Spectre is a family of hardware vulnerabilities in modern processors that abuse speculative execution to make a program read data it should never access and then leak that data through a microarchitectural side channel, usually the CPU cache. In cybersecurity, the Spectre vulnerability is notable because it is not a software bug in a single product but a consequence of performance design shared by nearly every high-performance CPU built over two decades.
Spectre was disclosed publicly in January 2018 together with its sibling Meltdown, after a coordinated disclosure period involving processor vendors, operating system developers and browser makers. The original variants received the identifiers CVE-2017-5753 and CVE-2017-5715, and the class has since grown to include many related attacks.
How Spectre exploits speculative execution
Spectre works by training the branch predictor so that the processor speculatively executes instructions along a path the program would never take architecturally. Modern CPUs guess the outcome of conditional branches and indirect jumps and continue executing ahead, then discard the results if the guess was wrong. The architectural state, meaning registers and memory, is rolled back correctly.
The flaw is that the microarchitectural state is not rolled back. If a speculatively executed instruction loads a secret byte and then uses that byte as an index into a probe array, the corresponding cache line stays loaded after the misprediction is discovered. The attacker then measures access times to each line of the probe array; the one that loads quickly reveals the secret value. This technique is known as Flush+Reload or a related cache timing method.
The attack therefore has three stages, and each stage relies on a different hardware behavior. The table below summarizes them.
| Stage | What happens | Hardware feature abused |
|---|---|---|
| Mistraining | Attacker repeatedly runs a branch with benign inputs | Branch predictor history |
| Speculative access | Victim code reads out-of-bounds or secret data speculatively | Speculative and out-of-order execution |
| Encoding | Secret value selects which cache line is loaded | Data cache fill behavior |
| Recovery | Attacker times memory accesses to decode the value | Cache hit and miss latency difference |
Main variants of the Spectre family
The Spectre name now covers a growing class of transient execution attacks rather than one bug. Each variant targets a different predictor or buffer, which is why a single patch has never closed the whole class.
| Variant | Identifier | Predictor or mechanism | Typical mitigation |
|---|---|---|---|
| Variant 1, bounds check bypass | CVE-2017-5753 | Conditional branch predictor | Index masking, speculation barriers |
| Variant 2, branch target injection | CVE-2017-5715 | Indirect branch predictor | Retpoline, IBRS, eIBRS |
| Variant 4, speculative store bypass | CVE-2018-3639 | Memory disambiguation | SSBD control bit |
| SpectreRSB | Several CVEs | Return stack buffer | RSB stuffing |
| Branch history injection | CVE-2022-0001 | Branch history buffer | History clearing, eIBRS hardening |
Variant 3 is Meltdown, which is a separate issue: Meltdown lets user code read kernel memory because of a deferred permission check, while Spectre makes the victim program itself perform the illegal access speculatively. This distinction matters because Meltdown was largely fixed by kernel page table isolation and newer silicon, whereas Spectre requires mitigation in compilers, kernels, hypervisors and applications.
How Spectre differs from conventional software vulnerabilities
Spectre differs from bugs such as a buffer overflow or use-after-free because no memory safety rule is violated architecturally. Correct, bounds-checked code can still leak secrets, since the bounds check itself is speculatively bypassed. Memory-safe languages therefore do not prevent Spectre on their own.
| Property | Spectre | Meltdown | Buffer overflow |
|---|---|---|---|
| Root cause | Speculation across branches | Late permission check | Missing bounds check in code |
| Impact | Information disclosure | Information disclosure | Often code execution |
| Fix location | Software and microcode | Kernel and newer CPUs | Application code |
| Affected vendors | Intel, AMD, Arm, others | Mainly Intel, some Arm | Any software |
| Typical CVSS impact | Confidentiality only | Confidentiality only | Confidentiality, integrity, availability |
Spectre is a read-only primitive: it discloses data but does not by itself let an attacker modify memory or run code. Its danger lies in what can be read, such as cryptographic keys, session tokens and passwords, particularly across isolation boundaries like browser tabs, virtual machines and the user-kernel split.
Mitigating Spectre in practice
Spectre mitigation is layered and workload-dependent, combining microcode updates, operating system changes, compiler instrumentation and application design. Defenders choose controls according to which trust boundary they need to protect.
| Layer | Mitigation | Main protection | Cost |
|---|---|---|---|
| Compiler | Retpoline, speculative load hardening | Indirect branches, bounds checks | Low to moderate |
| Microcode | IBRS, IBPB, STIBP | Cross-privilege and cross-thread prediction | Moderate, workload-dependent |
| Kernel | Array index masking, barrier insertion | System call gadgets | Low |
| Browser | Site isolation, reduced timer precision | Cross-site data in one process | Higher memory use |
| Hypervisor | Predictor flushing on VM exit | Guest-to-host and guest-to-guest leaks | Moderate |
Performance overhead varies widely. Compute-bound workloads may see negligible slowdown, while workloads with frequent system calls, context switches or virtualization exits have historically seen double-digit percentage losses on older processors. Newer CPUs with enhanced IBRS and hardware predictor isolation reduce this cost considerably.
- Keep CPU microcode and firmware current, because many mitigations require new control bits.
- Run operating systems and hypervisors with default Spectre protections enabled unless a measured risk assessment justifies otherwise.
- Isolate mutually untrusted code in separate processes or virtual machines rather than relying on language sandboxes.
- Use constant-time cryptographic libraries that also apply speculation hardening.
Limitations, exploitability and common misconceptions
Real-world Spectre exploitation is difficult but demonstrated. An attacker usually needs code execution on the same physical machine, a suitable gadget in the victim code and a precise timer. Leakage rates in proofs of concept range from bytes to kilobytes per second, which is slow but sufficient for extracting keys or credentials.
- Misconception: Spectre is fully patched. The class cannot be removed without abandoning speculation, so new variants continue to appear.
- Misconception: only Intel is affected. AMD, Arm and other high-performance designs are also vulnerable to several variants.
- Misconception: disabling JavaScript solves it. Native code, containers and virtual machines remain exposed to local attackers.
- Misconception: low CVSS means low priority. In multi-tenant cloud environments the confidentiality impact can be severe.
In vulnerability management, Spectre-class issues are usually tracked as long-lived platform risks rather than one-time patches. Each new variant receives its own identifier and security advisory, and teams must verify that the relevant mitigation is both installed and actually enabled on each host.
In plain words
A modern processor tries to save time by guessing what a program will do next and doing that work in advance. If the guess is wrong, it throws the work away. Spectre shows that the thrown-away work leaves fingerprints in the processor cache.
An attacker can trick the processor into guessing wrong on purpose, so it briefly touches secret data. The secret is never handed over directly, but by timing how fast certain memory loads, the attacker can reconstruct the secret piece by piece. It is like learning which book someone read in a library by noticing which shelf is still warm.
A real-world example
A cloud hosting provider runs virtual machines from many customers on the same physical servers. After a new Spectre variant affecting the indirect branch predictor is announced, the security team learns that a malicious tenant could, in principle, read memory from a neighboring virtual machine, including TLS private keys.
The team applies the vendor microcode update, upgrades the hypervisor so that it flushes branch predictors on every VM exit, and enables enhanced IBRS on newer hosts. Benchmarks show an overhead of about 3 to 8 percent on I/O-heavy hosts and almost none on compute-heavy ones. Older hosts with higher overhead are scheduled for retirement. The outcome is that the cross-tenant leakage path is closed across the fleet, and the team records the mitigation status for each host in its vulnerability management system.