The Printer Goes Brrrrr, Again!
A heap-based buffer overflow in the NetBIOS name parsing function of a Canon printer's firmware allowed an attacker to write controlled data to arbitrary memory addresses and ultimately execute shellcode. The vulnerability was exploited at Pwn2Own to achieve code execution on the printer.
Published on synacktiv.com
Written by Rémi Jullian, Mehdi Talbi, Thomas Jeunet - 12/05/2023 - in Exploit - Download
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 parser increments the destination pointer without decrementing the remaining length when a label has zero length, allowing the pointer to advance beyond the buffer and a subsequent copy to overflow the heap.
Impact
An attacker could execute arbitrary code on the printer, as demonstrated by displaying a ninja on the screen.
What the attacker needed
Network access to the printer; printer running vulnerable firmware
The fix
The vulnerability was fixed in firmware version 12.03 by decrementing the remaining length when a label length of zero is encountered, preventing the pointer from advancing without reducing the available space.
How it was found
- Use the heap overflow to prepare a write-what-where primitive for the lower two bytes of a function pointer.
- Trigger the write by sending a Positive Name Query Response.
- Use the heap overflow again to prepare the primitive for the upper two bytes of the function pointer.
- Trigger the write by sending another Positive Name Query Response.
- Send a BJNP SessionStart message to store shellcode at a fixed address.
- Send a PJCC ECHO message to execute the shellcode via the overwritten function pointer.
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.
The printer's software had a bug in how it read a network name: it could be tricked into writing more data than the space reserved for it, overflowing into adjacent memory. An attacker on the same network could send specially crafted network packets to take control of the printer and run their own code.
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.