4 ms·
> So, we get it. Complicated file and network formats, handled in C code leads to these types of security issues. Actually, the magic byte thing makes me think
by amluto 11y ago
> So, we get it. Complicated file and network formats, handled in C code leads to these types of security issues.
Actually, the magic byte thing makes me think this is a content sniffing issue, and the RCE might be due to a "feature". Rust won't help or, at best, would make it more awkward to exploit.
A capability-based (i.e. memory-safe, no accessible globals that can induce side effects) system would mitigate this, though. If I call out to ImageMagick and say "rescale this image", ImageMagick should not be able to initiate network requests in response.
- gamache 11y ago> A capability-based (i.e. memory-safe, no accessible globals that can induce side effects) system would mitigate this, though. Check out OpenBSD's pledge, it's addressing precisely this problem. http://man.openbsd.org/OpenBSD-current/man2/pledge.2 http://man.openbsd.org/OpenBSD-current/man2/pledge.2
- lmm 11y agoThat's a whack-a-mole approach that doesn't even try to define a real security boundary. It will catch the most common errors, sure, but it's not a long-term solution.
- amluto 11y ago> Check out OpenBSD's pledge, it's addressing precisely this problem. Au contraire. You can fork(), restrict yourself to a couple of pipes in a subprocess, pledge(), do the calculation in the subprocess, and exit the subprocess. It'll work, and it'll be slow. But this isn't at all specific to pledge() -- seccomp can do exactly the same thing, arguably more simply. Performance will suck either way. <rant>I have yet to see a credible argument for how pledge() is better than seccomp. You could almost implement pledge() as a library function that uses seccomp, and the I consider the one part of pledge (execve behavior) that this won't get right to be a misfeature in pledge<./rant> The performance of that scheme will be abysmal for anything that does very fine-grained sandboxing. What you want is language support. E (erights.org) does this as a matter of course. Rust and similar languages could if they were to allow subsetting of globally accessible objects. Java and .NET tried to do this and fell utterly flat. I've considered trying to get a nice Linux feature to do this kind of sandboxing with kernel help (call a function that can only write to a certain memory aperture without the overhead of forking every time), and maybe I'll get this working some day.
- caf 11y agoIsn't intel's new memory protection keys feature intended to allow exactly this sort of thing?
- amluto 11y agoNope. Intel's MPX is an opt-in thing to assist with pointer bounds checking.
- caf 11y agoI was thinking of MPK, not MPX. You'd set the library's code and data pages to protection key 1, along with the page containing a library access trampoline, leaving the rest of the address space with protection key 0. You'd call into the library through the trampoline, which would revoke access to protection key 0, call into the library, then restore access to key 0.
- throwaway2048 11y agoYou could indeed implement pledge as a seccomp wrapper, pledge wins because its near trivial to add to programs.
- justincormack 11y agoThere are several differences, eg pledge is not inherited by exec, while seccomp is. Also seccomp is vastly more complex and it is not really possible to filter by eg filename, so you need additional tools.
- dozzie 11y ago> If I call out to ImageMagick and say "rescale this image", ImageMagick should not be able to initiate network requests in response. Impossible in the world where programmers routinely cram together networking and file transformations without any regard for whether the operation belongs there or not (build systems that on `compile' command download random things from internets; even Rust's build system does such a dumb thing by downloading rustc after running an hour-long LLVM compilation, instead of failing before doing anything).
- steveklabnik 11y agoHm, this should be in parallel. If downloading stage0 waits till after LLVM complies, that's a bug, IMHO.
- catnaroek 11y agoSo the way to prevent robots from throwing people of a cliff is to use a capability system that only allows robots to kill people when explicit authorized?