LEADTOOLS CMP-parsing code execution vulnerability
An integer underflow in LEADTOOLS' CMP image parsing allows a crafted file to cause a heap buffer overflow, potentially leading to code execution.
Originally disclosed on Cisco Talos
An exploitable integer underflow vulnerability exists in the CMP-parsing functionality of LEADTOOLS 20. A specially crafted CMP image file can cause an integer underflow, potentially resulting in 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
The code subtracts 2 from a two-byte size field without checking if the value is less than 2, causing an integer underflow when the size is 1.
Impact
This could lead to a heap buffer overflow, potentially resulting in code execution.
What the attacker needed
Victim opens a crafted CMP file
The fix
The size field should be validated to ensure it is at least 2 before subtracting, preventing the underflow.
How it was found
- Craft a CMP image file with the data size field set to 1.
- Open the crafted file in an application using LEADTOOLS CMP parsing.
- The parser subtracts 2 from the size, causing an underflow.
- The underflowed size is passed to a memmove wrapper, writing beyond the heap buffer.
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 reads a file, it often uses a number to say how much data to copy. If that number is too small, subtracting a fixed amount can wrap around to a huge number, causing the program to write far more data than intended. This 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.