
Chapter 18 of 50
A Leaky Crystal Ball
“Be wary of anyone who claims to be able to see the future.”
Speculative execution optimizes performance by executing instructions before knowing if they’re needed, leaving microarchitectural traces in cache memory even when results are discarded. Attacks such as Meltdown and Spectre exploit this, by constructing code sequences where a secret value determines which memory addresses are accessed during speculation. By measuring which addresses load quickly afterward (indicating they were cached), attackers can determine if specific bits were 0 or 1, allowing secrets to be extracted across privilege boundaries.
Topics
- CPU Pipeline Architecture
- Speculative Execution
- Meltdown & Spectre
- Cache Timing Channels
- Branch Predictor Training
- Microarchitectural State
- Kernel Memory Extraction
- Mitigations & Performance
- KPTI & Retpolines
- Hardware Vulnerabilities
- 30% Performance Cost
Sidenote
Top (Celebrity in Disguise): A secret value is hidden in either Room A or Room B, represented by the celebrity and their doppelgänger. The attacker does not know which room contains the real secret. Middle (Reporter’s Probe): The reporter (attacker) sends a crafted request: ordering crème brûlée to Room A. This dish is special because only the celebrity would ever receive it. The CPU (chef) will prepare it only if the celebrity is in Room A. Bottom (Timing Side Channel): The reporter then makes a normal order, sweet potato pie. If the torch is still warm, the pie finishes faster — revealing that the crème brûlée preparation occurred, and thus that the celebrity is in Room A. If no torch warmth remains, the celebrity must be in Room B. This mirrors speculative execution: incorrect paths are rolled back architecturally, but their side effects persist in microarchitectural state, leaking secrets through timing.
