Skip to content
Memory corruption Advisory Advanced CVE-2016-5684

FreeImage Library XMP Image Handling Code Execution Vulnerability

The XPM image loader in FreeImage reads a signed integer for characters-per-pixel from the file and uses it without validation to compute a pointer into the buffer, then writes to that location while replacing tabs. A crafted XPM image could therefore cause an out-of-bounds write, potentially leading to arbitrary memory overwrite and code execution.

Yves Younan Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable out-of-bounds write vulnerability exists in the XMP image handling functionality of the FreeImage library.

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 characters-per-pixel value parsed from the file is a signed integer used without validation to offset a pointer, so a negative or oversized value moves the write outside the allocated buffer.

Impact

A specially crafted XPM file could cause an arbitrary memory overwrite resulting in code execution, though the attacker needs the victim to open the malicious image.

What the attacker needed

Victim opens a crafted XPM image; program uses FreeImage to load images

The fix

The library should validate the characters-per-pixel value before using it as an offset; the text only offers a mitigation of refusing to load files detected as XPM.

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.

FreeImage is a library that many programs use to open image files. When it reads a particular image format called XPM, it trusts a number written inside the file to decide where in memory to start editing text. A malicious file can supply a bad number so the library writes outside the intended memory area, which 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.

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.