Simple DirectMedia Layer SDL2_Image IMG_LoadLBM_RW Code Execution Vulnerability
A heap buffer overflow exists in SDL2_image's ILBM image parsing when the number of bit planes is not 24 or less than 8, causing the palette colour array to be overrun with attacker-controlled data. An attacker could execute code by displaying a specially crafted image.
Originally disclosed on Cisco Talos
An exploitable code execution vulnerability exists in the ILBM image rendering functionality of SDL2image-2.0.2. A specially crafted ILBM 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 assumes the number of bit planes in the image header matches the colour depth used to allocate the palette, but this is not true for values other than 24 or less than 8, leading to a heap overflow.
What the attacker needed
Victim opens a crafted ILBM image
How it was found
- Craft an ILBM file with a BMHD chunk where the planes field is set to a value other than 24 or less than 8.
- Load the file using SDL2_image's IMG_Load function.
- The palette population loop writes beyond the allocated colour array, 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.
An image file contains a header that tells the program how many colours to expect. The program allocates space for a fixed number of colours but then copies more colours than that into the space, writing past the end of the buffer. This can crash the program 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.