CVE-2026-96778
High · 8.8CVSS
8.8
EPSS
0.5%
Published
Oct 21, 2026
CISA due date
—
Cloudanix analysis
A bug in the popular Python image library can let a specially made picture corrupt memory when it is re-saved, potentially crashing programs or allowing attackers to run code.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Moderate
- Impact
- Remote Code Execution
- Component
- Library
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Out-of-bounds write in ImagingJpegEncode when an ICC profile exactly fills the 65536-byte buffer and a JPEG COM comment is written, allowing jpeg_write_marker to overwrite adjacent heap memory due to unchecked free_in_buffer wrap.
Why it matters to the business
Attackers able to supply crafted images can crash image-processing services or potentially execute code when the library re-encodes JPEGs while preserving ICC profiles and comments; the flaw affects any application using vulnerable Pillow versions for untrusted image handling.
How an attack unfolds
An attacker supplies a JPEG with a full-size ICC profile and a COM comment; when the application re-saves the image the encoder writes the comment marker without bounds checking, corrupting heap memory and leading to a crash or, under favorable conditions, arbitrary code execution.
How to fix it
Upgrade Pillow to version 13.0.0 or later; rebuild any dependent packages and restart affected services; disable JPEG re-encoding of untrusted images or strip ICC profiles and comments as a temporary mitigation.
How to confirm the fix worked
Confirm installed Pillow version is 13.0.0 or newer via pip show or import; test with a crafted JPEG containing a full ICC profile and COM comment to verify the process no longer crashes or corrupts memory.
Typical attack path
- Attacker crafts JPEG containing maximum-size ICC profile plus COM comment
- Victim application loads and re-encodes the image with Pillow 9.4.0-12.x
- ImagingJpegEncode calls jpeg_write_marker on the comment after buffer exhaustion
- One byte is written past the buffer, wrapping the counter and corrupting adjacent heap
- Process crashes or attacker-controlled data enables code execution in suitable heap layout
How to detect it
Review application logs for unexpected crashes or segmentation faults during JPEG encoding operations; inspect process core dumps or heap sanitizer output for buffer overflows involving jpeg_write_marker; correlate with file-upload or image-processing audit trails for recently handled JPEGs containing large ICC profiles.
What your security team should do
- Immediately inventory all systems using Pillow 9.4.0 through 12.x and schedule upgrade to 13.0.0
- Prioritize services that accept and re-encode user-supplied JPEG images
- Add runtime version checks and alerts for Pillow < 13.0.0 in CI/CD pipelines
- Monitor crash logs for jpeg_encode related segmentation faults while patches are applied
The record
Pillow is a Python imaging library. From 9.4.0 until 13.0.0, ImagingJpegEncode() in src/libImaging/JpegEncode.c can call jpeg_write_marker() for a JPEG COM comment when an ICC profile has exactly filled the 65536-byte encoder buffer. libjpeg writes one byte before checking the exhausted free_in_buffer counter, which then wraps and permits the attacker-controlled comment and subsequent compressed image data to overwrite adjacent heap memory. Re-saving an untrusted image as JPEG while preserving its ICC profile and forwarded comment can crash the process and may enable code execution in suitable runtime and heap layouts. This issue is fixed in version 13.0.0.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|
Related vulnerabilities
- CVE-2026-78402 Stack-based buffer overflow and out-of-bounds write vulnerability in Thales Sentinel Keys… CWE-787
- CVE-2026-119777 A flaw was found in GStreamer's gst-plugins-bad H.266/VVC parser. CWE-787
- CVE-2026-104065 Scribus before 1.6.7 contains an out-of-bounds write vulnerability in the importdrw… CWE-787
- CVE-2026-104067 Scribus before 1.6.7 contains an out-of-bounds memory access vulnerability in the… CWE-787
- CVE-2026-104066 Scribus before 1.6.7 contains a heap buffer overflow vulnerability in the Mac PICT image… CWE-787
- CVE-2026-104061 Scribus before 1.6.7 contains a heap out-of-bounds write vulnerability in the… CWE-787
- CVE-2026-104062 Scribus before 1.6.7 contains a heap buffer overflow vulnerability in the PICT image… CWE-787
- CVE-2026-61627 libass is a portable subtitle renderer for the `ASS`/SSA (Advanced Substation… CWE-787