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

OpenImageIO DDS scanline parsing code execution vulnerability

A heap buffer overflow exists in OpenImageIO's DDS scanline parsing because the buffer size calculation uses a different bytes-per-pixel value than the read operation. An attacker can provide a malicious .dds file to trigger the overflow, potentially leading to code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

A code execution vulnerability exists in the DDS scanline parsing functionality of OpenImageIO Project OpenImageIO v2.4.4.2. A specially-crafted .dds can lead to a heap buffer overflow.

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 buffer allocation size uses m_spec.depth * m_spec.nchannels * format.size() while the read size uses m_Bpp, and these values are not validated against each other, allowing m_Bpp to be larger.

Impact

A heap buffer overflow could lead to code execution.

What the attacker needed

Victim opens a malicious .dds file

The fix

The vulnerability was fixed in a vendor patch release.

How it was found

  1. Craft a .dds file with the DDS_PF_LUMINANCE flag set and a bpp value that makes m_Bpp larger than the product of depth, nchannels, and format size.
  2. Open the file with OpenImageIO, which calls DDSInput::open and then seek_subimage.
  3. Call read_native_scanline, which triggers readimg_scanlines and allocates m_buf based on the smaller size.
  4. internal_readimg reads w * m_Bpp * h bytes into m_buf, overflowing the heap 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.

OpenImageIO is a library that reads many image formats, including .dds files. When it reads a .dds file, it calculates how much memory to allocate for the image data, but it uses one size for the allocation and a different size for the actual read. This mismatch lets an attacker write more data than allocated, corrupting memory and possibly running 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.