Accusoft ImageGear allocate_buffer_for_jpeg_decoding out-of-bounds write vulnerability
A missing buffer size check in the JPEG decoding function allocate_buffer_for_jpeg_decoding allows a malformed JPG file to cause an out-of-bounds write. An attacker can provide a malicious file to trigger memory corruption.
Originally disclosed on Cisco Talos
An out-of-bounds write vulnerability exists in the allocatebufferforjpegdecoding functionality of Accusoft ImageGear 20.1. A specially crafted malformed file can lead to 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
Likely the buffer size calculation can become zero when the image width is zero, leading to a one-byte allocation that is later written to as a two-byte value.
What the attacker needed
Victim opens a malicious JPG file; application uses vulnerable ImageGear library
The fix
The vendor released a patch in version 20.3.
How it was found
- Craft a JPG file containing a SOF3 marker and set the X_image value to zero.
- Load the malformed JPG file using the vulnerable ImageGear library.
- The library allocates a one-byte buffer and then writes a two-byte value into it, 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.
When a program reads a file, it often reserves a block of memory to hold the data. If it reserves too little space and then writes more data than fits, it can overwrite other memory, which is called an out-of-bounds write. Here, a malformed image file tricks the program into reserving almost no space, and then it writes into that tiny block, corrupting memory.
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.