Simple DirectMedia Layer Create RGB Surface Code Execution Vulnerability
SDL's CreateRGBSurface function multiplies width, pitch and height without overflow checks, so a crafted image file with extreme dimensions causes too little memory to be allocated. Writing layer pixel data into that undersized buffer then overflows the heap, which the text says could lead to code execution.
Originally disclosed on Cisco Talos
An exploitable integer overflow vulnerability exists when creating a new RGB Surface in SDL 2.0.5. A specially crafted file can cause an integer overflow resulting in too little memory being allocated which can lead to a buffer overflow and potential 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 size calculation multiplies width, pitch and height without checking for integer overflow, so an oversized image dimension yields a tiny allocation.
Impact
A crafted image could cause a heap buffer overflow and potentially code execution, though the text only says this is potential.
What the attacker needed
Victim opens a crafted image file; application uses SDL_image
How it was found
- Craft an XCF image whose header declares very large width and height values.
- Open the file so SDL_image reads the header dimensions and calls CreateRGBSurface.
- The surface allocation overflows and reserves too little memory.
- The layer data is written into the undersized buffer, causing an out-of-bounds write.
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 needs memory for an image, it works out the size by multiplying the image's width, height and bytes per pixel. If those numbers are huge, the multiplication can wrap around to a small number, so the program reserves far less space than it thinks. It then copies the image data into that small space, spilling past the end and corrupting other memory, which can 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.