SDL_image XPM image colorhash parsing Code Execution Vulnerability
An integer overflow in the colorhash function of SDL_image 2.0.4 when parsing a specially crafted XPM image can cause a too-small buffer allocation, leading to a heap overflow and potentially code execution. An attacker can trigger this by displaying a malicious image.
Originally disclosed on Cisco Talos
An exploitable code execution vulnerability exists in the XPM image rendering function of SDL2image 2.0.4. A specially crafted XPM image can cause an integer overflow in the colorhash function, allocating too small of a buffer.
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 multiplication of the hash table size by the size of a pointer can overflow, resulting in a small allocation, and later writes to the hash table can go out of bounds.
Impact
This could lead to code execution, though the report notes it is 'potentially' resulting in code execution.
What the attacker needed
Victim opens a crafted XPM image
The fix
The vendor patched the vulnerability, but the report does not describe the fix.
How it was found
- Craft an XPM image with a large number of colors to trigger integer overflow in create_colorhash.
- Display the crafted image using a program that uses SDL_image.
- The overflow causes a small allocation, and subsequent color insertion writes out of bounds.
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.
This report describes a bug in a library that reads image files. When the library processes a malicious image, it miscalculates how much memory to reserve, then writes data past the end of that 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.