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.
Originally disclosed on Cisco Talos
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.
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
- 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.
- Open the file with OpenImageIO, which calls DDSInput::open and then seek_subimage.
- Call read_native_scanline, which triggers readimg_scanlines and allocates m_buf based on the smaller size.
- 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.