Simple DirectMedia Layer SDL2_image do_layer_surface Double-Free Vulnerability
A crafted XCF image can make SDL2_image free the same memory buffer twice while parsing a layer. An attacker who gets a victim to open such an image could crash the application, and the report rates the impact as potentially allowing code execution.
A double-Free vulnerability exists in the XCF image rendering functionality of SDL2image-2.0.2. A specially crafted XCF image can cause a Double-Free situation to occur.
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 error branch frees the hierarchy's level offset array itself and then calls a cleanup function that frees the same array again.
Impact
A crafted image could crash the application, and the report rates the flaw as potentially allowing code execution, though most modern allocators catch the double free and abort immediately.
What the attacker needed
Victim opens a crafted XCF image; application uses SDL2_image 2.0.2
How it was found
- Craft an XCF image whose layer has a hierarchy with a bit depth of two and an image type that is neither indexed nor greyscale.
- Load the crafted image with SDL2_image so it reads the layer and its hierarchy.
- The parser reaches the default branch of the image type switch and frees the level offset array.
- The cleanup function then frees the same array again, and the allocator aborts.
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 memory for the image data and later gives that memory back. A double free happens when the program gives the same block back twice, which confuses the memory manager and can crash the program or let an attacker take control. Here a malformed GIMP image file makes the library take a path where the same buffer is released twice.
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.