ZDI-24-821: A Remote UAF in The Kernel's net/tipc
A missing check in the TIPC fragment reassembly error path in the Linux kernel frees the last fragment buffer and then frees the head buffer whose fragment list still references it, causing a use-after-free. A local or remote attacker who can reach the TIPC stack could trigger the bug, potentially leading to memory corruption.
sam4k.com
Published on sam4k.com
While preparing for my talk at TyphoonCon, about how to find bugs in the Linux kernel, I discovered a neat little vulnerability in the kernel’s TIPC networking stack.
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
The error cleanup in tipc_buf_append() frees the current fragment buffer and then frees the head buffer, whose frag_list still references that already-freed fragment, without checking whether the fragment was already chained.
Impact
A local or remote attacker could trigger a use-after-free in the kernel, which may lead to memory corruption; only systems with TIPC built and loaded, and reachable by the attacker, are affected.
What the attacker needed
TIPC module built and loaded; TIPC reachable on an interface (for remote); Established TIPC link; Ability to send crafted fragments
How it was found
- Establish a TIPC link with the target node by sending the handshake messages.
- Send a first fragment message so the head buffer is created.
- Send further fragments so they are added to the head buffer's fragment list.
- Send a last fragment whose inner message header is malformed so validation fails.
- The error path frees the last fragment and then the head buffer, triggering the use-after-free.
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.
When a message is too big for one network packet, it is split into pieces called fragments and put back together on arrival. The code that puts them back together had a mistake in its error handling: it threw away the last piece, then threw away the whole pile, which still pointed at that already-thrown-away piece. Using something after it has been thrown away is called a use-after-free and can crash the machine or let an attacker control memory.
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.