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.
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.
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
- Create an XCF file with a layer that contains more tiles than the surface dimensions allow.
- Open the crafted XCF file with an application using SDL2_image.
- 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.