Skip to content
Memory corruption Advisory Advanced CVE-2021-21949

Accusoft ImageGear JPEG-JFIF Scan header parser out-of-bounds write vulnerability

The JPEG-JFIF Scan header parser in Accusoft ImageGear 19.10 fails to validate array indices for AC and DC Huffman table selectors, allowing an attacker to use out-of-range values to access arbitrary memory. This can lead to a stack-based buffer overflow and potentially code execution when a malicious JPEG file is opened.

Francesco Benvenuto Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

An improper array index validation vulnerability exists in the JPEG-JFIF Scan header parser functionality of Accusoft ImageGear 19.10. A specially-crafted file can lead to an out-of-bounds write and potential code exectuion.

Francesco Benvenuto, 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 AC and DC table index values from the SOS header are used as array indices without validating that they are within the range of parsed Huffman tables, breaking assumptions made during table parsing.

Impact

An attacker could cause a stack-based buffer overflow, leading to a crash or potentially arbitrary code execution.

What the attacker needed

Victim opens a malicious JPEG file

How it was found

  1. Craft a JPEG file with an SOS header containing AC or DC table index values outside the valid range (0-3).
  2. Open the malicious JPEG file with a vulnerable application using ImageGear.
  3. The parser uses the out-of-range index to fetch a pointer from memory beyond the Huffman table array.
  4. The fetched pointer is used to calculate an offset that bypasses signed range checks.
  5. The offset is used to write data outside the stack buffer, causing an access violation or potential code execution.

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 an image is loaded, the software reads a header that tells it which compression tables to use. The code does not check that the table numbers are within the allowed range, so a crafted file can make it read a pointer from outside the table. That bad pointer is then used to write data outside a buffer on the stack, 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.

More by Francesco Benvenuto

View all

152 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.