Skip to content
Memory corruption Advisory Advanced CVE-2018-3839

Simple DirectMedia Layer SDL2_Image load_xcf_tile_rle bpp Code Execution Vulnerability

A heap-based buffer overflow in SDL2_image's XCF image parsing allows an attacker to cause an out-of-bounds write by supplying a crafted XCF file with a large bpp value, potentially leading to code execution.

Lilith Follow

Originally disclosed on Cisco Talos

Medium 6.5 View original

An exploitable code execution vulnerability exists in the XCF image rendering functionality of SDL2image-2.0.2. A specially crafted XCF image can cause an out-of-bounds write on the heap, resulting in code execution.

Lilith, 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 product of x, y, and bpp is computed as an integer without overflow checking, so a large bpp value causes a small allocation, and subsequent writes using bpp as a stride go out of bounds.

Impact

An attacker could achieve code execution, though the large bpp value increases the chance of hitting unmapped memory and crashing, especially on 64-bit systems.

What the attacker needed

Victim loads a crafted XCF image

The fix

The vulnerability was fixed by the vendor.

How it was found

  1. Craft an XCF file with a large bpp value in the hierarchy struct.
  2. Load the crafted XCF file using SDL2_image.
  3. The integer overflow in the allocation size leads to a small buffer.
  4. The RLE decompression loop writes out of bounds, causing a crash or potential 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 loads an image, it reads size values from the file to decide how much memory to allocate. If those values are not checked, a malicious file can make the program write data past the end of the allocated memory, which can crash it 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.

More by Lilith

View all

4 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.