GHSL-2022-038: Use After Free (UAF) in Qualcomm NPU driver - CVE-2022-22068
A use-after-free in the Qualcomm NPU driver occurs when a stats buffer is freed after being referenced in an event queue, allowing an attacker to leak kernel data to an untrusted app.
When appmsgproc receives a NPUIPCMSGEXECUTEV2DONE message, initializes a npukevent and sets its reserved[0] field to the address of the statsbuf [1] and places the event in the event queue of network->client:
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The driver frees the stats_buf while an event referencing it remains in the queue, leading to a dangling pointer that is later used.
What the attacker needed
Access to NPU driver ioctls
How it was found
- Trigger an NPU_IPC_MSG_EXECUTE_V2_DONE message to queue an event referencing stats_buf.
- Call npu_unload_network_v2 ioctl to free the network and its stats_buf.
- Call npu_receive_event ioctl to process the queued event and copy freed memory to user space.
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 report has not been written yet. The Original tab links to the source.
A use-after-free happens when a program frees memory but keeps a pointer to it, and later reads or writes through that pointer. Here, the driver frees a buffer but an event still points to it, so when the event is processed, the freed memory is copied back to the user, leaking kernel data.
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.