Skip to content
Memory corruption Advisory Advanced CVE-2017-2888

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.

Yves Younan Follow

Originally disclosed on Cisco Talos

High 8.8 View original

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.

Yves Younan, 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 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

  1. Craft an XCF image whose header declares very large width and height values.
  2. Open the file so SDL_image reads the header dimensions and calls CreateRGBSurface.
  3. The surface allocation overflows and reserves too little memory.
  4. 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.

More by Yves Younan

View all

3 more disclosed reports, 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.