Memory-corruption exploits read the bytes directly. Side channels are sneakier: they never read the secret, they observe a physical effect of the victim using it. FLUSH+RELOAD is the cleanest of them — it turns the CPU cache into a one-bit oracle ("did the victim access this line?") and reconstructs a secret from a sequence of those bits.
- primitive
- clflush + rdtsc (both unprivileged on x86)
- leaks
- the victim's memory-access pattern -> key bits, control flow, KASLR
the three steps#
The whole technique fits in its name, run in a tight loop over a shared cache line — a line in a library both you and the victim map, so a cache hit is genuinely shared state:
|
The gap between an L1/L3 hit and a DRAM miss is enormous and stable — tens of cycles versus a couple hundred — so a single threshold separates them:
turning hits into a secret#
A hit/miss on one line is nothing; a pattern of them is the secret. The classic victims:
- Square-and-multiply (RSA/DSA). The exponentiation loop calls a
multiplyroutine only on1bits of the secret exponent. Probe the cache line holdingmultiply's code: a HIT in an iteration means that exponent bit was1. Walk the loop, read the exponent — and from it, the private key. - T-table AES. Software AES indexes lookup tables by
key ⊕ plaintext. Which table line gets cached reveals the index, hence key bytes. - KASLR / control flow. Probe function lines to learn which branch a victim took or whether a page is mapped — leaking layout, not key material.
an exponent, one bit at a time
Probing the multiply line across the exponentiation loop, HIT = 1, MISS = 0:
the defences (and their cost)#
- Constant-time code. Crypto with no secret-dependent branches or table indices has no access pattern to leak — the real fix. Scatter-gather / bitsliced AES, Montgomery ladders for exponentiation.
- Kill the sharing. FLUSH+RELOAD needs shared memory; disabling memory deduplication / KSM removes the cross-process channel (same-address-space leaks remain).
- Restrict the tools. Coarsening or trapping
rdtsc, and limitingclflush, raises the noise floor — partial, and costly to legitimate code.
FLUSH+RELOAD is the gateway to the whole microarchitectural-leak family — Prime+ Probe when there's no shared memory, and the Spectre/Meltdown attacks that use exactly this cache-timing oracle to exfiltrate the results of speculative reads. The unifying idea: computation leaves footprints in shared hardware state, and timing reads the footprints. You don't need to see the secret — only to watch the machine react to it.