NitroPDF jpeg2000 yTsiz Remote Code Execution Vulnerability
A crafted JPEG2000 image embedded in a PDF causes an integer overflow when calculating memory size, leading to a heap buffer overflow. An attacker could exploit this to execute arbitrary code when the victim opens the malicious PDF.
Originally disclosed on Cisco Talos
A specifically crafted jpeg2000 file embedded in a PDF file can lead to a heap corruption when opening a PDF document in NitroPDF 12.12.1.522. With careful memory manipulation, this can lead to arbitrary 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 an integer overflow in the calculation of the memory size for a JPEG2000 image, caused by multiplying large dimensions without checking for overflow, resulting in an undersized allocation.
Impact
An attacker could potentially execute arbitrary code on the victim's system by convincing them to open a malicious PDF.
What the attacker needed
Victim opens a malicious PDF; NitroPDF 12.12.1.522
The fix
The vulnerability should be fixed by validating image dimensions and using overflow-safe calculations for memory allocation.
How it was found
- Craft a PDF containing an embedded JPEG2000 image with unusually large xSiz and yTsiz values.
- Open the PDF in NitroPDF 12.12.1.522.
- The program calculates the memory size and overflows, allocating a smaller buffer than needed.
- The program writes pixel data in a loop, overflowing the buffer and corrupting adjacent heap memory.
- The corruption eventually causes a crash or, with careful manipulation, arbitrary code execution.
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 program opens a PDF with a special image inside, it calculates how much memory to reserve for the image. A mistake in that calculation makes it reserve too little memory, and then it writes more data than fits, corrupting other parts of memory. This can let an attacker run their own code on the victim's computer.
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.