An EPYC escape: Case-study of a KVM breakout
A race condition in KVM's AMD nested-virtualisation code let a malicious guest bypass a VMCB validation check, causing KVM to overwrite its saved L1 host state with L2 guest data. This gave the guest unrestricted access to host MSRs, which the author then developed into a full guest-to-host escape.
googleprojectzero.blogspot.com
Published on googleprojectzero.blogspot.com
KVM (for Kernel-based Virtual Machine) is the de-facto standard hypervisor for Linux-based cloud environments. Outside of Azure, almost all large-scale cloud and hosting providers are running on top of KVM, turning it into one of the fundamental security boundaries in the cloud.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a time-of-check-to-time-of-use flaw: the guest-supplied VMCB was validated in guest memory and then copied again later, so a second CPU core could change it in between.
Impact
A malicious guest could gain unrestricted access to host MSRs, which the author turned into a full guest-to-host escape; the bug only became exploitable in v5.10 and most real deployments should not be affected.
What the attacker needed
Control of a KVM guest; nested virtualisation enabled; AMD host CPU; multiple vCPU cores
How it was found
- Enable nested virtualisation by setting the SVME bit in the EFER register.
- On one core repeatedly try to launch a nested guest while a second core flips the VMRUN intercept bit.
- If the launch succeeds, try launching a further nested guest; if that fails the race was lost and must be retried.
- Clear the SVME bit while still in the innermost guest, freeing the MSR permission bitmap pages.
- Wait for the host to reuse those pages so the permission bits are cleared, granting access to host MSRs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A hypervisor is the software that runs virtual machines and keeps them apart from each other and from the real machine. This bug let a program inside one virtual machine trick the hypervisor into losing track of which machine it was running, so it could reach settings that belong to the real host. From there the researcher worked towards running their own code on the host, which breaks the main security wall in cloud computing.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.