Spectre is a family of security vulnerabilities in which an attacker manipulates a processor’s speculative execution to make a victim computation expose information that should remain inaccessible. Although the processor discards the incorrect computation’s visible results, traces can remain in internal hardware structures. An attacker can measure those traces through a side-channel attack and infer sensitive data. Publicly disclosed in January 2018, Spectre affected processor designs from multiple manufacturers and challenged assumptions underlying software isolation.
Spectre is not a single programming error or a conventional unauthorized memory read. It exploits a mismatch between a processor’s architectural behavior—the instructions and results that software is supposed to observe—and its microarchitectural behavior, which includes predictions, temporary execution, and cache activity. Successful attacks require particular combinations of attacker influence, usable victim instructions, accessible secrets, and observable hardware effects. The original attacks demonstrated that these combinations could occur across important security boundaries, including those enforced by language runtimes and operating systems.
The original Spectre disclosures described bounds-check bypass and branch-target injection, commonly called variants 1 and 2. Subsequent research identified related attacks involving other predictors and speculation mechanisms. Defenses consequently span processor design, firmware, operating systems, compilers, browsers, and application software; their effectiveness depends on which speculative paths and information channels they cover.
Discovery, disclosure, and scope
Spectre emerged from research into the security consequences of performance optimizations in modern processors. Cache-timing attacks were already established techniques in cryptography, where researchers had demonstrated that memory-access patterns could reveal secret-dependent behavior. Spectre added a different capability: an attacker could induce a victim to execute instructions transiently that would not execute along the correct architectural path, then recover information from their side effects.
The vulnerability was independently discovered by researchers associated with Google Project Zero and a collaboration involving academic and industry researchers. Jann Horn of Project Zero reported speculative-execution vulnerabilities to processor vendors in June 2017. The original Spectre paper, led by Paul Kocher and coauthored by researchers including Daniel Genkin, Daniel Gruss, Werner Haas, Mike Hamburg, Moritz Lipp, Stefan Mangard, Thomas Prescher, Michael Schwarz, and Yuval Yarom, described practical attacks against several isolation mechanisms. Public disclosure occurred on 3 January 2018, followed by extensive coordinated software and firmware updates. The paper appeared at the IEEE Symposium on Security and Privacy in 2019.
The initial Spectre vulnerabilities received the identifiers CVE-2017-5753 for bounds-check bypass and CVE-2017-5715 for branch-target injection. These identifiers remain useful because defenses for one variant do not automatically protect against the other. “Spectre” subsequently became an umbrella term for related attacks rather than a precise designation for every vulnerability involving speculation. The larger research category is transient-execution attacks, which also includes mechanisms that differ substantially from the original Spectre attacks.
Meltdown, disclosed at the same time, is an important distinction. The original Meltdown attack exploited transient behavior associated with a permission-checked load, allowing protected data to influence subsequent execution on affected processors before the access fault became architecturally effective. Original Spectre attacks instead induced a victim to mispredict a branch and transiently misuse data it could access. They did not generally grant arbitrary access to all physical memory or bypass every page-permission check.
The affected population was broad, including processors implementing x86 and Arm instruction sets, but vulnerability details differed across models. The presence of speculation alone does not establish that a particular attack works. Predictor organization, forwarding rules, cache behavior, privilege boundaries, and mitigation features all matter. Spectre therefore changed security assessment from a simple question of whether an instruction is architecturally permitted to a broader question about which computations and observations are possible before execution is resolved.
Speculation, rollback, and information leakage
Modern central processing units pursue performance by overlapping many operations. A memory access may take far longer than an arithmetic instruction, so processors use out-of-order execution to perform ready operations while earlier work waits. They also use branch prediction to guess whether a conditional branch will be taken and where an indirect branch will go. These predictions allow instruction fetching and execution to continue before the correct path is known.
Processors preserve architectural correctness by controlling when results become committed. An instruction may execute and produce temporary results without yet changing the architectural state visible to software. If a prediction proves wrong, the processor squashes the incorrectly executed instructions and redirects execution. Register results and stores from that path do not become the program’s committed outcome. This distinction between execution and commitment is essential: an instruction can affect internal hardware without ever becoming part of the architecturally completed instruction sequence.
The rollback is not a restoration of every physical effect. A transient load can populate a CPU cache, alter replacement state, initiate address translation, or affect contention for a shared execution resource. These effects are normally performance details, not direct program outputs. Spectre turns them into a communication channel. A victim transiently reads a secret, uses that value to select a location in an observable structure, and leaves a measurable trace.
A common demonstration uses a probe array. If a secret byte has value , transient code accesses an address of the form
where is the probe array’s base address and separates candidate locations. After speculation is resolved, the attacker measures which candidate loads quickly. A timing difference can reveal the selected value. Demonstrations often use a stride of 4,096 bytes, but that is an implementation choice rather than a defining property of Spectre. Cache layout, address translation, prefetching, and noise influence the appropriate encoding.
This extraction stage is a cache-timing attack, but caches are not the only possible channel. Research has also examined execution-port contention and other shared microarchitectural resources. The general requirement is that secret-dependent transient activity changes something the attacker can observe.
The complete mechanism has three logically distinct parts: inducing an incorrect transient path, making sensitive data affect that path’s behavior, and measuring the resulting effect. A processor can mispredict constantly during normal operation without creating an exploitable disclosure. Conversely, reducing timer precision or blocking one cache-measurement method does not necessarily remove the underlying secret-dependent transient computation.
Bounds-check bypass: Spectre variant 1
Bounds-check bypass targets code that first validates an index and then accesses an array. In a conventional execution, a condition such as prevents an access outside an array of length . Architecturally, the check is correct. The vulnerability arises when the processor predicts that the condition will succeed and begins the array access before the comparison has finished.
A schematic victim sequence is:
if x < length:
value = data[x]
access probe[value * stride]
If an attacker repeatedly supplies valid indices, the branch predictor can learn that the condition is usually true. The attacker then supplies an out-of-range index. If the processor speculates into the body, it may transiently load a value beyond the intended array and use it to select a location in the probe array. When the failed bounds check is resolved, the processor discards the incorrect execution, but the probe-array access may remain observable.
Delaying the bounds check can make the attack easier. For example, if the array length must be fetched from a slow memory location, the processor may have more time to execute younger instructions before discovering the misprediction. This interval is often called the speculation window. Its useful size depends on dependencies, cache misses, instruction availability, and processor implementation; it is not a fixed number of instructions.
Variant 1 does not mean that every out-of-range address becomes readable. The transient load must still be able to obtain relevant data under the processor’s applicable access rules, and a disclosure sequence must execute before the incorrect path is stopped. A common target is data within the victim’s address space but outside the memory region that the attacker is authorized to access. This makes the vulnerability particularly relevant to language runtimes and sandboxes, where software checks enforce boundaries finer than those provided by hardware page permissions.
A useful attack sequence in existing software is often called a gadget. A variant 1 gadget needs more than an unchecked transient read: some subsequent operation must make the value externally distinguishable. Real code may provide that operation indirectly, through a table lookup, pointer dereference, or control-flow decision rather than an obvious probe array.
Bounds-check bypass also extends beyond array indices. A conditional check may validate a pointer, an object type, a privilege state, or a length before accessing sensitive information. Some checks protect against architectural memory errors; others enforce access-control policy. The security question is whether misprediction can make a protected value influence an observable effect before the check takes effect. This is why conventional memory-safety testing alone cannot establish immunity to variant 1.
Branch-target injection: Spectre variant 2
Branch-target injection attacks the prediction of indirect control flow. An indirect jump or call obtains its destination from a register or memory rather than encoding the destination directly in the instruction. Such transfers occur in virtual method dispatch, callbacks, dynamically linked code, and many other mechanisms. To avoid waiting for the destination to be calculated, processors predict a likely target.
In Spectre variant 2, an attacker influences prediction state so that a victim’s indirect branch transiently transfers to an attacker-selected instruction sequence. That sequence need not be a valid destination in the program’s intended control flow. It must, however, be executable in the victim’s context and perform useful operations with the register and memory state available there. The correct target is eventually resolved, and the processor discards the misdirected execution.
The relevant prediction structures are microarchitectural rather than fully specified by the instruction set architecture. Implementations may index prediction tables using only parts of branch addresses or combine addresses with branch history. Different branches can therefore interfere through aliasing. Where prediction state is insufficiently separated, activity in one security context can influence predictions in another. The exact opportunities depend on processor generation and on whether execution occurs sequentially on one logical processor or concurrently on sibling threads.
An attack commonly distinguishes the poisoning location, where the attacker trains prediction state, from the victim location, where the consequential misprediction occurs. The attacker may need to arrange address relationships or control branch history so that training affects the victim branch. This requirement helps explain why a proof of concept for one processor and software configuration does not automatically transfer to another.
The disclosure gadget might load a secret through a pointer already present in a register, then use the secret to influence a cache access. Unlike variant 1, the attacker need not rely on a conditional bounds check immediately before the gadget. Instead, an indirect transfer provides the speculative entry point. This made variant 2 relevant to boundaries involving applications, operating-system kernels, and virtual machines, subject to the prediction and execution properties of the platform.
Return prediction forms a related but distinct area. Processors commonly use specialized return-prediction structures, often called return stack buffers, to predict function returns. Their behavior can interact with other branch predictors, especially when the expected return history is unavailable or mismatched. Later research showed that return instructions and branch-history effects could create attack paths not covered by simple models of indirect-branch poisoning. Accordingly, “protect indirect calls” and “prevent all speculative control-flow injection” are not equivalent goals.
Related variants and the evolving attack family
The Spectre name covers several mechanisms connected by attacker-influenced transient execution, but their triggers and defenses differ. A useful classification separates what initiates speculation, how a sensitive value becomes available, and which observation channel conveys it. This is more informative than treating every newly named attack as an entirely independent flaw or assuming that all share a single fix.
Speculative store bypass, disclosed in 2018 as CVE-2018-3639 and commonly called variant 4, involves memory-dependency prediction. A processor may allow a load to execute before it knows whether an older store writes the same address. If the predicted independence is wrong, the load may transiently obtain an older value. Subsequent instructions can use that stale value in a way that exposes information. The processor later replays or corrects the computation, but an observable trace may remain. This mechanism does not require the conditional-branch pattern of variant 1.
Other research has examined transient stores and their influence on later operations. An out-of-bounds store on a mispredicted path does not normally become an architecturally committed write, but it can affect transient dataflow and store-to-load forwarding. Such behavior can undermine assumptions that speculation only creates harmless discarded reads. The consequences depend on the particular forwarding and execution rules; transient modification is not equivalent to a persistent arbitrary-memory-write primitive.
NetSpectre, presented in 2018, explored speculative-execution disclosure through network interactions without requiring attacker-supplied code to execute locally on the target. Its demonstrations relied on suitable victim behavior and extensive repeated measurement. It showed that local high-resolution timers were not a universal prerequisite, while also illustrating the severe bandwidth and noise constraints that can accompany remote exploitation.
Branch History Injection, disclosed in 2022, demonstrated that branch-history manipulation could remain relevant even where newer controls restricted direct cross-boundary predictor influence. Retbleed, also disclosed in 2022, examined how return instructions could behave as useful speculative transfer points on affected processors, undermining assumptions behind some return-based defenses. These results reinforced the need to model interactions among prediction structures rather than treating each structure in isolation.
Not every transient-execution disclosure belongs to Spectre. Meltdown-type attacks, microarchitectural data sampling, and other mechanisms may expose data through different fault, forwarding, or buffer behaviors. Grouping them together can be useful when discussing speculative information flow, but it can obscure mitigation requirements. A control that stops branch-target injection may do nothing against stale data from a load, while a buffer-clearing mechanism may not address bounds-check bypass. Precise identification of the trigger and data path is therefore essential to interpreting both vulnerability reports and claims of protection.
Security boundaries and deployment environments
The practical significance of Spectre depends on the threat model: what the attacker can execute or influence, which data the victim can access, and which observations are available. Some attacks operate entirely within one process, while others seek to cross privilege levels, process boundaries, or virtualization boundaries. These cases share mechanisms but impose different prerequisites.
A major early concern was untrusted code inside a web browser. Browsers execute JavaScript supplied by websites and traditionally relied on language checks and runtime isolation to prevent access to unrelated memory. The original Spectre research demonstrated that browser-executed code could use speculative bounds-check bypass and timing techniques to infer data outside its intended accessible region. Just-in-time compilation mattered because generated native instructions, not source-language semantics alone, determined the available speculative behavior.
Browsers responded with several layers of change, including reduced timing precision and stronger process separation between sites. Process isolation can move sensitive information out of an attacker-controlled renderer’s address space, reducing the data available to an in-process speculative gadget. This is a structural reduction in exposure, not a guarantee that every microarchitectural channel between processes disappears. Browser security consequently involves both language-level constraints and decisions about which data may coexist within a process.
For operating systems, the concern includes attacker-controlled user programs influencing more privileged execution. Kernels contain indirect calls, bounds checks, and complex data structures that can supply relevant gadgets. Kernel mitigations therefore address both predictor state across privilege transitions and selected software sequences inside privileged code. An attack must still satisfy the requirements of the particular variant; the mere presence of a kernel secret is not enough to make it observable.
In cloud computing, the central question is whether one tenant can influence or observe another tenant or the host. Virtualization does not inherently create separate physical branch predictors or caches. Hypervisors may need to manage prediction state during virtual-machine transitions, and scheduling policy can affect whether mutually untrusted workloads share a core or run on sibling hardware threads. The relationship between a virtual processor and the underlying hardware is therefore part of the isolation model.
Managed runtimes, browser extensions, database extensions, and other plugin systems present similar issues at different scales. A component may be unable to issue arbitrary architectural loads yet still influence a victim’s predictions or inputs. Conversely, a demonstrated hardware weakness may be difficult to exploit if the deployment provides no suitable gadget, no reachable secret, or no usable observation channel. Spectre assessments must distinguish hardware susceptibility, software exposure, and a completed attack against a specific boundary.
Software and compiler defenses
Software defenses usually target one of three stages: entering an unsafe speculative path, allowing a secret to influence transient computation, or observing the resulting trace. These approaches are complementary. Blocking only the final measurement technique leaves the unsafe dataflow intact, whereas preventing that dataflow may protect against several observation channels at once.
For bounds-check bypass, one approach inserts a speculation barrier after a security-sensitive check and before the protected operation. If the platform defines the barrier to prevent younger instructions from executing until the check is resolved, the dangerous transient access cannot occur. On x86 processors, LFENCE has been used for this purpose under documented vendor behavior. Fence semantics must be interpreted for the target architecture and processor; a normal memory-ordering rule does not automatically provide a speculation barrier.
Another approach masks or constrains an index so that an invalid value selects only a safe location, even during transient execution. The intended protection depends on maintaining a genuine data dependency between validation and use. A compiler transformation that removes the dependency or reintroduces a branch can defeat the intended effect. Operating systems and toolchains therefore use architecture-specific primitives rather than relying solely on an intuitive source-code expression.
Speculative Load Hardening, developed for LLVM, uses compiler-generated dataflow to track potentially misspeculated execution and constrain values that could disclose information. Such transformations seek broader coverage than manually identifying a few vulnerable checks, but they introduce execution costs and depend on their model of processor behavior. They also need careful treatment of calls, returns, inline assembly, and interactions with code that was not compiled under the same scheme.
For branch-target injection, retpoline replaces certain indirect branches with a return-based sequence designed to trap speculative execution in a harmless loop while architectural execution reaches the intended destination. Introduced publicly in 2018, it provided a widely deployed software mitigation on supported x86 configurations. Its safety depends on return-prediction behavior. Later attacks, including Retbleed on affected processors, demonstrated why retpoline could not be treated as a processor-independent solution.
Other software defenses reduce the amount of sensitive data reachable from untrusted computation. Process separation, narrower interfaces, and least privilege can limit what a successful transient gadget can access. These measures complement rather than replace processor-specific defenses. Similarly, constant-time cryptographic programming removes many secret-dependent architectural accesses, but speculation can introduce paths beyond those considered in a conventional constant-time analysis.
Compiler and application defenses require attention to the emitted machine code. Security properties expressed in source code may not survive optimization, linking, or runtime code generation. A complete deployment must account for libraries and dynamically generated code as well as the main executable, and must specify which speculative behaviors its transformations are intended to constrain.
Processor, firmware, and operating-system controls
Hardware-assisted defenses address prediction and speculation at boundaries that application code cannot manage reliably. Many post-disclosure controls were delivered through microcode updates together with firmware and operating-system changes. Microcode can modify aspects of processor behavior or expose new controls, but the operating system or hypervisor usually determines when and how those controls are used.
For x86 branch-target injection, widely discussed controls include Indirect Branch Restricted Speculation, or IBRS; the Indirect Branch Predictor Barrier, or IBPB; and Single Thread Indirect Branch Predictors, or STIBP. IBRS constrains the influence of less privileged execution on subsequent indirect-branch predictions under its documented conditions. IBPB establishes a prediction barrier between execution contexts. STIBP restricts relevant predictor influence between sibling logical processors. Their guarantees are specific and should not be interpreted as clearing or partitioning every microarchitectural structure.
Enhanced IBRS, available on later processor generations, changes how protection can be maintained across privilege transitions compared with earlier IBRS usage. Even so, attacks involving branch history or different prediction mechanisms have required additional analysis and, on affected systems, further mitigations. Processor security documentation consequently distinguishes capabilities and controls at a finer level than a single “Spectre protected” flag.
Speculative Store Bypass Disable, commonly abbreviated SSBD, addresses speculative store bypass rather than the original indirect-branch attack. Operating systems may expose mechanisms to enable it for selected processes or execution environments, reflecting the fact that different workloads have different isolation requirements and performance sensitivities. Other architectures provide their own instructions and control registers for constraining speculation and managing prediction state.
The operating-system kernel coordinates these mechanisms with scheduling, context switches, and transitions into privileged code. A hypervisor has related responsibilities when entering or leaving a guest. Some mitigations operate at every relevant transition; others can be selected according to whether the next context belongs to the same security domain. Policies concerning simultaneous multithreading can also matter when sibling threads share resources that a mitigation does not sufficiently isolate.
Protection is therefore a property of the combined system, not just the processor model or patch level. Hardware must provide the necessary behavior, firmware must expose it correctly, and software must activate it at the appropriate boundaries. Conversely, a mitigation suitable for one processor may be unnecessary, ineffective, or costly on another. Operating systems such as Linux maintain processor-specific mitigation logic because prediction mechanisms and available controls vary across generations and vendors.
Evaluation, verification, and unresolved design questions
Evaluating Spectre requires more than searching for a particular instruction pattern. An analyst must determine whether attacker-controlled state can influence a prediction, whether the transient path can obtain sensitive data, and whether the resulting effect is measurable. Each stage depends on the target program, processor, and execution environment. A static code pattern may identify a potential gadget without demonstrating that a complete attack is feasible.
Experimental results are sensitive to cache residency, predictor training, address layout, interrupts, scheduling, and background activity. A reported extraction rate therefore describes a particular measurement setup rather than a universal property of Spectre. Laboratory experiments may intentionally simplify address discovery and noise. Real deployments can introduce additional obstacles, while repeated observations, alternative channels, or a more favorable gadget can improve an attacker’s signal.
Performance costs are similarly workload-dependent. A speculation barrier inside a frequently executed loop can be expensive because it interrupts overlap among operations. Predictor barriers and privilege-transition controls can particularly affect workloads with many system calls, context switches, or virtual-machine exits. Retpoline changes the cost of indirect control transfers, while compiler hardening adds instructions and dependencies. A meaningful performance comparison must specify the processor, mitigation configuration, workload, and baseline rather than assigning one percentage to Spectre protection as a whole.
Formal verification research addresses the gap between architectural correctness and speculative security. Traditional program proofs often describe only committed execution. Spectre analysis requires a model of transient instructions and attacker-visible observations. One important goal is noninterference: changes in secret inputs should not change what an attacker can observe, subject to the system’s allowed disclosures. Whether a proof establishes this property depends on which predictors, caches, forwarding behaviors, and timing effects the model includes.
Automated approaches include gadget detection, symbolic execution, analysis of generated code, and hardware-model exploration. Their results involve trade-offs. A broad model can flag paths that a real processor never executes, while a narrow model can miss an undocumented or newly discovered behavior. Testing provides evidence about actual hardware, but absence of a successful test is not proof that no usable transient path exists.
Processor-design proposals explore delaying sensitive cache effects until instructions are safe, separating speculative from committed state, partitioning shared predictors, and attaching security-domain information to prediction structures. These approaches face concrete engineering constraints: additional storage, cache-coherence interactions, critical-path delays, power consumption, and compatibility with existing software. Restricting one visible structure is also insufficient if the same transient value affects another observable resource. The design problem is to define and enforce which effects uncommitted execution may expose across a security boundary without discarding the performance benefits that speculation was introduced to provide.