GHSA-g7cr-3p24-7wf7
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessCraft JPEG with buffer-filling ICC profile and comment
-
ExploitVictim application re-saves image as JPEG preserving ICC and comment
-
ExecutionCOM marker write overruns 65536-byte encoder buffer
-
ImpactOverwrite adjacent heap memory, crash or execute code
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Bounds checking, write limits
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Privilege Escalation The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires an application to re-save an attacker-supplied JPEG using Pillow (9.4.0 through 12.x) while preserving BOTH the image's ICC profile AND a forwarded COM comment. The triggering condition is highly specific: the ICC profile must be sized so it exactly fills the 65536-byte encoder buffer, leaving the COM marker to be written when libjpeg's free_in_buffer counter has been exhausted and then wraps. LIMITING FACTORS: the attack depends on this precise buffer-fill boundary (reflected as AT:P in the CVSS 4.0 vector) and on the host application actively re-encoding/round-tripping the image with metadata preserved (UI:P), making it application-behavior-dependent rather than exploitable against a passive library install; reliable code execution further depends on runtime and heap layout, so a process crash is the more consistently achievable impact. |
| Impact | This is a genuine memory-corruption flaw (CWE-787 out-of-bounds write) with a write primitive confirmed directly in the source diff: ImagingJpegEncode() in JpegEncode.c wrote a COM marker without first checking free_in_buffer against comment_size+5, and the fix adds exactly that bounds check. The CVSS 4.0 base score is 7.7 (High) with AV:N/AC:L/AT:P/PR:N/UI:P and full H/H/H vulnerable-system impact, reflecting a network-reachable, unauthenticated issue that nonetheless carries a real attack requirement (AT:P) and passive user/application interaction (UI:P). Several real-world mitigating signals cut against treating this as top-priority: no EPSS score was supplied in the input (exploitation probability unknown), the CVE is NOT in CISA KEV, and no public POC/exploit code is referenced - so exploitation status is 'no public exploit identified at time of analysis.' The precondition is narrow and precise: the ICC profile must exactly fill the 65536-byte encoder buffer so that libjpeg writes one byte past an exhausted counter that then wraps - a fragile, heap-layout-dependent condition. The description itself hedges RCE as 'may enable code execution in suitable runtime and heap layouts,' so reliable code execution is unconfirmed and a process crash (DoS) is the more probable practical outcome. Net: a real bug worth patching promptly given Pillow's enormous footprint, but currently a high-CVSS issue without evidence of weaponization or widespread exploitation. |
| Exploit ScenarioDerived | An attacker uploads a crafted JPEG whose ICC profile is sized to exactly fill Pillow's 65536-byte JPEG encoder buffer and which also carries a forwarded COM comment, to a web service that uses Pillow to re-save uploaded images as JPEG while preserving metadata. When the server re-encodes the image, the COM marker write overruns the buffer and corrupts adjacent heap memory, crashing the worker and potentially enabling code execution depending on heap layout. No public exploit code is referenced in the provided intelligence. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv2 – Oct 21, 2026
Heap-based out-of-bounds write in Pillow's JPEG encoder (9.4.0 through 12.x) can crash a process and may enable code execution when an application re-saves an attacker-supplied image while preserving both an ICC profile and a forwarded COM comment. The flaw is triggered only when the ICC profile exactly fills the 65536-byte encoder buffer, causing libjpeg's free_in_buffer accounting to wrap before the comment is written; exploitation is application-behavior-dependent and heap-layout-sensitive. Vendor-released patch: 13.0.0; no public exploit identified at time of analysis.
Earlier versions of this analysis (1)
A heap buffer overflow in Pillow's JPEG encoder occurs when an ICC profile large enough to fill the encoder's internal output buffer is supplied together with a JPEG comment, causing the comment write to run past the end of that already-filled buffer. Only applications that pass attacker-influenced ICC profile data and comment strings into Pillow's JPEG save path are reachable - merely opening or decoding a malicious image does not trigger it. Affected are Pillow versions prior to 13.0.0; the Pillow maintainers rate this issue High (GHSA-g7cr-3p24-7wf7), and no CVSS vector, CWE, EPSS score, KEV entry, or public exploit code was available at time of analysis.
RemediationAI
Upgrade to Pillow 13.0.0 or later (vendor-released patch: 13.0.0), which adds a comment-length limit that raises ValueError for overly long comments and a free_in_buffer bounds check before writing the COM marker. If upgrading immediately is not possible, avoid re-saving untrusted JPEGs with ICC profiles and forwarded comments; strip the COM comment and/or ICC profile before encoding, or reject images whose comment exceeds the JPEG marker limit of 65533 bytes. As compensating controls, run image re-encoding in a low-privilege, memory-limited worker and monitor for crashes, accepting the trade-off of metadata loss and possible color-profile fidelity loss when stripping ICC or comment data. See https://github.com/python-pillow/Pillow/security/advisories/GHSA-g7cr-3p24-7wf7 and https://pillow.readthedocs.io/en/stable/releasenotes/13.0.0.html.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Pillow binds libjpeg through src/libImaging/JpegEncode.c. In ImagingJpegEncode(), a COM marker is emitted with jpeg_write_marker() without ensuring the destination buffer has room for the comment; libjpeg writes one byte before checking free_in_buffer, so if an ICC profile has exactly consumed the 65536-byte buffer, the exhausted counter wraps and attacker-controlled comment data plus subsequent compressed image data can overwrite adjacent heap memory. This is CWE-787 (out-of-bounds write) in a native C extension reachable from Python's JPEG save path in JpegImagePlugin.py when an application round-trips untrusted images with metadata preserved. The source diff confirms the root fix: reject comments above the marker limit and add a comment_size + 5 > free_in_buffer bounds check before writing the COM marker. The CVSS 4.0 vector's AT:P/UI:P and the independent CVSS 3.1 AV:N/AC:H/PR:N/UI:R assessment reflect the precise buffer-fill boundary and the requirement that the host application actively re-encode the image.
Know when Pillow gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
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
AV:N as the image arrives over the network and PR:N as no authentication is needed; AC:H because the ICC profile must exactly fill the 65536-byte buffer, and UI:R because the application must re-save preserving metadata.
Primary rating from Vendor (CNA).
CVSS VectorVendor
Lifecycle Timeline
4Description PRE-NVD
Blast Radius
ecosystem impact- 284 pypi packages depend on pillow (263 direct, 21 indirect)
Ecosystem-wide dependent count for version 9.4.0.
Technical POC Analysis
CWE-787 heap-based out-of-bounds write in ImagingJpegEncode() in src/libImaging/JpegEncode.c (state 4, line 330).
Full technical POC analysis - root cause, step-by-step exploitation and patch breakdown - is part of the Pro and Business plans.
Executive ViewAI
A high-severity memory corruption flaw in Pillow, the Python imaging library embedded in many web upload, content moderation, and media-processing pipelines, can crash services and, under narrow conditions, enable code execution when untrusted images are re-saved. Any team that ingests and re-encodes user-supplied JPEGs while preserving ICC profiles and forwarded COM comments is in scope, creating a broad availability risk and a potential integrity concern for customer-facing platforms. Because Pillow is often a transitive dependency, leadership should treat this as a supply-chain remediation priority rather than an isolated engineering ticket.
Apply vendor patch (upgrade to Pillow 13.0.0).
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
A buffer overflow occurs when a program writes more data to a memory buffer than it was allocated to hold, causing the excess data to spill into adjacent memory regions.
Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
libImaging/TgaRleDecode.c in Pillow 9.1.0 has a heap buffer overflow in the processing of invalid TGA image files. Rated
Denial of service in Python Pillow (versions 8.2.0 through 12.2.0) allows remote attackers to exhaust memory during JPEG
Out-of-bounds memory disclosure in Python Pillow before 12.3.0 lets an attacker who supplies a crafted McIdas AREA image
Heap out-of-bounds write in Python Pillow prior to 12.3.0 lets an attacker who controls the rank-filter size parameter c
Denial-of-service and controlled heap corruption in Python's Pillow imaging library (all versions prior to 12.3.0) occur
Denial of service in Python Pillow 12.0.0 through 12.2.0 lets a remote attacker hang an application by supplying a craft
Denial of service (and potential memory corruption) in Python Pillow before 12.3.0 arises when public image coordinate A
Uncontrolled memory allocation in Python Pillow before 12.3.0 lets a crafted BDF font file exhaust available memory and
Uncontrolled memory consumption in Python Pillow (PIL) versions 5.1.0 through 12.2.x allows a remote attacker to cause d
Denial-of-service via memory exhaustion in Python Pillow before 12.3.0 allows a crafted GD-format (.gd) image to trigger
Uncontrolled memory allocation in Python Pillow before 12.3.0 allows a maliciously crafted font file to trigger excessiv
Uncontrolled memory allocation in the Python Pillow imaging library (all versions prior to 12.3.0) allows a crafted PCF
EUVD-2026-107566
NVD
CVE.org
EPSS
VulDB
Exploit-DB