33C3: Memory Deduplication, the Hacker’s Friend

At the 33rd annual Chaos Communications Congress, [Antonio Barresi] and [Erik Bosman] presented not one, not two, but three (3!!) great hacks that were all based on exploiting memory de-duplication in virtual machines. If you’re interested in security, you should definitely watch the talk, embedded below. And grab the slides too. (PDF)

Memory de-duplication is the forbidden fruit for large VM setups — obviously dangerous but so tempting. Imagine that you’re hosting VMs and you notice that many of the machines have the same things in memory at the same time. Maybe we’re all watching the same cat videos. They can save on global memory across the machines by simply storing one copy of the cat video and pointing to the shared memory block from each of the machines that uses it. Notionally separate machines are sharing memory. What could go wrong?

Basically, it takes slightly longer to access that memory when it’s de-duplicated, because the VM has to go lookup the address of memory that’s outside of itself. If an attacker were interested in finding out if another VM was watching cat videos, he could put the cat video in his memory, wait for the VM manager to de-duplicate it, and then time how long it takes to make a modification in his memory. If it’s longer than some threshold, someone else is watching cat videos. The rest of the talk explains three exploits of this vulnerability.

The CAIN attack allows the attacker to figure out what address a given memory page has in a neighboring VM. Think, for instance, of a Windows DLL. The basic idea is as explained above, but figuring out the offset of the code within a memory page is hard, but they brute-force it by writing the same code fragment at all offsets, and figuring out which one matches. This attack so far just leaks the memory location of programs running on another virtual machine, but think of it as a stepping-stone.

The second attack adds a hardware bug, the Rowhammer attack, to exploit a process running on the same machine. In particular, they’re running Javascript code to exploit Microsoft’s “secure” Edge browser. They get the address of a code and heap pointer using their memory de-duplication attack, create a code object, and use Rowhammer to turn the address of the object into a pointer and run it. All thanks to memory de-duplication.

Finally, “Flip Feng Shui” writes new data into the victim VM by corrupting a local copy of shared memory that then gets mirrored back to the victim. Because a bit flipped in Rowhammer is unpredictable but repeatable, the first stage is to figure out where bits are going to flip, and then align a copy of the data you want changed on the victim’s VM in memory. Then the memory is Rowhammered, and because it hasn’t been written to explicitly, after a while it can percolate back to the victim.

The demonstration includes flipping a few bits in a victim’s SSH public key to turn it into a key that’s easily factorable, and then logging in. In a second attack, they combine the key bit flip with possession of the web domain “ubunvu.com” to install arbitrary software on the victim’s VM using its automatic upgrade mechanism. Holy cow.

This talk is a bit heavy at times, but the takeaways are stunning. It’s “obvious” that memory de-duplication should be a problem, but actually exploiting it (three ways!) is a tour de force. They don’t say that they were responsible, but it’s worth noting that Windows 10 doesn’t use memory de-duplication anymore.


Filed under: security hacks

from Hackaday http://ift.tt/2kEbMC4
via IFTTT