Skip to content
Memory corruption Advisory Advanced CVE-2023-40163

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.

Emmanuel Tacheau Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

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.

Emmanuel Tacheau, 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

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

  1. Craft a JPG file containing a SOF3 marker and set the X_image value to zero.
  2. Load the malformed JPG file using the vulnerable ImageGear library.
  3. 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.

More by Emmanuel Tacheau

View all

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