4 ms·
That'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
by saagarjha 3y ago
That'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.
- Hackbraten 3y ago> And how did you screw up length x width x 4? There’s a million ways to screw that up. People botch SCM merges. People are hungover. People are distracted. People are tired. People are heartbroken. People are going through divorces. People have parents dying. People forget numbers. People make copy-paste mistakes. All the time. > The sandboxed process doesn't have any way to exfiltrate data. You can abuse it to gain a (known-page-offset) write primitive in the other, non-sandboxed process to which the buffer is also mapped.
- Dylan16807 3y ago> People make copy-paste mistakes. All the time. But if you do that every image looks wrong and it's vanishingly unlikely to get into a release. > You can abuse it to gain a (known-page-offset) write primitive in the other, non-sandboxed process to which the buffer is also mapped. There's no reason to have the memory mapped into both processes at once, and you can't exploit the bytes you write without a real vulnerability. Since it's a one-shot write into the buffer, if your intent is using it as an exploit step then you might as well encode an actual image with your exploit-assisting bytes.