Skip to content
Memory corruption Advisory Advanced CVE-2022-41639

OpenImageIO TIFF tile pels decoding heap-based buffer overflow

A heap-based buffer overflow exists in OpenImageIO's TIFF tile decoding because the destination buffer size is calculated from the image specification while the actual read size comes from LibTIFF's tile size, which can be larger. An attacker can supply a crafted TIFF file to corrupt heap memory and potentially achieve arbitrary code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

A heap based buffer overflow vulnerability exists in tile decoding code of TIFF image parser in OpenImageIO master-branch-9aeece7a and v2.3.19.0. A specially-crafted TIFF file can lead to an out of bounds memory corruption, which can result in arbitrary code execution.

Lilith >_>, 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

Likely the destination buffer is sized from OpenImageIO's ImageSpec tile bytes while the read length passed to LibTIFF is derived from LibTIFF's own tile size, and the two calculations disagree.

Impact

A crafted TIFF file can cause heap memory corruption, which could lead to arbitrary code execution.

What the attacker needed

Attacker supplies a crafted TIFF file; victim processes the file with OpenImageIO

How it was found

  1. Craft a TIFF file whose tile tags produce a LibTIFF tile size larger than the OpenImageIO tile buffer size.
  2. Open the file with OpenImageIO so that TIFFInput::seek_subimage parses the directory and computes tif_tilesize.
  3. Call read_native_tiles, which allocates the pels buffer from the ImageSpec tile bytes.
  4. read_native_tile passes the pels buffer to TIFFReadTile, which reads using the larger LibTIFF tile size and overflows the buffer.

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 an image library reads a TIFF file, it first works out how big a temporary buffer needs to be to hold one tile of the image. Here it worked out one size for the buffer but then told the underlying TIFF reader to fill it using a different, larger size. That means data is written past the end of the buffer, corrupting nearby memory, which an attacker can use to 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 Lilith >_>

View all

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