Earlier quoted context omitted.
> The code doesn't have to be wrong for every input. It may be wrong just for pathological cases that don't occur in the field unless specifically crafted. I could argue this more but it doesn't matter, that was just a little tangent, getting the size wrong will not let anything out of the sandbox. > The assumption was that the code tries to clean up the buffer immediately after use. Cleaning up would be removing the…
> Cleaning up would be removing the mmap. How are you going to exploit that? Your scenario is not very clear. If a buffer is going to be reused across calls, then cleaning after use is not the same thing as unmapping. One example for cleaning up a buffer after use would be zeroing. If there's a bug in the calculation for the amount of zeroing needed, then leftover attacker-controlled data can bleed back from the sand…
> In other words, the attacker can now write arbitrary data into the unsandboxed process's memory at a semi-known location (known page offset) inside the mapped buffer.
But what is the arbitrary data going to be?
1. If it's gadgets with known lower bits, then you could put that into a plain-old image file, no decoder exploits needed. Also this requires the second dumb mistake of the coder going out of their way to mark the buffer as executable.
2. If it's data you want to exfiltrate, you could just gather that after you trigger your unrelated exploit. This is only useful if everything aligns to drop the private data you want in that specific section of memory, and then the buffer is reused, and then the private data is removed from everywhere else, and then you run an unrelated exploit to actually give you control. This is exceptionally niche.
> harmless on its own
Ha.