# KVM Guest-to-Host Escape

KVM on AMD nested virtualization left a stale nested page-table pointer after INIT reset, giving a guest use-after-free and full host memory read/write.

- Payout: Research
- Severity: critical
- Program: Linux KVM
- Write-up by: Oren Yomtov
- Disclosed: 2026-11-18
- CVE: CVE-2026-99312
- Write-up quality: 9/10
- Original: https://www.terra.security/blog/kvm-guest-to-host-escape
- Library page: https://bugbountylibrary.com/r/blog%3Aterra-security-blog-kvm-guest-to-host-escape
- Tags: area:cloud domain:infra impact:data-leak impact:privesc kind:research platform:research sev:critical tech:linux technique:incomplete-fix technique:race-window technique:source-review vuln:memory-corruption vuln:privilege-escalation vuln:race-condition

**Target:** KVM hypervisor nested page table (AMD SVM, nested virtualization)
**Root cause:** The INIT reset exit path from a nested VM skips the normal pointer refresh, and the full rebuild only runs when nested paging was on, so the VM control block keeps a pointer to a page table page that a memory-map change already freed.
**Steps:**
1. Run a nested VM with paging off so KVM builds it a second page table.
2. While nested VM runs, change the VM's memory map so KVM frees the page at the top of the VM's page table.
3. Have a second vCPU send INIT; KVM resumes the VM with the stale pointer to the freed page.
4. Touch unmapped memory so KVM reallocates the freed page as a bottom-level table; processor reads it as top level and lands in a guest data page now treated as second level.
5. Plant Accessed-bit-clear large-page entries in 262,144 guest pages; observe which page's Accessed bit flips to identify the controlled second-level page.
6. Guess host addresses in a third-level entry; a guess hitting another marked page sets its Accessed bit, confirming the page's host address.
7. Build a forged page table from two known host addresses and map host RAM read-only; demonstrate write on own bare-metal host.
**How found:** Traced the INIT reset exit path and noticed it skips the pointer refresh; the second safety net (full rebuild) only triggers when nested paging was on, which the attacker disables. Recognized the 2022 CVE-2022-3344 fix switched the control block but never refreshed the page-table pointer inside it.
**Exploitation:** Guest root rents a cloud VM, races the INIT reset against a memory-map change to free the page table page, reclaims it as a bottom-level table, uses the Accessed-bit oracle to learn host addresses of guest pages, forges a page table mapping ~127GB host RAM read-only on DigitalOcean, and demonstrates arbitrary host kernel write on own bare-metal AMD server.
**Escalation:** Read of all host RAM reaches every tenant's memory; arbitrary write to host kernel memory yields host code execution.
**Insight:** When auditing hypervisor reset/exit paths, check that every path refreshing the control block also refreshes the nested page-table pointer; a fix that swaps the control block can leave a stale pointer to a freed page table, and disabling nested paging bypasses the rebuild safety net.

