Accusoft ImageGear PNG store_data_buffer size computation code execution vulnerability
A specially crafted PNG file causes an out-of-bounds write in the store_data_buffer function of Accusoft ImageGear because a raster size is cast to a signed 16-bit value and then sign-extended. An attacker who supplies a malformed file to a victim could corrupt memory and potentially achieve remote code execution.
Originally disclosed on Cisco Talos
An exploitable out-of-bounds write vulnerability exists in the storedatabuffer function of the igcore19d.dll library of Accusoft ImageGear 19.5.0. A specially crafted PNG file can cause an out-of-bounds write, resulting in a remote code execution.
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
A raster size computed as an unsigned value is stored through a signed 16-bit pointer and later sign-extended to a larger type, so the copy loop count becomes far larger than the allocated destination buffer.
Impact
The out-of-bounds write corrupts memory and could result in remote code execution when a victim opens a malformed file.
What the attacker needed
Victim opens a malformed PNG file; attacker can deliver the file to the victim
The fix
The vendor patched the issue, presumably by correcting the signed truncation and sign extension of the raster size before it is used as a copy length.
How it was found
- Open a malformed PNG file through the library's file-loading function.
- The PNG raster processing path computes a destination buffer size from the image width, colour space and bit depth.
- A separate size value derived from the raster size is truncated to a signed 16-bit integer and sign-extended.
- The copy routine uses that inflated size as its loop bound and writes past the end of the destination 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.
ImageGear is a library that programs use to open and convert image files. When it reads a PNG, it works out how big a buffer to allocate and how many bytes to copy into it, but a number is squeezed into a smaller signed type, so it can become negative and then be treated as a huge positive number. The copy loop then writes past the end of the buffer, which can crash the program or 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.