MuPDF Fitz library font glyph scaling Code Execution Vulnerability
A heap out-of-bounds write exists in MuPDF's glyph scaling code when a font glyph is scaled down, due to incorrect pointer arithmetic. An attacker could craft a PDF that triggers this write, potentially corrupting heap metadata and sensitive memory, leading to code execution.
Originally disclosed on Cisco Talos
An exploitable heap out of bounds write vulnerability exists in the Fitz graphical library part of the MuPDF renderer. A specially crafted PDF file can cause a out of bounds write resulting in heap metadata and sensitive process memory corruption leading to potential code execution.
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
Likely, the destination pointer is incremented by nf inside a loop but decremented by 2*nf outside, so when the outer loop runs more than once the pointer moves before the buffer start.
Impact
The out-of-bounds write could corrupt heap metadata and sensitive process memory, potentially leading to code execution.
What the attacker needed
Victim opens a crafted PDF
How it was found
- Create a PDF with a font glyph that must be scaled down.
- Open the PDF in a vulnerable MuPDF reader.
- The glyph scaling code writes out of bounds, corrupting heap metadata.
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.
MuPDF is a program that reads PDF files. A bug in how it shrinks certain text characters can make it write data past the end of a memory buffer. If you open a malicious PDF, this could crash the program or let an attacker 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.