upvote
There was an even more restrictive single NUL byte heap overflow in glibc in 2014 that the ProjectZero folks managed to turn into ACE and thus an LPE in setuid binaries[1]. The final section that talks about bickering over exploitability seems particularly pertinent today.

[1]: https://projectzero.google/2014/08/the-poisoned-nul-byte-201...

reply
The simplest core mechanism of these kinds of exploits is that you can groom the heap by triggering lots of similar-sized allocations, so you have a good guess as to what the heap will contain where your wild write occurs, and then you can trigger specific allocations to land juicy victim structs in the heap where you want them.

It's an evolution of the old "nop sled" idea from stack overflows (and viruses before that), where you don't know exactly what the stack addresses you're targeting are, but you can in your exploit trigger payload include data that will carpet bomb the stack with NOP instructions so that you have a big window to guess.

reply
I was under the impression that everyone adopted the OpenBSD randomized memory heap by default. Does this imply that it's not enough to prevent this sort of attack from working? If this is even slightly repeatable then the mechanism doesn't seem to be sufficiently random. I'm not an expert on low level memory allocation but at a high level it seems like we need to do a better job of randomizing the heap if this sort of thing is still possible.
reply
All the heaps are (probably) randomized. I haven't seen an exploit for this (but know them to exist). ASLR is not a reliable countermeasure for these kinds of flaws. Here's a good starting point:

https://azeria-labs.com/grooming-the-ios-kernel-heap/

reply
To be able to effectively turn a single byte overwrite into ACE is still challenging because you will corrupt outside of your buffer, but this corruption must be meaningful.

I would be curious to see how they were able to exploit it here.

reply
There was an article on this topic in Phrack 55 back in 1999: https://phrack.org/issues/55/frame-pointer-overwriting#artic...

Exploitation conditions are likely more challenging today but that’s the earliest reference I know for exploiting a single byte overflow.

reply
The commit message for the Ruby fix says it's a heap buffer, so frame pointer smashing would not apply here.
reply
Exactly, these advanced heap exploitation techniques are a relatively new development (last decade or so) and were not even remotely known in 1999. Most of the developments were driven by browser exploitation.
reply
The next byte in the heap might be the size of an allocation, so if you overwrite it and then free that other allocation, the heap code will think that there is a very large free area there instead of a small one, once you allocate that, you now have a very large heap overflow and can do more fun things. That is just one idea, there are many other ways.
reply