4 ms·
That depends entirely on what the software needs to do. For image decoding in particular, you can put the software into an exceptionally restrictive sandbox, o
by Dylan16807 3y ago
That depends entirely on what the software needs to do.
For image decoding in particular, you can put the software into an exceptionally restrictive sandbox, or use a language that builds in the same restrictions.
No I/O. No system calls. Just churn internally and fill a preallocated section of memory with RGBA.
The broader system will still have weaknesses, but it won't have this kind, and this kind keeps happening.
- vilunov 3y agoWhat exactly is "an exceptionally restrictive sandbox"? There are virtual machines such as JVM, V8, or even QEMU. These are sandboxes, which run either some special bytecode or native code with extreme performance drawbacks. Media decoders are performance- and energy-sensitive pieces of software in the end. And media decoders actually ARE sandboxes of sorts. They are designed to interpret media formats, sometimes even Turing-complete bytecode in retrictive and isolated environments. And like any sandboxes, they too have bugs.
- Dylan16807 3y ago> JVM, V8, or even QEMU > extreme performance drawbacks That's just not true. > And media decoders actually ARE sandboxes of sorts. They are designed to interpret media formats, sometimes even Turing-complete bytecode in retrictive and isolated environments. And like any sandboxes, they too have bugs. It's pretty easy to sandbox a simple bytecode, but that's not the bulk of what a media decoder is doing. A plain old decoder is mostly not sandboxing what it does.
- saagarjha 3y agoThat's an awfully big preallocated array you have there. It would be pretty inefficient for that section of memory to be copied around, right? Let's map it into both processes. Also, image decoding is pretty hard, let's offload some of it to dedicated hardware. Of course, that hardware needs to have access to it mediated by the kernel. And the hardware needs to be able to access that shared memory, which was of course allocated correctly and the IOMMU setup was done correctly… You see how even simple things are difficult to secure when they have to be implemented in practice?
- Dylan16807 3y agoMapping pure RGBA across processes is safe, but also a single extra copy is not a big performance impact in the first place for an image decoder. Configuring the IOMMU is one of the easiest parts of doing it in hardware. That's not going to make things "difficult to secure". And allocating the chunk of memory is trivial.
- saagarjha 3y agoI think disagree with every single point you brought up, having seeing exploits that involve all of them.
- Dylan16807 3y agoIf you've seen an exploit caused by a big pre-allocated array of untrusted RGBA data, please explain how. (If you mean they put evil data through it and then used a separate exploit to run it, that's not a vulnerability, that's just "data transfer exists".) And you seeing someone screw up an IOMMU doesn't disqualify it from being one of the easiest parts of a hardware decoder.
- saagarjha 3y agoCode to calculate size of preallocated array is incorrect. Size ends up too small or underflows. Buffer is reused across calls. Buffer is actually mapped across processes and thus page-aligned. Code to check how much space is needed checks number of pages versus actual number of bytes, and fails to clear leftover data correctly. Code receives RGBA buffer but expects some other encoding. Accidentally reads out of bounds as a result. You can definitely say “oh these are stupid and I wouldn’t screw this up” but people do and that’s what really matters.
- Dylan16807 3y ago> Code to calculate size of preallocated array is incorrect. Size ends up too small or underflows. If you go outside the array you copied/mapped out of the sandbox, then that doesn't let the attacker code escape the sandbox, you just put some of your own data onto the screen. If you mean the sandbox isn't given enough memory, then that will make the sandbox exit when it hits unmapped addresses. And how did you screw up length x width x 4? > Buffer is reused across calls. Buffer is actually mapped across processes and thus page-aligned. Code to check how much space is needed checks number of pages versus actual number of bytes, and fails to clear leftover data correctly. The sandboxed process doesn't have any way to exfiltrate data. At most it can display it back to you, which is not really any worse than innocent code which could also send back the leftover data. > Code receives RGBA buffer but expects some other encoding. Accidentally reads out of bounds as a result. Reads out of bounds and does what with it? That doesn't sound like a vulnerability to me. It might display private data or crash, but that's entirely of its own volition. The behavior would be the same between innocent code in the sandbox and malicious code in the sandbox.