Rowhammer Attack
Rowhammer Attack
Assignment # 1
Rowhammer Attack
1
Rowhammer Attack: A Deep Dive
1. Introduction
The Rowhammer attack is a hardware-based security vulnerability that affects DRAM (Dynamic
Random Access Memory). It was first discovered in 2014, and it exploits the way modern memory cells
are physically structured.
Why is it dangerous?
o It can be used to escalate privileges, bypass security mechanisms, and steal sensitive data from
other processes.
DRAM stores data in capacitors, which hold electrical charges. Each capacitor represents a bit (0 or 1).
These capacitors are arranged in rows and controlled by row access transistors.
o Each memory row is activated (opened) when the CPU accesses it.
o Repeated access to a row (hammering) causes electrical interference, leading to bit flips in
adjacent rows.
o If a row is accessed too frequently, it can cause bit flips in neighboring rows.
o These bit flips can alter program data, security settings, or even OS kernel data.
Structure of DRAM:
2
Row consists of cells and each cell consists of capacitor and transistor. The capacitor stores a tiny amount
3
Hammering a DRAM with flush and reload:
When you access a row very often, bits might flip in the neighbouring row.
Before:
Row A: 1101010110
Row C: 1101010110
After Rowhammer:
Row A: 1101010110
Row C: 1101010110
4
3.1 Step-by-Step Memory Attack
o The attacker hammers selected rows in memory thousands to millions of times per
second.
o This process flips bits in the adjacent row without directly accessing it.
o The OS stores page table entries (PTEs) in memory to manage access control.
5
4. Escalating Privileges
o Once privileges are elevated, attackers can read and modify other processes' memory.
o This allows them to steal passwords, encryption keys, or inject malicious code.
No, each process has its own virtual Yes, multiple processes access the same
Is it shared?
memory space. physical memory.
6
Each process runs in its own isolated memory space.
Security mechanisms like Address Space Layout Randomization (ASLR) make it harder for
attackers to predict memory locations.
Key Weakness: Rowhammer does not attack virtual memory; instead, it attacks physical
memory directly. Since virtual memory is mapped to physical memory, bit flips in physical
memory can affect multiple virtual memory spaces.
Additionally, modern CPUs include memory protection mechanisms like Intel SGX and ARM
TrustZone, which Rowhammer can also target.
Since Rowhammer operates at the hardware level, it can break process isolation in several ways:
Even though processes are separated in virtual memory, they share the same physical RAM. If an
attacker can flip bits in a shared memory region, they can:
Example:
Process A (user application) has virtual memory mapped to physical memory region X.
Process B (another application) also has a different virtual address, but it maps to physical
memory region X.
If Process A runs a Rowhammer attack, it can cause bit flips in region X, affecting Process B
without needing direct access to it.
Attackers often use cache flushing (e.g., CLFLUSH instruction) to increase bit flip reliability,
ensuring the attack works more effectively.
In cloud computing, multiple virtual machines (VMs) from different users run on the same physical
server. These VMs share the same DRAM, even though they have separate virtual memory.
7
1. A hacker rents a VM in a cloud provider (AWS, Google Cloud, etc.).
3. The attack flips bits in memory used by another victim's VM running on the same server.
4. This allows the hacker to modify or leak sensitive information from another customer’s VM!
Real-World Example:
Researchers demonstrated Rowhammer attacks in the cloud where one VM could exploit bit
flips to gain control over another VM running on the same physical server.
Cloud providers mitigate Rowhammer risks through ECC RAM, TRR (Target Row Refresh),
and disabling memory deduplication.
A special Rowhammer attack called Flip Feng Shui allows attackers to target specific bits in a victim’s
memory in a cloud environment.
1. Memory Deduplication: Cloud providers use deduplication to save space by sharing identical
memory pages between VMs.
2. Attacker Injects Data: The attacker forces the system to store their data in the same physical
page as the victim’s.
3. Bit Flip Corruption: The attacker hammers the memory to flip a bit in the shared memory,
corrupting the victim’s sensitive data (like cryptographic keys).
Impact:
Attackers can modify SSH keys, authentication data, or passwords in a victim's memory.
Cloud providers like AWS, Azure, and Google Cloud have disabled memory deduplication to
prevent such attacks.
Unlike traditional Rowhammer, Flip Feng Shui gives attackers better control over which bits
flip, allowing precision attacks on security-critical data.
If a Rowhammer attack flips bits in these keys, decryption might become easier or the key itself
can be completely exposed.
AES (Advanced Encryption Standard) uses fixed-length keys (128-bit, 192-bit, 256-bit).
8
If an attacker flips just a few bits in an AES key, it can weaken encryption.
In some cases, this allows attackers to recover the original key faster, breaking security.
Unlike traditional Rowhammer, Flip Feng Shui gives attackers better control over which bits
flip, allowing precision attacks on security-critical data.
If a Rowhammer attack targets a memory page storing password hashes, an attacker can corrupt
or extract those hashes.
If an attacker flips a bit in the user’s permission level, they could escalate privileges (e.g., a
normal user becomes an admin).
9
5. Real-World Rowhammer Attack Variants
1. Double-Sided Rowhammer
2. Single-Sided Rowhammer
#include <stdlib.h>
10
for (int i = 0; i < NUM_ACCESSES; i++) {
_mm_clflush(addr2);
int main() {
if (!memory) {
return -1;
hammer_memory(addr1, addr2);
printf("Rowhammer executed!\n");
free(memory);
return 0;
11
Repeatedly accesses two specific rows (A and C).
o ECC RAM detects and corrects bit flips before they cause harm.
3. Software-Based Mitigations
o Some modern DRAM chips include Target Row Refresh (TRR) to block Rowhammer
effects.
References:
12