QEMUtiny - QEMU escape vulnerability if cxl is used
QEMU's CXL Type-3 device emulation contains an out-of-bounds read in the GET_LOG mailbox command and an out-of-bounds write in the SET_FEATURE command. A guest can chain these to leak QEMU memory addresses and corrupt heap state, ultimately calling a controlled function pointer to escape the virtual machine.
github.com
Published on github.com
v12-security / pocs Public
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 the GET_LOG handler treats a byte offset as an array index, and the SET_FEATURE handler fails to check that the provided offset plus copy length stays within the target structure.
Impact
A guest can escape the virtual machine and execute code on the host, though the provided exploit depends on specific build offsets and the maintainers note CXL is not intended for virtualisation use cases.
What the attacker needed
Root inside the guest; CXL Type-3 device emulated; specific QEMU build offsets
The fix
The SET_FEATURE handler should bound the copy to the size of the selected write-attribute structure, as the patrol scrub path already does.
How it was found
- The guest enables PCI memory decoding for the CXL device and maps BAR2.
- The guest sends a GET_LOG command with an offset that lands just past the CEL buffer, reading adjacent QEMU state.
- The leaked data includes a command handler pointer and the CXLType3Dev heap address, giving the QEMU PIE base.
- The guest sends a SET_FEATURE / RANK_SPARING command with a non-zero offset and large payload, overflowing into later CXLType3Dev fields.
- The overflow plants fake memory dispatch structures so that a later sanitize operation calls a controlled write callback.
- The callback is first used to call memmove and leak libc, then repointed to system to run a shell.
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.
QEMU is software that runs a virtual computer (a guest) inside a real one. A bug in QEMU's emulation of a CXL device lets code inside the guest read and write memory outside the intended buffer, which can lead to running commands on the host. This is called a virtual machine escape.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.