Vulnerability3 Jan 2018

Spectre and Meltdown

CPUs that guess ahead to go faster left traces of secret data in the cache, which any program could measure. The flaw was in the hardware.

Severity
History books
Difficulty
advanced
Companies
Intel, AMD, ARM, Google Project Zero
Tech
CPUs, Speculative execution, CPU cache, Operating system kernels, Side channels
Root cause
latent bug, insecure defaults

The story

Quick (1 min)

On 3 January 2018, researchers revealed Meltdown and Spectre, flaws in how nearly all modern computer processors work.

To go faster, CPUs guess ahead: they start running instructions before they know whether they're needed (called speculative execution). If the guess was wrong, the CPU throws the results away. But traces are left behind in the CPU cache, a small fast memory. By timing how quickly memory loads, an attacker can work out what secret data the CPU touched while guessing.

Meltdown let ordinary programs read the operating system's memory on many Intel chips. Spectre tricks other programs into leaking their secrets and affects Intel, AMD and ARM chips. Because the problem is in the hardware design, the fixes were software workarounds, some of which cost performance.

The lesson: performance tricks can create security holes, and "invisible" side effects like timing can leak secrets.

Keep reading to the end to earn XP.Read. XP earned.

Engineer (2 min)

Speculative execution. Modern CPUs keep many instructions in flight, predict branches and execute ahead. Wrong guesses are rolled back architecturally (registers are restored), but micro-architectural state such as the cache is not.

The side channel. If speculative code loads array[secret * 4096], that line ends up cached. Afterwards, the attacker times accesses to each possible line; the fast one reveals secret. Project Zero's paper is titled "Reading privileged memory with a side-channel".

The three variants (Project Zero):

  • Variant 1, bounds check bypass (CVE-2017-5753), Spectre: train the branch predictor so code like if (x < len) y = arr[arr2[x]] runs speculatively with an out-of-bounds x.
  • Variant 2, branch target injection (CVE-2017-5715), Spectre: poison indirect branch prediction so victim code speculatively jumps to an attacker-chosen gadget. Project Zero read host kernel memory from inside a KVM guest at about 1,500 bytes per second.
  • Variant 3, rogue data cache load (CVE-2017-5754), Meltdown: a user process speculatively reads kernel memory before the permission check takes effect.

Who's affected. Meltdown: "every Intel processor which implements out-of-order execution is potentially affected, which is effectively every processor since 1995 (except Intel Itanium and Intel Atom before 2013)," verified on Intel from 2011. Spectre was verified on Intel, AMD and ARM (meltdownattack.com).

Mitigations:

  • Meltdown: kernel page-table isolation (KPTI, formerly KAISER) on Linux, plus patches for Windows and macOS. Kernel memory is no longer mapped into user processes. Some workloads saw performance loss.
  • Spectre: harder. Compiler mitigations (LLVM, MSVC), speculation barriers (ARM header) and hardening of specific code. The site notes specific known Spectre exploits can be blocked, but the class is hard to eliminate.

Interview takeaway: isolation boundaries assume hardware behaves as documented; side channels break that assumption, and fixes trade performance for safety.

Keep reading to the end to earn XP.Read. XP earned.

Deep dive (2 min)

Timeline

  • 1 June 2017: Google Project Zero (Jann Horn) reports the issues to Intel, AMD and ARM (Project Zero).
  • 28 July 2017: affected hardware and software vendors had been made aware (Wikipedia).
  • 3 January 2018: public disclosure, several days ahead of the coordinated 9 January date, after news sites began reporting on Linux kernel commits. Some platforms, such as Ubuntu, didn't have patches ready (Wikipedia). Microsoft releases emergency Windows updates the same day.
  • 4 January 2018: CVE-2017-5753 and CVE-2017-5754 published in NVD.

Independent discovery

Per meltdownattack.com, Meltdown was independently found by three teams: Jann Horn (Project Zero); Werner Haas and Thomas Prescher (Cyberus Technology); and Daniel Gruss, Moritz Lipp, Stefan Mangard and Michael Schwarz (Graz University of Technology). Spectre was independently found by Jann Horn and Paul Kocher, with collaborators including Daniel Genkin, Mike Hamburg, Moritz Lipp and Yuval Yarom. Project Zero's post lists the other researchers who reported the issues.

Proofs of concept (Project Zero)

  • Variant 1 in userspace on Intel Haswell Xeon, AMD FX, AMD PRO and ARM Cortex-A57 (same process).
  • Variant 1 reading a 4 GiB range of kernel memory under a standard Linux kernel on Haswell Xeon (on AMD PRO only with the non-default BPF JIT enabled).
  • Variant 2 from a KVM guest reading host kernel memory, about 1,500 bytes per second.
  • Variant 3 reading kernel memory on Haswell Xeon when the target data is in the L1D cache.

Performance cost (Wikipedia)

Some researchers claimed up to 30% loss from KPTI on certain workloads, which Intel considered an exaggeration. Intel said impacts were "workload-dependent." Benchmarks found little to no effect in games but larger effects in synthetic I/O and some databases. Chips with PCID (Haswell onward) were less affected.

Why it was different

Most vulnerabilities are a bug in one product. These came from a design technique used across the industry for decades. Hardware can't be patched in place, so the industry relied on OS, compiler, browser and microcode workarounds, and on new CPU designs over time.

Severity

NVD scores CVE-2017-5753 and CVE-2017-5754 at CVSS 3.1 5.6 each. They need local code execution, but the breadth of affected systems made them historic.

Keep reading to the end to earn XP.Read. XP earned.

Failure replay

Step by step, what broke and what it hit next.

  1. Since ~1995
    CPU speculative executiondegraded

    Processors execute ahead of branch decisions for speed. Wrong guesses are rolled back, but cache contents aren't.

    Affects: CPU cache

  2. Attack
    Attacker programcompromised

    Unprivileged code trains the branch predictor or sets up a speculative read of memory it isn't allowed to access.

    Affects: CPU speculative execution

  3. Attack
    CPU speculative executioncompromised

    Before the permission or bounds check resolves, the CPU speculatively loads secret-dependent data into the cache.

    Affects: CPU cache

  4. Attack
    CPU cachecompromised

    The speculative work is discarded, but a cache line tied to the secret value stays warm.

    Affects: Attacker program

  5. Attack
    Attacker programcompromised

    Timing memory accesses reveals which line is cached, leaking kernel or other-process secrets bit by bit.

    Affects: OS kernel

  6. Jan 3, 2018
    OS kernelrecovering

    Disclosure lands days early. KPTI and emergency OS patches unmap kernel memory from user processes to block Meltdown.

  7. 2018 onward
    Compilers and browsersrecovering

    Spectre needs ongoing mitigations, such as speculation barriers and compiler changes, plus new hardware designs.

Impact

Who was affected
Nearly all modern processors capable of speculative execution; Meltdown mainly Intel CPUs (effectively all out-of-order Intel chips since 1995, with some exceptions), Spectre verified on Intel, AMD and ARM; desktops, laptops, phones and cloud servers.
How long
The design flaw existed for decades; mitigation began with disclosure on 3 January 2018 and continued for years.
Cost
not disclosed (performance costs of mitigations were workload-dependent).

Lessons

  • Side effects that don't change results, like timing and cache state, can still leak secrets.
  • Performance optimisations need security review, even in hardware.
  • Isolation relies on the layer below; when hardware leaks, software has to compensate.
  • Embargoes leak; plan for early disclosure.
  • Mitigations can cost performance; measure for your workloads.

Quiz

  1. What CPU feature do Spectre and Meltdown exploit?

    Check answer

    Speculative execution combined with cache timing side channels. Speculatively executed instructions leave traces in the cache that can be measured by timing.

  2. Which variant is Meltdown?

    Check answer

    Variant 3, rogue data cache load. Meltdown is variant 3 (CVE-2017-5754); Spectre covers variants 1 and 2.

  3. What Linux mitigation was developed against Meltdown?

    Check answer

    KPTI (kernel page-table isolation, formerly KAISER). KPTI stops mapping kernel memory into user processes, blocking Meltdown's reads.

  4. Why was the disclosure on 3 January 2018 earlier than planned?

    Check answer

    News sites began reporting on Linux kernel commits before the coordinated 9 January date. Press reports about kernel patches forced disclosure several days early, before every platform had patches.

Interview prep

Try answering out loud before you open the model answer.

  1. security

    Explain at a high level how a speculative execution side-channel attack like Meltdown or Spectre leaks data.

    Show model answer

    CPUs execute instructions speculatively before checks resolve. The attacker arranges for speculative code to read a secret and use it to index memory, such as array[secret*4096], which brings a specific line into the cache. The CPU later discards the results, but the cache line stays warm. The attacker then times access to each candidate line; the fast one reveals the secret. Meltdown reads kernel memory across the user/kernel boundary on affected Intel chips. Spectre tricks a victim's own code, via a mistrained branch predictor, into leaking its data.

    A strong answer hits:

    • Speculative execution before checks
    • Secret-dependent memory access
    • Cache timing reveals the value
    • Meltdown vs Spectre differences
  2. system design

    You run a multi-tenant cloud. How do Spectre and Meltdown change your threat model, and what mitigations would you deploy?

    Show model answer

    Tenants sharing physical CPUs could potentially read each other's or the host's memory, so co-location becomes a risk. Mitigations: patch host and guest kernels (KPTI), apply microcode updates and hypervisor patches, enable compiler mitigations for sensitive code, and consider dedicated hosts for high-security tenants. Benchmark performance impact and add capacity where needed. Track new variants and plan hardware refreshes to CPUs with built-in mitigations.

    A strong answer hits:

    • Shared hardware breaks tenant isolation assumptions
    • KPTI, microcode, hypervisor patches
    • Dedicated hosts for sensitive workloads
    • Capacity planning for mitigation overhead
  3. behavioural

    A critical patch will slow your service by 10–30% on some workloads. How do you decide whether and how to roll it out?

    Show model answer

    Start with risk: who could exploit this in our environment (untrusted code, multi-tenant)? Benchmark our real workloads rather than relying on headline numbers; Meltdown impacts varied widely, and CPUs with PCID were less affected. Roll out in stages with monitoring, add capacity where needed, and prioritise the most exposed systems. Communicate the trade-off to stakeholders. Security usually wins when the threat applies, but measured data guides capacity and timing.

    A strong answer hits:

    • Assess exploitability in your context
    • Benchmark real workloads
    • Staged rollout and capacity planning
    • Communicate trade-offs

Go deeper