(CVE-2022-0216) QEMU LSI SCSI Use After Free
A use-after-free exists in QEMU's LSI SCSI emulation: sending an ABORT TAG message cancels the current request and frees it, but a stale pointer is kept. Sending the abort message again then dereferences the freed request, which can crash the emulator or cause undefined behaviour.
starlabs.sg
Published on starlabs.sg
The vulnerability resides in the hw/scsi/lsi53c895a.c specifically in lsidomsgout function. lsidomsgout function is used to receive messages from the OS, and do something based on that message. In this case, one message only has one-byte size.
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 abort-tag path frees the current request via scsi_req_cancel but leaves the local current_req pointer dangling, so a second abort message dereferences freed memory.
Impact
A guest can trigger a use-after-free in the emulator, which can lead to undefined behaviour or a crash of the QEMU process.
What the attacker needed
Control over a guest OS inside QEMU; emulated LSI SCSI controller
How it was found
- Send a SCSI command so that a current request exists.
- Send an ABORT TAG message (0x0d) to cancel it, freeing the request.
- Send the abort message again so the stale pointer is used.
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 pretends to be a whole computer, including a disk controller. That controller keeps a note of the request it is currently handling. When the guest asks to cancel the request, the note is thrown away but a second note still points at it, so asking to cancel again reads memory that no longer belongs to the program. Reading freed memory like this is called a use-after-free and often makes the program crash.
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.