NitroPDF Stream Length Memory Corruption Vulnerability
A use-after-free vulnerability exists in NitroPDF's parsing of the /Length attribute when it is a reference object instead of an integer. An attacker could craft a malicious PDF to trigger memory corruption and potentially achieve arbitrary code execution.
Originally disclosed on Cisco Talos
An exploitable use-after-free vulnerability exists in the Length parsing function of NitroPDF. A specially crafted PDF can cause a type confusion, resulting in a use-after-free condition.
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 parser frees a reference object when it fails to treat it as an integer but does not remove the stale pointer from the document dictionary, leading to a use-after-free.
Impact
This could lead to further memory corruption and ultimately arbitrary code execution, though the CVSS vector indicates high attack complexity and user interaction is required.
What the attacker needed
Victim opens a malicious PDF; attacker crafts a PDF with a reference /Length
The fix
The vendor advised that the issues will be addressed in a future release, but no specific fix details were provided.
How it was found
- Create a PDF with an object whose /Length attribute is a reference to another object instead of an integer.
- Open the PDF in NitroPDF, causing the parser to free the reference object but leave a stale pointer.
- Trigger reuse of the stale pointer, resulting in a use-after-free and memory corruption.
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.
When a PDF file is opened, the program reads a value called /Length that tells it how long a stream of data is. If that value is given as a reference to another object instead of a plain number, the program frees the object but keeps a pointer to it. Later, when it tries to use that pointer, the memory has already been freed, which can 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.