Skip to content
Memory corruption Advisory Advanced CVE-2019-5060

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.

Cory Duplantis Follow

Originally disclosed on Cisco Talos

High 8.8 View original

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.

Cory Duplantis, on Cisco Talos

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

  1. Craft an XPM image with a large number of colors to trigger integer overflow in create_colorhash.
  2. Display the crafted image using a program that uses SDL_image.
  3. 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.

More by Cory Duplantis

View all

35 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.