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

OpenImageIO Exif out-of-bounds write vulnerability

A stack-based out-of-bounds write exists in OpenImageIO's Exif parsing when handling a TIFF_RATIONAL tag with a large tdir_count, leading to memory corruption. An attacker can provide a malicious image file to trigger this vulnerability, potentially leading to code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

An out-of-bounds write vulnerability exists in the OpenImageIO::addexifitemtospec functionality of OpenImageIO Project OpenImageIO v2.4.4.2. Specially-crafted exif metadata can lead to stack-based memory corruption.

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

The tdir_count value from the Exif data is used directly to allocate stack memory via alloca without proper bounds checking, and later used to write data, leading to stack corruption.

Impact

An attacker could cause a crash or potentially achieve code execution by corrupting the stack with controlled values.

What the attacker needed

Victim opens a malicious image file

The fix

The vulnerability was fixed in a vendor patch release.

How it was found

  1. Craft an image file with Exif metadata containing a TIFF_RATIONAL tag with a large tdir_count value.
  2. Open the crafted image with OpenImageIO, which triggers Exif parsing.
  3. The parsing reaches add_exif_item_to_spec, where the large tdir_count causes alloca to allocate a huge or negative-sized buffer on the stack.
  4. The subsequent loop or attribute call writes data to the stack, causing memory 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.

OpenImageIO is a library for reading and writing image files. When it reads a specially crafted image, it can be tricked into writing data outside the intended memory area on the stack, which can crash the program or potentially 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 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.