Spectre

Also known as: Spectre vulnerability

On this page 7

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.

StageWhat happensHardware feature abused
MistrainingAttacker repeatedly runs a branch with benign inputsBranch predictor history
Speculative accessVictim code reads out-of-bounds or secret data speculativelySpeculative and out-of-order execution
EncodingSecret value selects which cache line is loadedData cache fill behavior
RecoveryAttacker times memory accesses to decode the valueCache hit and miss latency difference
Stages of a typical Spectre attack

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.

VariantIdentifierPredictor or mechanismTypical mitigation
Variant 1, bounds check bypassCVE-2017-5753Conditional branch predictorIndex masking, speculation barriers
Variant 2, branch target injectionCVE-2017-5715Indirect branch predictorRetpoline, IBRS, eIBRS
Variant 4, speculative store bypassCVE-2018-3639Memory disambiguationSSBD control bit
SpectreRSBSeveral CVEsReturn stack bufferRSB stuffing
Branch history injectionCVE-2022-0001Branch history bufferHistory clearing, eIBRS hardening
Selected Spectre variants and their targets

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.

PropertySpectreMeltdownBuffer overflow
Root causeSpeculation across branchesLate permission checkMissing bounds check in code
ImpactInformation disclosureInformation disclosureOften code execution
Fix locationSoftware and microcodeKernel and newer CPUsApplication code
Affected vendorsIntel, AMD, Arm, othersMainly Intel, some ArmAny software
Typical CVSS impactConfidentiality onlyConfidentiality onlyConfidentiality, integrity, availability
Spectre compared with related vulnerability types

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.

LayerMitigationMain protectionCost
CompilerRetpoline, speculative load hardeningIndirect branches, bounds checksLow to moderate
MicrocodeIBRS, IBPB, STIBPCross-privilege and cross-thread predictionModerate, workload-dependent
KernelArray index masking, barrier insertionSystem call gadgetsLow
BrowserSite isolation, reduced timer precisionCross-site data in one processHigher memory use
HypervisorPredictor flushing on VM exitGuest-to-host and guest-to-guest leaksModerate
Spectre mitigations by layer

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.