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

Simple DirectMedia Layer SDL2_Image do_layer_surface code execution vulnerability

A heap buffer overflow in SDL2_image's XCF parsing allows an attacker to write beyond the allocated pixel buffer by supplying a crafted XCF file with more tiles than the surface can hold. This can lead to code execution when the image is displayed.

Lilith Q Follow

Originally disclosed on Cisco Talos

High 8.8 View original

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

Lilith Q(‘.’Q), 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 code does not verify that the number and size of tiles in an XCF layer match the dimensions of the destination surface, so it writes pixel data beyond the allocated buffer.

Impact

An attacker could execute arbitrary code on the victim's system by convincing them to open a malicious XCF image.

What the attacker needed

Victim opens a crafted XCF file

The fix

The vulnerability was fixed by the vendor, likely by adding bounds checks to ensure tile data does not exceed the surface buffer.

How it was found

  1. Create an XCF file with a layer that contains more tiles than the surface dimensions allow.
  2. Open the crafted XCF file with an application using SDL2_image.
  3. The parser writes pixel data for each tile without bounds checking, causing a 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 reserves a block of memory for the picture's pixels. This bug lets a malicious image file trick the program into writing past the end of that block, corrupting other memory. An attacker could use this to 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 Lilith Q

View all

1 more disclosed report, 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.