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.
Originally disclosed on Cisco Talos
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.
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
- Craft an image file with Exif metadata containing a TIFF_RATIONAL tag with a large tdir_count value.
- Open the crafted image with OpenImageIO, which triggers Exif parsing.
- 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.
- 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.