Skip to content
Info disclosure Write-up Advanced

Project Rain:L1TF

The L1 Terminal Fault (L1TF) vulnerability in some Intel CPUs allows an attacker-controlled virtual machine to speculatively read data from the L1 data cache that it should not have access to, because a terminal fault forwards a guest physical address to the cache as if it were a host physical address. Combined with a half-Spectre gadget in the host kernel, an attacker could obtain an arbitrary RAM read primitive and leak secrets such as host OS data, victim VM processes, and a victim Nginx server's private TLS key.

bughunters.google.com

Published on bughunters.google.com

This blog provides a detailed overview of the L1TF vulnerability, a CPU vulnerability on some Intel CPUs (Skylake and older), how it could be exploited, as well as different mitigation strategies. We also explain how Google responded to this issue and the work we have done to fix this vulnerability together with the…

The author, on bughunters.google.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

Context

This is a write-up of Project Rain:L1TF, published on Google's bughunters site on 19 September 2025. It is not a web application report: the subject is a CPU vulnerability, L1 Terminal Fault (L1TF), on some Intel CPUs (Skylake and older), how it can be exploited, and how it is mitigated. The work was done together with VUSec, the Systems and Network Security Group at Vrije Universiteit Amsterdam, and a researcher from the University of Birmingham who collaborated on the L1TF Reloaded exploit and had to remain anonymous until the double blind review process finished.

The exploit described is a guest-to-host attack against a virtualised environment. The attacker controls a VM; the target is the host kernel (Linux with KVM) and other VMs co-scheduled on the same physical machine. The write-up also describes Google's response: mitigations deployed in 2018, gadget fixes upstreamed to Linux in 2020, and Address Space Isolation (ASI), which Google deployed on affected processors as a result of this research.

Setup

VUSec proposed the research project and Google sponsored it with a sole-tenant node so the research could be conducted safely without potentially affecting other customers. Once VUSec succeeded, they visited Google's offices in Zurich and presented the results. Google awarded a $151,515 USD reward, the highest tier of the Google Cloud VRP and the first time researchers have been rewarded at this level.

The exploit targets Linux KVM. The write-up links to Linux kernel source for the structures involved. The affected hardware includes Skylake and some other Intel CPUs; Cascade Lake and more modern CPUs are not vulnerable to this particular vulnerability, as listed on Intel's affected processors page.

Finding it

The starting point is a property of the microarchitecture rather than a bug in an application. The write-up builds the background needed to see why the attack works:

  • Caching. Modern CPUs use hierarchical SRAM caches (L1 fastest, LLC slowest) to hide DRAM latency.
  • Speculative execution. The CPU prepares future instructions ahead of their turn and discards the results if they turn out to be unnecessary. Micro-operations belonging to one instruction retire together; when they all retire the instruction is said to be architecturally executed. Branch prediction, using buffers such as the Branch Target Buffer or Branch History Table, keeps a steady stream of instructions coming.
  • Hyperthreading (SMT). Most x86 CPUs have 2 hyperthreads per physical core, and the hyperthreads share most core resources, including some buffers.
  • Multitasking. The OS time-shares the CPU between tasks and must clear microarchitectural buffers on switches; some of these buffers are shared across hyperthreads, so sometimes the only way to stop leakage is to avoid running one hyperthread while its sibling runs untrusted code.
  • Memory addressing. Page tables translate virtual to physical addresses. On x86 with 4-level paging the virtual address is split into indices into PML4, PDPT, PD and PT, and the entry flags (present, writeable, cacheable) matter later.
  • Virtualisation. The guest sees Guest Physical Addresses; the host translates them through extended page tables (EPT) to Host Physical Addresses. The gap between GPA and HPA is the root cause of the vulnerability.
From the original on bughunters.google.com

Fig. 1 shows a trace from uica.uops.info of out-of-order execution of a few assembly instructions. The example used to explain branch prediction is this snippet, where the CPU must decide what to fetch after the conditional branch on 402009 before the comparison result is known:

Text
  402000:  mov rax, [rsp-100]
  402005:  cmp rax, 100
  402009:  je 0x401000
  40200f:  mov rbx, [rsp-999]
  402017:  int3

If the CPU speculates that the line on 40200f is executed, it may fetch data from the memory pointed at by rsp-999.

From the original on bughunters.google.com

Fig. 2 diagrams how the CPU schedules tasks on hyperthreads that share buffers.

From the original on bughunters.google.com

Fig. 3 gives the pseudocode and table for the 4-level paging walk:

Text
virtual_addr = 0xFF_FF_00_11_22_33_44_55
pml4e_i = (virtual_addr >> 39) & 0b111_111_111
pdpte_i = (virtual_addr >> 30) & 0b111_111_111
pde_i = (virtual_addr >> 21) & 0b111_111_111
pte_i = (virtual_addr >> 12) & 0b111_111_111
pfn = pml4[pml4e_i]->pdpt[pdpte_i]->pd[pde_i]->pt[pte_i]->pfn
phys_addr = (pfn << 12) | (virtual_addr & 0b111_111_111_111)

Second level translation is described as follows:

Text
guest_page_table_base_gpa = read_guest_cr3()

gpa = walk_guest_page_tables(gva, guest_page_table_base_gpa)

host_ept_base_hpa = read_ept_pml4_register()

hpa = walk_host_ept(gpa, host_ept_base_hpa)

Code 1. Pseudocode of how second level address translation works.

The design oversight is that the host shares CPU resources with guests, letting lower privilege levels infer information about data in shared resources such as the data caches.

Exploitation

L1TF allows an attacker VM to speculatively read any data in the core-local L1 data cache, including data the VM should not access. L1TF Reloaded turns this into an arbitrary RAM read primitive. The attacker VM subsequently:

  1. chooses the secret to be any byte in RAM it wants to leak;
  2. performs a hypercall that tricks the host into a speculative out-of-bounds memory access, putting the secret into the L1 cache;
  3. triggers L1TF to obtain speculative access to the secret and speculatively encodes it into the data cache;
  4. decodes the secret from the data cache via timing side-channel analysis.

With this primitive the exploit leaks data from the host OS to detect victim VMs on the same machine, leaks which processes those victims run, and, from a victim Nginx web server, leaks its private TLS key, breaking that server's HTTPS security.

Step 1: Half-Spectre, caching secret data

L1TF can only leak data that is in the L1 cache. Forcing the host or other VMs to read the secret architecturally is targeted by the deployed mitigations, so the exploit instead relies on speculative execution populating the cache. A host code snippet that can be made to load secret data this way is a half-Spectre gadget, also called a cache load gadget, prefetch gadget or MDS gadget:

Text
if (idx < MAX) x = y[idx]

Code 2. Example of a Half-spectre gadget

The attacker controls idx. If the bounds check is slow to evaluate, the CPU speculatively takes the likely path and y[idx] loads data from RAM into L1; when the misprediction is detected the cache fill is not rolled back. With a 64-bit idx, y[idx] can reference any address in the host kernel's virtual address space. On x86_64 the Linux kernel linearly maps all physical memory in the physmap, so physical address p is at physmap_base + p. Most heap-allocated kernel objects live in the physmap, including the y array, so knowing the host physical address of y lets the exploit bring any physical address into L1 by varying idx. VUSec found such a gadget in Linux's KVM subsystem, shallow in the callstack and therefore easy to reach.

Step 2: L1 Terminal Fault

L1TF is caused by a logic error in how Skylake and some other Intel CPUs behave after a terminal fault, a page fault triggered by referencing invalid memory. The translation is terminated immediately, but the CPU may still load the referenced data from the L1 cache.

From the original on bughunters.google.com

Fig. 4 shows how the vulnerability ends up reading unexpected data.

The attacker maps a guest virtual address to a guest physical address but marks the entry as not present or reserved in the guest's page tables, which the attacker can do because they control their own VM. Accessing it causes a terminal fault that aborts translation before the EPT walk derives the HPA. The flaw is that the premature abort forwards the guest physical address to L1 cache resolution as if it were a host physical address, so the CPU reads any L1 data whose host physical address equals the faulting GPA. Speculative operations after the fault are discarded, but cache effects are not undone.

Step 3: Reading secret data

The attacker turns the mistakenly fetched value into an architectural observation with a dependent load, for example (this code is fully in the attacker VM):

Text
char reload_buffer[64*256];
char *gva = GVA;
char secret = *gva;
reload_buffer[64*secret];

Only the first two instructions execute architecturally; the last is never reached because of the page fault, but it executes speculatively and caches the secret-th cacheline of reload_buffer. The guest's page fault handler then measures access latency to each of the 256 cachelines. If 255 take 200+ cycles and only entry 99 takes 4 cycles, the attacker concludes secret was 99. This is Flush+Reload, turning speculative access into architectural knowledge.

Step 4: Leaking addressing information

The exploit needs host virtual addresses (the gadget's base y and the secret's location) and the host physical address of the secret. Most of its time goes into leaking this addressing information.

The first phase leaks y in host physical memory by brute force: trigger the gadget with idx zero to pull y[0] into L1, then brute-force its host physical address; a correct guess gives a measurable Flush+Reload signal. False positives are filtered using a priori knowledge of the data patterns at y[0] and by failure of later steps.

The second phase breaks the host kernel's KASLR by leaking the physmap base, which also gives y's host virtual address. In the VUSec exploit y was an array of struct kvm_lapic structures. The exploit leaks the pointer y[0] to the first LAPIC structure and brute-forces its host physical address as before; with both the physmap virtual address and the physical address known, subtracting them gives the physmap base.

From the original on bughunters.google.com

Fig. 5 shows how the attacker chases pointers found in structs to find the page tables of other tasks on the host.

The exploit then chases physmap pointers: given a physmap pointer, subtracting the physmap base gives its host physical address, which yields the idx that loads the pointed-to data into L1 and leaks it with L1TF. Following a chain of heap-allocated objects leads to the host's root page table, and traversing the host's page tables translates arbitrary host virtual addresses to host physical addresses. struct kvm_lapic contains a pointer to a struct kvm_vcpu, which contains a pointer to a struct pid, which is in a linked list of all tasks using that PID; traversing it finds the task_struct for the vCPU task. The task_struct points to the task's mm_struct, which contains a pointer to the top-level page table for the vCPU task. Leaking page table entries across each level lets the exploit translate arbitrary host virtual addresses, moving from chasing physmap pointers to chasing arbitrary host kernel pointers.

The leakage primitive is imperfect: half-Spectre, L1TF and Flush+Reload can each produce errors (for example leaking a 0x79 byte as 0x00), and a single error breaks a pointer chain. VUSec therefore uses chasing-and-checking: after a number of chased pointers, the exploit re-leaks a known prior pointer in the chain to check it has not gone off track.

Step 5: Leaking interesting secret data

Dumping all RAM would be slow and the state changes over time, so the attacker locates interesting data through host metadata. All task_structs are in a global linked list; starting from its own CPU's task_struct, the attacker finds the task for a victim VM's vCPU. That task's file descriptor table contains a descriptor for KVM's vCPU object, which points to the task's kvm_vcpu. From there the attacker leaks the root of the victim VM's EPTs (in kvm_vcpu_arch -> kvm_mmu -> kvm_mmu_root_info) and the guest's cr3 register value (in kvm_vcpu_arch), which holds the physical address of the root of the guest's own page tables. With both, the exploit performs a two-dimensional page table walk to translate any guest virtual address to a host physical address readable with L1TF.

The attacker still does not know where interesting data lies, so it first breaks KASLR in the guest using the guest's page tables to find the kernel text and the kernel's direct map. It then follows pointers from the guest kernel's init_task, a global at a known offset from the start of the guest kernel, traversing the task list. In the demonstrated exploit the target was an Nginx web server process in the guest: the exploit went through the process's mm_struct, found its root page table and the virtual address of the start of its heap, and translated the heap address to its physical counterpart. Nginx stores its private key at a static location on the heap surrounded by magic numbers, and L1TF with chase-and-check leaks the key successfully.

Or watch on YouTube
From the original on bughunters.google.com

A video demo of the exploit is included at the end of the blog.

Root cause

The root cause is the mismatch between Guest Physical Addresses and Host Physical Addresses. When a terminal fault aborts translation before the EPT walk, the CPU forwards the GPA to L1 cache resolution as if it were an HPA, so the attacker chooses which host physical cache line is read by choosing the faulting GPA. The cache fill is not rolled back on misprediction, and the half-Spectre gadget in KVM lets the attacker place arbitrary RAM contents into L1 in the first place. Existing defences did not stop it because the deployed L1TF mitigations target architectural loads of secret data, not speculative ones, and because gadget hunting is reactive: new gadgets, including kvm_sched_yield and __pv_send_ipi, were introduced over time.

Impact

An attacker controlling a VM on a shared machine can read arbitrary RAM, detect victim VMs co-scheduled on the same machine, learn which processes they run, and, as demonstrated, leak a victim Nginx server's private TLS key, breaking its HTTPS security. The write-up frames this as demonstrating that CPU exploits are real and that the barrier to developing one that breaches across VMs is becoming easier to cross. The attack requires affected hardware (Skylake and some other Intel CPUs) and the ability to run a VM on the same machine as the victim.

Fix

Google deployed multiple mitigations at the time of the initial L1TF discovery in 2018. As explained in 2018, Google ensured an individual core is never concurrently shared between distinct virtual machines, and when VMs were scheduled sequentially the L1 data cache was completely flushed. Intel's official documentation expected hypervisors to flush the cache before VM Enter and to disable the sibling hyperthread unless both virtual CPUs ran guest code, with core stunning on every VM Exit; the write-up notes this would be very expensive.

From the original on bughunters.google.com

Fig. 6 explains Intel's core scheduling to prevent sharing a physical core between two virtual machines.

From the original on bughunters.google.com

Fig. 7 shows Intel's relative performance of different workloads with a sibling hyperthread enabled or disabled.

For cache load gadgets, Google fixed them internally and upstreamed the fixes to Linux in 2020, mostly using the array_index_nospec helper, which returns an index bounded to [0, size) even under speculation by building an all-0 or all-1 bit mask. This was applied selectively where users could control an offset, because doing it everywhere has a significant performance cost. The gadgets used by the VUSec exploit were kvm_sched_yield, triggered by the KVM_HC_SCHED_YIELD hypercall, and __pv_send_ipi, triggered by the KVM_HC_SEND_IPI hypercall; both were fixed in the commit "KVM: x86: use array_index_nospec with indices that come from guest".

From the original on bughunters.google.com

Fig. 8 compares page tables with and without Address Space Isolation.

Address Space Isolation is Google's long-term proactive solution: speculative execution stops when it hits a page translation fault, so kernel-context speculation cannot leak data not mapped into the kernel's address space. ASI separates sensitive memory (including all userspace and guest data) from nonsensitive memory. On a VM Exit no sensitive data is present in the kernel's address space; accessing it triggers an ASI Exit, which switches to the full address space and clears shared CPU buffers such as branch predictor buffers. Preparing a VM Enter triggers an ASI Enter, which reverts to the restricted address space and flushes CPU data buffers such as the L1 data cache. Performance testing with ASI and L1 data cache flush on ASI Entry showed an impact of less than 3% across almost all benchmarks, with less than 1% common.

ASI alone is not sufficient because buffers are shared between hyperthreads: hyperthread 1 runs guest code, hyperthread 2 does an ASI exit and triggers a half-Spectre gadget, hyperthread 1 reads L1 data, then hyperthread 2 does an ASI enter and clears L1. Google searched for half-Spectre gadgets triggerable by a guest during an ASI exit and found none, but for future-proofing the sibling hyperthread must be stunned whenever an ASI exit occurs. This stunning-during-ASI-exit functionality is integrated into Google's internal kernel fork and is intended to be released externally in a subsequent patch series once testing and qualification are finalised. Google has also been working on ASI with the Linux Kernel community.

Variants to test

  • Other hypercalls and VM Exit paths. Look for bounds-checked array accesses where a guest controls the index, in the style of kvm_sched_yield and __pv_send_ipi. A positive result is a path reachable from a guest hypercall that speculatively loads attacker-chosen memory into L1.
  • Other physmap-resident structures. Any heap object reachable from a leaked pointer can serve as a starting point for pointer chasing. A positive result is a chain from a known structure to a page table or other sensitive object that survives chase-and-check.
  • Other guest kernels and workloads. The Nginx TLS key was one example; the same two-dimensional page table walk applies to any guest process whose data location can be derived from kernel structures. A positive result is a successful translation of a guest virtual address to a host physical address and a correct leak of known data.
  • Sibling hyperthread scheduling. Test whether an attacker can arrange the hyperthread conditions needed to read L1 data between an ASI exit and the following ASI enter. A positive result is a measurable leak across the window despite the flush on ASI Entry.
  • Gadget regressions over time. Re-audit code paths that take guest-controlled offsets after kernel changes, since new gadgets were introduced after the 2020 fixes. A positive result is a newly reachable half-Spectre gadget in a VM Exit path.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 25 min read.

What happened, in plain words

This is a story about a weakness built into some computer chips, not a bug in a website. The chips in question are certain Intel processors, including Skylake and some other Intel CPUs. The weakness is called L1 Terminal Fault, or L1TF for short. It lets one virtual machine peek at data that belongs to the machine it runs on, or to other virtual machines sharing the same physical computer.

A quick word on virtual machines, since everything here depends on them. A physical computer can be split by software into several pretend computers, each with its own operating system. Each pretend computer is a virtual machine, or VM. The real machine underneath is called the host, and the software that creates and runs the VMs is called the hypervisor. Cloud providers sell time on VMs, so many customers' VMs can end up on the same physical box. The whole promise is that one customer cannot see another customer's data. This research shows a way to break that promise on the affected chips.

The work was done by researchers from VUSec, the Systems and Network Security Group at Vrije Universiteit Amsterdam, together with a researcher from the University of Birmingham. That researcher had to stay anonymous until a double blind review process finished, which is now over. Google sponsored the project with a dedicated physical machine, called a sole-tenant node, so the research could be done safely without touching other customers. When the researchers succeeded, they visited Google's offices in Zurich and presented the results. Google paid them a $151,515 USD reward, the highest tier of the Google Cloud Vulnerability Rewards Program, and the first time anyone had been rewarded at that level.

The exploit they built is called L1TF Reloaded. It targets Linux running the KVM hypervisor. Cascade Lake and newer Intel chips are not vulnerable to this particular weakness, according to Intel's list of affected processors.

The background you need

Before the attack makes sense, you need a handful of ideas about how a processor works. None of them are about websites or passwords; they are about the hardware itself.

Caching

Reading from the main memory of a computer, the DRAM chips, is slow in processor terms. It takes many clock cycles, where a cycle is one tick of the processor's internal clock. To hide that slowness, processors keep small, very fast memories called caches right next to the processing units. These caches are made of SRAM, which is fast but expensive and power hungry, so they are small, measured in megabytes. They are arranged in levels: the L1 cache is the smallest and fastest, and the Last-Level Cache, or LLC, is the largest and slowest of the caches. When the processor reads a piece of memory, a copy lands in the cache, and the next read of the same piece is much quicker. This is why caches matter for security: a copy of secret data can sit in a cache where other code might reach it.

Speculative execution

From the original on bughunters.google.com

Figure 1 is a trace from uica.uops.info showing a few assembly instructions being executed out of order. Assembly instructions are the low-level commands a processor actually runs.

Processors try to never sit idle. When an instruction will take a long time, for example because it reads memory that is not cached, the processor starts working on later instructions ahead of their turn. If it later turns out those later instructions were not needed, for example because a memory read failed or a division by zero happened, the processor throws the results away. Each assembly instruction is made of one or more smaller steps called micro-operations, and all micro-operations of one instruction finish together. When they all finish, the instruction is said to be architecturally executed, meaning its effect is real and permanent.

To keep a steady stream of work coming, the processor has to guess which way branches go. A branch is a decision point such as a loop or an if condition. The processor uses history stored in small buffers, often called the Branch Target Buffer or Branch History Table, plus heuristics, to predict the path and fetch instructions from it early. Here is the example from the write-up, where the processor must decide what to fetch after the conditional branch at 402009 before the comparison result is known:

Text
  402000:  mov rax, [rsp-100]
  402005:  cmp rax, 100
  402009:  je 0x401000
  40200f:  mov rbx, [rsp-999]
  402017:  int3

Line by line:

  • 402000: mov rax, [rsp-100] loads a value from memory into a register called rax. A register is a tiny storage slot inside the processor. rsp is a register that points at the current stack, a region of memory used for temporary values, and [rsp-100] means the address 100 bytes below that point.
  • 402005: cmp rax, 100 compares the value in rax with the number 100.
  • 402009: je 0x401000 means jump to address 0x401000 if the comparison was equal. This is the branch whose direction is not yet known.
  • 40200f: mov rbx, [rsp-999] loads another value from memory into rbx. This is the instruction the processor might start early if it guesses the branch is not taken.
  • 402017: int3 is a special instruction that stops execution, used here as a marker.

If the processor speculates that the line at 40200f will run, it may fetch data from the memory pointed at by rsp-999. That fetch is speculative: it may be thrown away, but as we will see, its effect on the cache is not.

Hyperthreading

From the original on bughunters.google.com

Figure 2 diagrams how the processor schedules tasks on hyperthreads that share some buffers.

Hyperthreading, also called Simultaneous Multithreading or SMT, lets one physical core present itself as two logical processors, called threads or hyperthreads. The operating system schedules work on each as if they were separate processors. In reality the two hyperthreads share most of the core's resources. Most x86 processors have two hyperthreads per physical core, so every thread has a sibling thread. This is efficient, because when one thread waits for memory the other can use the core. It also matters for security, because anything one hyperthread leaves in a shared buffer can potentially be seen by its sibling.

Multitasking

The operating system shares the processor between many tasks by time sharing. A task can be a process, a thread, a VM, or kernel work such as handling network packets. The processor runs one task until it is interrupted, either voluntarily, for example when the task asks the operating system for something, or involuntarily, for example by a timer. Control then goes back to the kernel, the privileged part of the operating system, which runs in a special mode called ring 0 on x86. The kernel decides whether to continue the same task or switch to another.

The kernel is responsible for the defined processor state shared by all tasks, such as registers. These are called architectural buffers. The processor also has a lot of poorly documented shared state, called microarchitectural buffers, which the kernel should clear when switching tasks. If it does not, data from the previous task can leak to the next one, or the previous task can influence the next. Clearing some of these buffers is very slow, which makes task switches slow. Some of these buffers are shared between hyperthreads, so sometimes the only safe option is to avoid running one hyperthread while its sibling runs untrusted code.

Memory addressing

The processor uses two kinds of addresses. A virtual address is what software uses. A physical address is the actual location in the DRAM chips. The mapping between them is kept in data structures called page tables, and the processor converts one to the other by doing a translation. This lets the operating system give different processes different permissions and assemble memory that looks contiguous to a program even though it is scattered physically.

On x86 processors with what is called 4-level paging, the virtual address is split into pieces that index into four levels of tables. Here is the pseudocode from the write-up:

Text
virtual_addr = 0xFF_FF_00_11_22_33_44_55
pml4e_i = (virtual_addr >> 39) & 0b111_111_111
pdpte_i = (virtual_addr >> 30) & 0b111_111_111
pde_i = (virtual_addr >> 21) & 0b111_111_111
pte_i = (virtual_addr >> 12) & 0b111_111_111
pfn = pml4[pml4e_i]->pdpt[pdpte_i]->pd[pde_i]->pt[pte_i]->pfn
phys_addr = (pfn << 12) | (virtual_addr & 0b111_111_111_111)

Line by line:

  • virtual_addr = 0xFF_FF_00_11_22_33_44_55 is an example virtual address written in hexadecimal, a base-16 way of writing numbers.
  • pml4e_i = (virtual_addr >> 39) & 0b111_111_111 shifts the address right by 39 bits and keeps the lowest 9 bits. That gives the index into the top-level table, called PML4. The 0b prefix means the number is written in binary.
  • pdpte_i = (virtual_addr >> 30) & 0b111_111_111 does the same for the next level, PDPT.
  • pde_i = (virtual_addr >> 21) & 0b111_111_111 gives the index into the PD level.
  • pte_i = (virtual_addr >> 12) & 0b111_111_111 gives the index into the PT level.
  • pfn = pml4[pml4e_i]->pdpt[pdpte_i]->pd[pde_i]->pt[pte_i]->pfn follows the four tables in turn and reads the page frame number, the identifier of the physical page.
  • phys_addr = (pfn << 12) | (virtual_addr & 0b111_111_111_111) combines the page frame number with the lowest 12 bits of the virtual address, the offset within the page, to produce the physical address.
From the original on bughunters.google.com

Figure 3 shows this pseudocode and a table of how a virtual address maps to a physical address. The names of the levels are not important; what matters is that each level points to the next, and that each entry also carries flags such as present, writeable and cacheable. The present flag will matter later.

Virtualisation

Virtualisation lets one physical machine host several VMs, each with its own operating system. The outer operating system is the host OS, the inner ones are guest OSes, and the hypervisor manages them. The processor supports transitions between host and guest called VM Exit, when the guest stops and control returns to the host, and VM Enter, when the host hands execution to the guest.

The guest is allowed to define its own view of memory as if it were physical, while the host decides which real memory the guest gets. This is done with extended page tables, also called second level address translation or nested paging. The steps are:

  1. The host configures a mapping between host physical addresses and host virtual addresses.
  2. The host gives a VM a range of virtual address space.
  3. The host launches the guest, which sees that range as its physical memory, called guest physical memory.
  4. The guest configures a mapping between guest physical memory and guest virtual memory.

When the guest dereferences an address, the processor first translates the guest virtual address, or GVA, to a guest physical address, or GPA, and then translates that to a host physical address, or HPA. Here is the pseudocode:

Text
guest_page_table_base_gpa = read_guest_cr3()

gpa = walk_guest_page_tables(gva, guest_page_table_base_gpa)

host_ept_base_hpa = read_ept_pml4_register()

hpa = walk_host_ept(gpa, host_ept_base_hpa)

Code 1. Pseudocode of how second level address translation works.

Line by line:

  • guest_page_table_base_gpa = read_guest_cr3() reads the guest's cr3 register, which holds the address of the root of the guest's own page tables.
  • gpa = walk_guest_page_tables(gva, guest_page_table_base_gpa) walks those tables to turn the guest virtual address into a guest physical address.
  • host_ept_base_hpa = read_ept_pml4_register() reads the register that holds the root of the host's extended page tables.
  • hpa = walk_host_ept(gpa, host_ept_base_hpa) walks the host's tables to turn the guest physical address into a host physical address.

Virtualisation saves money through economies of scale and lets providers pack many customers onto one machine. But it also means the host shares processor resources with guests, and that lets a lower privilege level, such as a guest, infer things about data used by a higher one, such as the host or another guest.

The attack, step by step

L1TF lets an attacker's VM speculatively read any data sitting in the core-local L1 data cache, including data the VM should not be allowed to touch. L1TF Reloaded turns that into a way to read any byte in RAM. The attacker's VM does the following in sequence:

  1. Chooses the secret to leak: any byte in RAM.
  2. Makes a hypercall, a special request from a guest to the hypervisor, that tricks the host into a speculative out-of-bounds memory read, which puts the secret into the L1 cache.
  3. Triggers L1TF to get speculative access to the secret and speculatively encode it into the data cache.
  4. Decodes the secret from the data cache by measuring timings.

With that ability, the exploit leaks data from the host OS to find victim VMs on the same machine, learns which processes those victims run, and, from a victim Nginx web server, leaks its private TLS key. A TLS key is the secret that makes HTTPS encryption work; with it, an attacker can decrypt or impersonate that server's traffic.

Step 1: getting the secret into the cache (Half-Spectre)

L1TF can only leak data that is in the L1 cache. One way to get secret data there is to make the host or another VM read it normally, but the deployed mitigations target exactly that, so it does not work well. Instead, the exploit uses speculative execution: the processor fills cache entries from memory even while speculating, and those fills are not undone when the speculation turns out wrong.

A piece of host code that can be made to load secret data this way is called a half-Spectre gadget, also known as a cache load gadget, prefetch gadget or MDS gadget. Here is the example:

Text
if (idx < MAX) x = y[idx]

Code 2. Example of a Half-spectre gadget

Line by line:

  • if (idx < MAX) is a bounds check: only proceed if the index idx is below a maximum.
  • x = y[idx] reads the element at position idx from the array y and stores it in x.

The attacker controls idx. If the check is slow to evaluate, for example because idx is not cached, the processor guesses the check will pass and runs y[idx] early. That read pulls data from RAM into the L1 cache. When the guess turns out wrong, the result is discarded, but the cache fill stays. Since idx is a 64-bit integer, y[idx] can point anywhere in the host kernel's virtual address space.

On x86_64, the Linux kernel maps all physical memory in one contiguous region called the physmap or direct map. Physical address p sits at virtual address physmap_base + p. Most heap-allocated kernel objects live in the physmap, including the y array, so once the attacker knows the host physical address of y, varying idx brings any physical address into the L1 cache. VUSec found such a gadget in Linux's KVM subsystem, and it was shallow in the call stack, meaning it was easy to reach.

Step 2: L1 Terminal Fault

L1TF comes from a logic error in how Skylake and some other Intel processors behave after a terminal fault. A terminal fault is a kind of page fault, an error raised when code references invalid memory. The processor stops translating the address immediately, but it may still load the referenced data from the L1 cache.

From the original on bughunters.google.com

Figure 4 shows how the vulnerability ends up reading unexpected data.

The attacker creates a VM and maps a guest virtual address to a guest physical address, but marks that entry as not present or reserved in the guest's page tables. The attacker can do this because they fully control their own VM. When the processor accesses that address, a terminal fault occurs and translation stops before the extended page tables are walked to find the host physical address. The flaw is that the guest physical address is then passed to the L1 cache lookup as if it were a host physical address. So the processor reads whatever L1 data happens to have that host physical address, which the attacker chose. Speculative work after the fault is discarded, but cache effects are not undone.

Step 3: turning the read into a real observation

The attacker needs to turn the mistakenly fetched value into something observable. They do this with a dependent load, a memory access whose address depends on the secret. Here is the example, which runs entirely in the attacker's VM:

Text
char reload_buffer[64*256];
char *gva = GVA;
char secret = *gva;
reload_buffer[64*secret];

Line by line:

  • char reload_buffer[64*256]; declares an array of 16,384 bytes, arranged as 256 slots of 64 bytes each. A cache line is 64 bytes, so each slot is one cache line.
  • char *gva = GVA; sets a pointer to the guest virtual address the attacker prepared, the one marked not present.
  • char secret = *gva; reads from that address. This is the read that triggers the page fault, but speculatively it returns the secret byte.
  • reload_buffer[64*secret]; uses the secret as an index to touch one of the 256 cache lines. This line is never reached for real because of the fault, but it runs speculatively and leaves the chosen cache line in the cache.

Only the first two lines execute architecturally. The last line runs speculatively and caches the secret-th cache line of reload_buffer. Then the fault happens and control goes to the guest's page fault handler. There, the attacker measures how long it takes to read each of the 256 cache lines. If 255 of them take 200 or more cycles and only entry 99 takes 4 cycles, the attacker concludes that secret was 99. This technique is called Flush+Reload, and it is how a speculative access becomes real knowledge through timing.

Step 4: finding the addresses

The exploit needs host virtual addresses, namely the gadget's base y and where the secret lives, and it needs the host physical address of the secret. Most of its time goes into leaking this addressing information.

The first phase finds y in host physical memory by brute force. The attacker triggers the gadget with idx set to zero, which pulls y[0] into the L1 cache, then tries candidate host physical addresses until one gives a measurable Flush+Reload signal. False positives are filtered out using prior knowledge of what data at y[0] should look like, and by the failure of later steps.

The second phase breaks the host kernel's KASLR, the randomisation of where the kernel is placed in memory, by leaking the physmap base. That also gives y's host virtual address. In the VUSec exploit, y was an array of struct kvm_lapic structures, which represent LAPICs, the local advanced programmable interrupt controllers. The exploit leaks the pointer y[0] to the first LAPIC structure and brute-forces its host physical address as before. With both the physmap virtual address and the physical address known, subtracting one from the other gives the physmap base.

From the original on bughunters.google.com

Figure 5 shows how the attacker chases pointers found in structures to find the page tables of other tasks on the host.

The exploit then chases physmap pointers. Given a physmap pointer, subtracting the physmap base gives its host physical address, which gives the idx needed to load the pointed-to data into L1 and leak it with L1TF. Following a chain of heap-allocated objects leads to the host's root page table, and walking the host's page tables translates any host virtual address to a host physical address. Concretely, struct kvm_lapic contains a pointer to a struct kvm_vcpu, which represents the virtual CPU the LAPIC belongs to. That contains a pointer to a struct pid, which represents the process ID of the vCPU task and sits in a linked list of all tasks using that PID. Walking that list finds the task_struct for the vCPU task, the kernel's record of a running task. The task_struct points to the task's mm_struct, which tracks the task's address space and contains a pointer to the top-level page table for the vCPU task. Leaking page table entries level by level lets the exploit translate any host virtual address, moving from chasing physmap pointers to chasing arbitrary host kernel pointers.

The leak is not perfect. Half-Spectre, L1TF and Flush+Reload can each produce errors, for example leaking a 0x79 byte as 0x00, and one error breaks a pointer chain. So VUSec uses chasing-and-checking: after a number of chased pointers, the exploit re-leaks a pointer it already knows and checks it has not gone off track.

Step 5: finding data worth leaking

Dumping all of RAM would be slow and the contents change over time, so the attacker uses host metadata to find interesting data. All task_structs are in a global linked list. Starting from its own CPU's task_struct, the attacker finds the task for a victim VM's vCPU. That task's file descriptor table, the list of open files and handles, contains a descriptor for KVM's vCPU object, which points to the task's kvm_vcpu. From there the attacker leaks the root of the victim VM's extended page tables, found in kvm_vcpu_arch -> kvm_mmu -> kvm_mmu_root_info, and the guest's cr3 register value, found in kvm_vcpu_arch, which holds the physical address of the root of the guest's own page tables. With both, the exploit performs a two-dimensional page table walk to translate any guest virtual address to a host physical address it can read with L1TF.

The attacker still does not know where the interesting data is, so it first breaks KASLR in the guest using the guest's page tables to find the kernel text and the kernel's direct map. It then follows pointers from the guest kernel's init_task, a global variable at a known offset from the start of the guest kernel, walking the task list. In the demonstrated exploit the target was an Nginx web server process in the guest. The exploit went through that process's mm_struct, found its root page table and the virtual address of the start of its heap, and translated the heap address to its physical counterpart. Nginx stores its private key at a static location on the heap surrounded by magic numbers, which makes it easy to spot, and L1TF with chase-and-check leaks the key successfully.

Or watch on YouTube
From the original on bughunters.google.com

A video demo of the exploit is included at the end of the blog.

Why it works

The root cause is the mismatch between guest physical addresses and host physical addresses. When a terminal fault stops translation before the extended page tables are walked, the processor passes the guest physical address to the L1 cache lookup as if it were a host physical address. The attacker chooses which host cache line is read by choosing the faulting guest physical address. The cache fill is not undone when speculation is wrong, and the half-Spectre gadget in KVM lets the attacker put any RAM contents into L1 in the first place. The existing defences did not stop it because the deployed L1TF mitigations target normal, architectural loads of secret data rather than speculative ones, and because hunting gadgets is reactive: new ones, including kvm_sched_yield and __pv_send_ipi, appeared over time.

What it means

An attacker who controls a VM on a shared machine can read arbitrary RAM, find victim VMs on the same machine, learn which processes they run, and, as demonstrated, steal a victim Nginx server's private TLS key, breaking its HTTPS security. The write-up presents this as proof that processor exploits are real and that the barrier to building one that crosses between VMs is getting easier to cross. The attack needs affected hardware, Skylake and some other Intel CPUs, and the ability to run a VM on the same machine as the victim.

The fixes

Google deployed several mitigations when L1TF was first discovered in 2018. As explained in 2018, Google made sure an individual core is never shared between distinct virtual machines at the same time, and when VMs ran one after another the L1 data cache was completely flushed. Intel's official documentation expected hypervisors to flush the cache before every VM Enter and to disable the sibling hyperthread unless both virtual CPUs were running guest code, with core stunning on every VM Exit. Core stunning means pausing the sibling hyperthread. The write-up notes this would be very expensive.

From the original on bughunters.google.com

Figure 6 explains Intel's core scheduling, which prevents sharing a physical core between two virtual machines.

From the original on bughunters.google.com

Figure 7 shows Intel's relative performance of different workloads with a sibling hyperthread enabled or disabled.

For cache load gadgets, Google fixed them internally and sent the fixes upstream to Linux in 2020, mostly using the array_index_nospec helper. A call to array_index_nospec(index, size) returns an index bounded to [0, size) even under speculation, by building a bit mask that is all zeros or all ones depending on whether the bound holds. This was applied selectively, where users could control an offset, because doing it everywhere has a significant performance cost. The gadgets used by the VUSec exploit were kvm_sched_yield, triggered by the KVM_HC_SCHED_YIELD hypercall, and __pv_send_ipi, triggered by the KVM_HC_SEND_IPI hypercall. Both were fixed in the commit "KVM: x86: use array_index_nospec with indices that come from guest".

From the original on bughunters.google.com

Figure 8 compares page tables with and without Address Space Isolation.

Address Space Isolation, or ASI, is Google's long-term proactive answer. The idea is that speculative execution stops when it hits a page translation fault, so speculation in kernel context cannot leak data that is not mapped into the kernel's address space. ASI separates sensitive memory, which may contain secrets and includes all userspace and guest data, from nonsensitive memory. On a VM Exit no sensitive data is present in the kernel's address space. When the kernel needs it, a page fault triggers an ASI Exit, which switches to the full address space and clears shared processor buffers such as the branch predictor buffers. Preparing a VM Enter triggers an ASI Enter, which returns to the restricted address space and flushes processor data buffers such as the L1 data cache. Performance testing with ASI and the L1 data cache flush on ASI Entry showed an impact of less than 3% across almost all benchmarks, with less than 1% common.

ASI alone is not enough because buffers are shared between hyperthreads. The sequence is: hyperthread 1 runs guest code; hyperthread 2 does an ASI exit and triggers a half-Spectre gadget; hyperthread 1, still as guest, reads L1 data; hyperthread 2 does an ASI enter and clears L1. Google searched for half-Spectre gadgets a guest could trigger during an ASI exit and found none, but for future-proofing the sibling hyperthread must be stunned whenever an ASI exit happens. That stunning-during-ASI-exit functionality is integrated into Google's internal kernel fork and is intended to be released externally in a later patch series once testing and qualification are finalised. Google has also been working on ASI with the Linux kernel community.

Things worth testing next

  • Other hypercalls and VM Exit paths. Look for bounds-checked array accesses where a guest controls the index, in the style of kvm_sched_yield and __pv_send_ipi. A positive result is a path reachable from a guest hypercall that speculatively loads attacker-chosen memory into L1.
  • Other physmap-resident structures. Any heap object reachable from a leaked pointer can start a pointer chase. A positive result is a chain from a known structure to a page table or other sensitive object that survives chase-and-check.
  • Other guest kernels and workloads. The Nginx TLS key was one example; the same two-dimensional page table walk applies to any guest process whose data location can be derived from kernel structures. A positive result is a successful translation of a guest virtual address to a host physical address and a correct leak of known data.
  • Sibling hyperthread scheduling. Test whether an attacker can arrange the hyperthread conditions needed to read L1 data between an ASI exit and the following ASI enter. A positive result is a measurable leak across that window despite the flush on ASI Entry.
  • Gadget regressions over time. Re-audit code paths that take guest-controlled offsets after kernel changes, since new gadgets appeared after the 2020 fixes. A positive result is a newly reachable half-Spectre gadget in a VM Exit path.

Glossary

  • Address Space Isolation (ASI): a technique that keeps sensitive memory out of the kernel's address space during speculative execution, so speculation cannot leak it.
  • Architectural execution: when an instruction's effect becomes real and permanent, after all its micro-operations finish.
  • ASI Enter / ASI Exit: transitions between the restricted address space and the full address space in ASI.
  • Branch: a decision point in code, such as a loop or an if condition.
  • Branch Target Buffer / Branch History Table: small processor buffers that store history used to predict branches.
  • Cache: a small, fast memory close to the processor that holds copies of recently used data.
  • Cache line: the fixed-size block, 64 bytes here, that a cache stores and moves as a unit.
  • Chasing-and-checking: re-leaking a known pointer after a chain of leaks to confirm the chain is still correct.
  • Core: one processing unit inside a processor.
  • Core stunning: pausing a hyperthread, for example the sibling of the one running untrusted code.
  • cr3: a processor register holding the address of the root of the current page tables.
  • Direct map / physmap: the region of kernel virtual memory where all physical memory is mapped contiguously.
  • DRAM: the main memory chips of a computer, slower than caches.
  • EPT (extended page tables): the second level of page tables used to translate guest physical addresses to host physical addresses.
  • Flush+Reload: a timing technique that detects which cache line was touched by measuring access times.
  • Gadget: a short piece of existing code that can be abused to do something it was not meant to do.
  • Guest / host: the virtual machine and the real machine (and its operating system) underneath it.
  • Guest physical address (GPA) / host physical address (HPA): the address as the guest sees it, and the real address in the host's memory.
  • Guest virtual address (GVA): an address used by software inside the guest.
  • Half-Spectre gadget: code that can be made to speculatively load attacker-chosen memory into the cache.
  • Heap: the region of memory used for dynamically allocated objects.
  • Hypercall: a request from a guest to the hypervisor, similar to a system call.
  • Hyperthreading (SMT): presenting one physical core as two logical processors that share resources.
  • Hypervisor: the software that creates and runs virtual machines.
  • KASLR: randomisation of where the kernel is placed in memory, meant to make attacks harder.
  • KVM: the virtualisation component of the Linux kernel.
  • L1 cache: the smallest and fastest cache, local to a core.
  • L1TF (L1 Terminal Fault): the processor weakness that lets a terminal fault read data from the L1 cache using a guest physical address as if it were a host physical address.
  • Last-Level Cache (LLC): the largest and slowest of the caches.
  • Micro-operation: a small step that a processor instruction is broken into.
  • Microarchitecture: the internal hardware design details of a processor, beyond what its manuals define.
  • Microarchitectural buffer: undocumented shared processor state that the operating system should clear between tasks.
  • mm_struct: the kernel structure that tracks a task's address space.
  • Page fault: an error raised when code accesses memory that is not validly mapped.
  • Page table: a data structure that maps virtual addresses to physical addresses.
  • Page table walk: following page tables level by level to translate an address.
  • Physical address: the real location of data in memory.
  • Register: a tiny storage slot inside the processor.
  • Ring 0: the privileged mode in which the kernel runs on x86.
  • Sole-tenant node: a physical machine dedicated to one customer, with no other tenants.
  • Speculative execution: running instructions ahead of their turn and discarding the results if they turn out not to be needed.
  • SRAM: fast, expensive memory used for caches.
  • task_struct: the kernel structure that records everything about a running task.
  • Terminal fault: a page fault that stops address translation immediately.
  • TLS key: the secret that makes HTTPS encryption work for a server.
  • Translation: converting a virtual address to a physical address.
  • Virtual address: the address software uses, which the processor translates to a physical one.
  • Virtual machine (VM): a pretend computer created by software on a real one.
  • VM Enter / VM Exit: transitions between the host and a guest.
  • Vulnerability Rewards Program (VRP): a program that pays researchers for reporting security problems.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.