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

Kakadu SDK JPEG 2000 Contiguous Codestream Code Execution Vulnerability

A specially crafted JPEG 2000 file with an oversized contiguous codestream causes the Kakadu SDK parser to allocate an undersized buffer, leading to an out-of-bounds write. An attacker could achieve code execution by getting a victim to open the malicious image.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.8 View original

A code execution vulnerability exists in the kdubufferedexpand function of the Kakadu SDK 7.9. A specially crafted JPEG 2000 file can be read by the program and can lead to an out of bounds write causing an exploitable condition to arise.

Aleksandar Nikolic and Tyler Bohan, 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 parser does not validate the codestream size fields, so an oversized value combined with a zero data value causes a buffer to be allocated at only 31 bytes instead of the required size, leading to an out-of-bounds write.

Impact

An attacker could achieve code execution with high confidentiality and integrity impact, though the victim must open the crafted image.

What the attacker needed

Victim opens a crafted JPEG 2000 file; software uses Kakadu SDK 7.9

How it was found

  1. Craft a JPEG 2000 file with an oversized contiguous codestream size field.
  2. Open the file with a program using the Kakadu SDK.
  3. The parser loops over the size values and allocates a buffer of only 31 bytes.
  4. The undersized buffer is reused in calculations, causing an out-of-bounds write and crash.

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.

JPEG 2000 files contain a header that tells the image decoder how big the image is. If those size numbers are huge but the file is tiny, the decoder can miscalculate how much memory it needs and write past the end of a buffer. That memory corruption can let an attacker run their own code when the image is opened.

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 Aleksandar Nikolic

View all

1 more disclosed report, 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.