Project Zero: Exploiting the DRAM rowhammer bug to gain kernel privileges
Some DRAM chips flip bits in memory rows adjacent to rows that are accessed repeatedly, and the authors built working exploits that use this to break out of the Native Client sandbox and to gain kernel privileges on Linux. An unprivileged process could induce a bit flip in a page table entry, gain write access to its own page table, and thereby read and write all of physical memory.
googleprojectzero.blogspot.com
Published on googleprojectzero.blogspot.com
Posted by Mark Seaborn, sandbox builder and breaker, with contributions by Thomas Dullien, reverse engineer
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the underlying mistake is in the DRAM hardware itself: shrinking cells interact electrically, so repeated row activations disturb neighbouring rows and flip bits, and software such as NaCl and the Linux kernel assumed memory never changes unless written.
Impact
An unprivileged userland process could gain read-write access to all of physical memory and run code as root, though the authors note the exploit needs a machine vulnerable to rowhammer and access to pagemap, and the NaCl route was mitigated by disallowing the cache-flush instruction.
What the attacker needed
Vulnerable DRAM hardware; unprivileged code execution; access to pagemap or huge pages
The fix
The NaCl sandbox was fixed by changing its validator to disallow the cache-flush instruction, but the authors say the kernel exploit is harder to mitigate on existing machines.
How it was found
- Fill the sandbox's dynamic code area with many sandboxed indirect jump sequences.
- Repeatedly row-hammer the dynamic code area using cache flushes, picking random address pairs.
- Search the dynamic code area for bit flips and use an exploitable one to jump to hidden shell code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Computer memory stores data in tiny cells arranged in rows. On some chips, reading the same row over and over very quickly can make nearby cells lose or gain charge, so a stored 0 can turn into a 1 or the reverse. The authors turned this hardware quirk into a way for an ordinary program to take control of the whole machine.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.