Skip to content
Memory corruption Advisory Advanced CVE-2019-5087

xcftools flattenIncrementally rows allocation code execution vulnerability

An integer overflow in the flattenIncrementally function of xcftools 1.0.7 can occur when calculating the row allocation size, leading to heap corruption. A victim opening a specially crafted XCF file could trigger memory corruption and potentially execute arbitrary code.

Claudio Bozzato Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable integer overflow vulnerability exists in the flattenIncrementally function in the xcf2png and xcf2pnm binaries of xcftools 1.0.7. An integer overflow can occur while calculating the row’s allocation size, that could be exploited to corrupt memory and eventually execute arbitrary code.

Claudio Bozzato, 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 row allocation size is computed as 4 times the layer width without checking for integer overflow, so a width larger than 0x3fffffff wraps around and allocates a too-small buffer.

Impact

A victim opening a specially crafted XCF file could trigger heap corruption, potentially leading to arbitrary code execution.

What the attacker needed

Victim opens a crafted XCF file

How it was found

  1. Craft an XCF file with a layer width larger than 0x3fffffff.
  2. Open the crafted XCF file with xcf2png or xcf2pnm.
  3. The program parses the file and calls flattenIncrementally.
  4. The row allocation overflows, leading to heap corruption.

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 calculates how much memory to reserve, it can wrap around if the number is too large, like an odometer rolling over. Here, a malicious image file can cause that wrap-around, so the program reserves too little memory and then writes more data than fits, corrupting other memory. This 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 Claudio Bozzato

View all

185 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.