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

SDL_image PCX Image Code execution Vulnerability

A heap buffer overflow in SDL_image's PCX parsing allows an attacker to write beyond the allocated pixel buffer by crafting a PCX image with specific header values. This can lead to code execution when the image is displayed.

Cory Duplantis Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable code execution vulnerability exists in the PCX image-rendering functionality of SDL2image 2.0.4. A specially crafted PCX image can cause a heap overflow, resulting in code execution.

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

The bytes-per-line value from the PCX header is used as a loop counter without proper validation against the allocated buffer size, leading to a heap overflow.

Impact

A specially crafted PCX image can cause a heap overflow, potentially resulting in code execution.

What the attacker needed

Victim opens a crafted PCX image

The fix

The vulnerability was fixed by the vendor.

How it was found

  1. Craft a PCX image with header fields that cause the bytes-per-line calculation to exceed the allocated buffer size.
  2. Set the encoding to RLE and provide data that triggers the overflow during decoding.
  3. Display the crafted image using a program that uses SDL_image, causing the heap overflow.

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 loads an image, it sets aside memory to hold the picture. In this case, a flaw in how the image header is checked lets an attacker make the program write more data than the memory can hold, which can crash the program or let the 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.

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.