CVE-2026-99312:KVM 客户机逃逸到宿主机
CVE-2026-99312: KVM Guest-to-Host Escape

原始链接: https://www.terra.security/blog/kvm-guest-to-host-escape

在启用嵌套虚拟化的 AMD CPU 上,KVM 的一个 bug 让虚拟机突破内存边界并访问宿主机内存。这是一个释放后使用漏洞:在 INIT 重置过程中,KVM 未能刷新虚拟机控制块中的页表指针,使其仍指向已释放的页面。攻击者可触发重新分配并操纵页表,在 DigitalOcean droplet 上读取约 127 GB 宿主机 RAM,并在受控裸机服务器上向宿主机内核内存写入任意字节,可能最终执行宿主机代码。该缺陷由 2022 年针对 CVE-2022-3344 的修复引入,该修复切换了控制块但未切换指针。它于 2026-10-21 报告,在主线中修复,并发布于稳定版和 LTS 内核。未在 AMD 上启用嵌套虚拟化的云平台不受影响;否则请更新内核或禁用 kvm_amd nested=0。

Hacker News 链接到一份关于 CVE-2026-99312 的报告,这是一个 KVM 客户机到主机的逃逸漏洞。评论者争论是否应该禁用嵌套 KVM:一人认为嵌套 KVM 仍然有用且安全,另一人则建议避免使用,并提到最近有多起嵌套 KVM 逃逸漏洞。其他人讨论 AI 对安全的影响,质疑 AI 辅助漏洞发现是否优于 AI 生成的漏洞,以及基础设施安全到 2027 年是否会改善。其他评论提到用于代理沙箱的单内核、对无休止 CVE 修补的沮丧,以及开玩笑说关掉互联网。还有人批评链接文章是 AI 写的。
相关文章

原文

Rent a server in the cloud and one thing comes with the bill: you are alone in there. Your VM is yours, your neighbors' VMs are theirs, and the hypervisor keeps it that way. We broke that boundary on an ordinary DigitalOcean droplet, and reached the physical host and every other tenant's VM on it.

What came back first was the host's own kernel version banner, a string that exists nowhere inside a guest. Then the rest of the machine: about 127 GB of host RAM, ours to read, and write and on a shared host that memory belongs to whoever else is running VMs there.

On DigitalOcean we demonstrated the read. The write we showed on a bare-metal AMD server of our own, where our VM dropped 32 chosen bytes into a live host kernel page. Arbitrary write to host memory is the basic ingredient for code execution.

All it took was what every cloud customer already has: a VM and root inside it.

The bug is in KVM, the hypervisor built into the Linux kernel, on AMD CPUs with nested virtualization enabled. It sat in the kernel for just under four years, and it was opened by a security fix.

So how does a VM reach memory it was never given?

How KVM Confines a VM to Its Own Memory

Three players matter here. Our VM is the droplet we rented. KVM is the hypervisor inside the host's Linux kernel. The processor is the physical AMD chip that runs our VM's code. A VM also has its own page table, but this story follows only KVM's nested page table: it turns a physical address as seen by our VM into an address in the host's real memory. KVM builds that table in host kernel memory, out of our VM's reach. The processor reads it when a translation is needed and not already cached.

The pointer in our VM's control block names the starting page of KVM's table. It is the physical address our VM wants to use, not that pointer, that the processor breaks into pieces. For an ordinary memory page, four groups of nine bits select one entry apiece at the top, second, third, and bottom levels. Each selected entry gives the host address of the next table page; the bottom entry gives the host memory page, and the remaining twelve bits select a position inside it. KVM builds the table, but the processor makes these selections. It treats whichever page the pointer names as the top level.

The bug: one code path in KVM forgot to update that pointer. After the bug fires, the pointer still names a page that no longer holds the page table, because KVM freed it. The processor keeps following the pointer anyway, so whatever the kernel reallocates that page for becomes the top of our VM's memory map. This is a use-after-free.

The next figures zoom in on the levels that go wrong. In Step 2, a large-page entry stops the lookup before the bottom level.

The Bug: A Reset Leaves a Pointer to a Freed Page

Some clouds let a VM run a VM of its own, a nested VM. The feature is called nested virtualization. KVM then keeps two control blocks, one for our VM and one for the nested VM, each with its own page table pointer. We write the nested VM ourselves, and we run it with paging turned off, which is why KVM cannot hand it our page table and builds it a second one. Every time the nested VM exits back to our VM the normal way, KVM updates our VM's pointer so that it names our VM's live page table before our VM runs again.

There is another way out: a reset signal called INIT. When INIT pulls a virtual CPU out of the nested VM, KVM skips the normal exit path and leaves our VM's pointer holding the address it held before. KVM has a second safety net that would catch this, a full rebuild of the memory map while it handles the reset. It runs that rebuild only when paging was on beforehand, and the setting it reads is the nested VMs, which we turned off. So neither path refreshes the pointer.

That is the bug: one exit path forgot to update the pointer. We turn it into a use-after-free. While the nested VM runs, we change our VM's memory map, which makes KVM throw away our VM's page table and free the page at its top. Then a second virtual CPU of our VM sends INIT. KVM does not update the pointer, so it resumes our VM with a pointer that names a freed page. What follows is how we exploit it.

Step 1: KVM Reallocates the Freed Page as a Bottom-Level Table

We touch memory in our VM that KVM has not mapped yet. KVM has to allocate a page-table page for it, and the page it just freed is a good candidate to come back: the same CPU freed it, so it sits near the top of that CPU's free list. KVM reallocates it as a fresh bottom-level table for our VM and fills it with the host addresses of our VM's pages. That page is a live page table again, built and owned by the kernel.

It is the wrong level. The stale pointer still names it, so the processor reads a bottom-level table as the top level. It takes an entry there and follows it, expecting the second level. The entries are perfectly correct bottom-level entries, each one the host address of a page of our VM, so the processor lands in ordinary memory of ours.

So we never touch KVM's table. The page we end up controlling is the one below it: our own data page, which the processor now reads as the second level of the page table, with entries we are free to write.

This step is a race and can fail. On a cloud host you get one real attempt per boot. On the large droplet where we ran the full chain, it worked on 6 of 12 boots. That is a coin flip per boot, which is practical for any motivated attacker.

Step 2: Let the Processor Reveal Our Pages' Host Addresses

Step 1 made the processor read a page of our VM as the second level of KVM's table. We control its contents, but to build a complete table of our own we need the host addresses of our pages. Our VM does not know them.

Here is the hardware detail that gets us there: when the processor reads a table entry, it sets its Accessed bit. We put a valid entry with that bit clear at the start of many pages in our VM, and we set its large-page flag so the processor stops at that entry instead of walking further. On the page it reads as the second level, the processor turns the Accessed bit on. We check which of our pages came back with that bit set. That tells us which page to edit, though it does not yet reveal the page's host address.

Now we edit that page. We put a guessed host address into a different entry of Page A, one the processor reads to find a third-level page. If the guess reaches another marked page of ours, the processor reads that page as the third level and sets the Accessed bit there too. That tells us the guessed address is where that page really sits in host memory. No change means we try another guess.

Guessing works because we stack the deck first. We plant that marked entry in 262,144 of our own pages, a gigabyte of guest RAM, so a healthy share of the host addresses we try turn out to be ours. On our bare-metal server a few hundred guesses gave us the host addresses of two of our pages, each guess costing microseconds.

Step 3: Forge a Page Table for All Host Memory

We now know the real host addresses of two of our pages. That is enough to build a complete page table of our own.

One page holds the table structure. The entries in it point wherever we like in host physical memory. The other page proves the oracle worked: it appears at the address we predicted.

From that moment on, our VM's code runs through a page table we wrote, and every memory access lands where we say.

On DigitalOcean we pointed our table at about 127 GB of host RAM, mapped read-only. The hypervisor's kernel version banner came back, a string no droplet should ever see.

To demonstrate the write without risking anyone else's infrastructure, we used a bare-metal AMD server we control. Our VM put chosen bytes into a host kernel page. A witness module in the host kernel owned that page and reported that something other than itself had changed it.

The impact: a read reaches every tenant's memory on the host. A write is worse. Arbitrary write to host kernel memory is how you get code execution on the host itself.

A Security Fix Opened the Bug

In 2022, KVM had a different bug: when a reset pulled a virtual CPU out of a nested VM, it kept running on the nested VM's control block, which then got freed. The fix for that bug, CVE-2022-3344, switched it back to the control block of the VM that runs the nested one before anything was freed.

That fixed the control block. It did not fix the page-table pointer inside it. The switch happened, but nobody refreshed the pointer, so our VM's control block went back into service, still naming the page our memory-map change had already freed. That 2022 fix has now needed at least two follow-on fixes, and one of them is this escape.

In PatchSlop we found that 3.2% of kernel CVEs were introduced by the fix for another CVE. This bug was introduced the same way.

Disclosure Timeline‍

  • 2026-10-21. Reported to the Linux KVM maintainers. 
  • ‍2026-11-02. Fix merged to mainline, and first tagged in v7.4-rc2 on 2026-11-09. ‍
  • 2026-11-17. Released in stable 7.3.5 and in the 6.18.64 and 6.12.118 long-term kernels.

Mitigation

Many cloud providers we surveyed are out of reach for one reason: they did not enable nested virtualization on AMD.

  1. Running KVM hosts on AMD? Update to a kernel that carries the fix.
  1. Cannot update yet? Set the nested parameter of the kvm_amd module to 0. That turns nested virtualization off and closes this path completely.

Visit Terra Security to learn more.

联系我们 contact @ memedata.com