Project

General

Profile

Actions

Bug #1221

closed

Out-of-bounds read in bundled IJG JPEG Huffman decoder

Added by Michael Onken 2 days ago. Updated about 3 hours ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Library
Target version:
-
Start date:
2026-06-10
Due date:
% Done:

0%

Estimated time:
Module:
dcmjpeg
Operating System:
Compiler:

Description

DCMTK's bundled IJG JPEG library (dcmjpeg/libijg8, and the identical libijg12/libijg16 copies) contains a Huffman-table validation bug that leads to an out-of-bounds read when decoding a crafted JPEG-compressed DICOM image.

The DC Huffman table validation in jdhuff.c accepts a symbol value of 16, but the extend_test[] lookup array used during coefficient decoding only has 16 valid entries (indices 0–15). A JPEG containing a DC Huffman code mapped to symbol 16 therefore causes the decoder to read one element past the end of extend_test[], a global-buffer-overflow (CWE-125). The same validation flaw triggers crashes in all three decoder variants — sequential, lossless, and progressive — and is reachable from untrusted input through any tool or application that decodes JPEG, including dcmdjpeg, dcm2img, dcmj2pnm, and anything using DJDecoderRegistration or DicomImage.

Full analysis, proof-of-concept, and a patch proposed by the original sender are in the attached report.

Thanks to Yiyi Wang for reporting this issue.


Files

Actions #1

Updated by Michael Onken 1 day ago

Fixed with commit d6ae1bc8d5b9ae9c7300013c8c85cc2ea0fd8cf5.

Actions #2

Updated by Michael Onken about 3 hours ago

  • Status changed from New to Closed
  • Private changed from Yes to No
Actions

Also available in: Atom PDF