Modern processors are designed to be fast, not necessarily to be private. To squeeze every drop of performance out of a silicon chip, CPUs engage in a high-stakes game of "guessing the future" known as speculative execution. While this makes programs run significantly faster, it creates a fundamental security gap: the processor executes instructions before it knows if they should be executed at all.
When the processor guesses wrong, it "squashes" the speculative instructions and rolls back the architectural state (like registers and memory). However, as Wenjie Xiong and Jakub Szefer explain in Survey of Transient Execution Attacks, this rollback is incomplete. The "ghost" instructions leave measurable footprints in the microarchitecture—the physical hardware structures that support the CPU—allowing attackers to exfiltrate secrets through side channels.
The Anatomy of a Speculative Leak
A transient execution attack typically follows a three-stage process. First, an attacker "trains" a hardware predictor (like the Branch Target Buffer) to make a specific mistake. Second, the CPU speculatively executes a "disclosure gadget"—a sequence of instructions that loads a secret and encodes it into a microarchitectural state. Finally, even after the CPU realizes its mistake and discards the instructions, the attacker measures the side effect to recover the secret.
This mechanism is not limited to simple branch mispredictions. Guoxing Chen and colleagues demonstrated in SgxPectre Attacks that even secure enclaves like Intel SGX are vulnerable. By poisoning the Return Stack Buffer (RSB), attackers can force an enclave to speculatively execute code that leaks its own internal keys.
Expanding the Speculative Window
The success of these attacks often depends on the "speculative window"—the amount of time the CPU spends executing incorrect instructions before it catches the error. Attackers have found clever ways to stretch this window to execute more complex gadgets.
- Resource Contention: Alyssa Milburn and Henrique Kawakami showed that in simultaneous multithreading (SMT) architectures, one thread can intentionally clog execution ports to slow down the pipeline of a sibling thread, artificially expanding the window for a malicious gadget to complete.
- Runahead Execution: In SPECRUN, Chaoqun Shen and Jiliang Zhang revealed that "runahead execution"—an optimization that keeps the pipeline moving during long memory stalls—can bypass the physical size limits of the Reorder Buffer, allowing for gadgets that are significantly longer than previously thought possible.
Beyond the Cache: New Leakage Vectors
While early attacks focused on the CPU cache, researchers are increasingly finding leaks in more obscure hardware structures.
- Microcode: Nicholas Mosier and Caroline Trippel discovered µSpectre, which exploits branch mispredictions within the CPU's internal microcode. Because microcode branches are often statically predicted, they provide a highly reliable vector for leaking data from internal buffers that software cannot normally see.
- Performance Counters: Pengfei Qiu and Dongsheng Wang identified PMUSpill, showing that Performance Monitor Units (PMUs) often fail to roll back their counters during a squash. This allows an attacker to "spill" secret data into a hardware counter and read it later.
- Memory Tagging: Even hardware security features like ARM's Memory Tagging Extension (MTE) can be subverted. Juhee Kim and Taesoo Kim developed TikTag, which exploits the fact that CPUs may speculatively block data forwarding if a tag check fails, turning a performance optimization into a 4-bit leakage channel.
From Confidentiality to Integrity
Perhaps the most surprising discovery is that speculative execution can threaten more than just privacy. Zhi Zhang 0001 and Yinqian Zhang demonstrated in GhostKnight that transient instructions can trigger Rowhammer-style bit flips in DRAM. Because the physical charge leakage in memory is not reversed when the CPU rolls back its logical state, speculation can be used to permanently modify data across privilege boundaries.
Building Leakage-Free Speculation
Defending against these attacks requires breaking the link between speculative execution and persistent microarchitectural changes.
One promising hardware approach is SafeSpec, proposed by Khaled N. Khasawneh and Dmitry Ponomarev. SafeSpec uses "shadow" structures to store speculative side effects, only promoting them to the main cache or TLB once the instruction is officially committed.
On the software side, researchers are moving toward formal verification. Santiago Arranz-Olmos and Gilles Barthe introduced Speculation-Passing Style (SPS), a method that transforms a program's speculative behavior into standard code. This allows developers to use existing "constant-time" verification tools to prove that their software is secure against Spectre-style leaks, bridging the gap between high-level code and low-level hardware reality.