HIGHCVSS v4 7.7Vulnerability

CVE-2026-96778

``` ============================================================================ Heap buffer overflow writing JPEG comment after ICC profile fills buffer Location: src/libImaging/JpegEncode.c:330 in ImagingJpegEncode() Commit: a707c6b21c313880d0771e54965d142dd42358b6 ============================================================================ ``` A heap buffer overflow in Pillow's JPEG encoder lets anyone who can supply an image write up to 64 KB of bytes they choose, followed by the rest of the compressed image, past the end of a 64 KB heap buffer. The target is any application that re-saves the image as JPEG while keeping its colour profile. The reliable result is that the Python process is killed outright rather than raising an exception. Because the overwritten memory sits directly in front of function pointers that the encoder calls next, this could allow code execution, though the attached reproducer demonstrates only the crash. The bug is in `ImagingJpegEncode()` in `src/libImaging/JpegEncode.c`. State 4 (line 330) calls `jpeg_write_marker()` for the COM comment marker without checking that the output buffer has room. Meanwhile, `JpegImagePlugin._save()` sizes that buffer from the EXIF and ICC/XMP data only and reserves nothing for the comment. When a 65498-byte ICC profile fills the 65536-byte buffer exactly, libjpeg's `emit_byte()` stores one byte past the end and then decrements `free_in_buffer` from 0. The `size_t` counter wraps, so the marker, the comment and the entire compressed image are written out of bounds. Triggering it takes only a valid JPEG (or PNG) carrying that profile and any comment, passed through `Image.open()` and then `im.save(..., "JPEG", icc_profile=im.info.get("icc_profile"))`. That is the documented way to preserve colour. The comment is forwarded from `im.info` automatically, and no non-default setting is involved. The attached reproducer re-saves such a file on the stock build, and the process dies with SIGSEGV. An identica

Properties

Severity
high
Summary
Pillow: Heap buffer overflow writing JPEG comment after ICC profile fills buffer
Nvd fetched at
2026-10-22T22:14:18.200859+00:00
Epss score
0.00401
Cvss severity
HIGH
Cvss score
7.7
Retrieved at
2026-10-22T22:17:36+00:00
Ghsa published
2026-10-22T16:05:39Z
Source url
https://github.com/advisories/GHSA-g7cr-3p24-7wf7
Ghsa updated
2026-10-22T16:05:41Z
Ghsa id
GHSA-g7cr-3p24-7wf7
Last source
FIRST EPSS
Score
7.7
Cvss version
4.0
Cve id
CVE-2026-96778
Cvss vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
First seen by Signal
2026-10-21T22:34:38+00:00
Is ghsa only
false
Vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Published at
2026-10-21T21:20:33.093

Related Entities (3)

AFFECTS (1)

→[Software]pip/Pillow

HAS_WEAKNESS (1)

→[Weakness]Out-of-bounds Write

VULNERABLE_TO (1)

←[Software]pip/Pillow

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-96778 (CVSS v4 7.7) — Ninja Signal Threat Intelligence | Ninja Signal