CVE-2026-59203: Denial of Service via Infinite Loop in Pillow EPS Image Parser
Vulnerability ID: CVE-2026-59203
CVSS Score: 5.3
Published: 2026-07-20
A denial-of-service (DoS) vulnerability in Pillow (Python Imaging Library) versions 12.0.0 through 12.2.0 allows unauthenticated remote attackers to trigger 100% CPU utilization and hang the processing thread. The issue occurs within the Encapsulated PostScript (EPS) image parser (PIL/EpsImagePlugin.py) due to missing validation on the byte count parsed from %%BeginBinary: comments, allowing negative values to cause an infinite backward stream seek loop. This formatting-level state-looping issue occurs during the initial format sniffing phase inside Image.open() and does not require the system Ghostscript interpreter to be executed or present. It is resolved in version 12.3.0.
TL;DR
Unvalidated negative byte counts in Pillow's EPS image parser trigger an infinite backward stream-seek loop, resulting in 100% CPU utilization and application hang without requiring image rendering or a Ghostscript installation.
⚠️ Exploit Status: POC
Technical Details
- CWE ID: CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
- Attack Vector: Network (AV:N)
- CVSS v3.1 Score: 5.3 (Medium)
- EPSS Score: 0.0039 (Percentile: 31.40%)
- Impact: Denial of Service (Thread Hang / CPU Exhaustion)
- Exploit Status: Proof-of-Concept (PoC) available
- CISA KEV Status: Not Listed
Affected Systems
- Pillow (python-pillow) version 12.0.0 through 12.2.0
-
Pillow: >= 12.0.0, < 12.3.0 (Fixed in:
12.3.0)
Code Analysis
Commit: 0399261
Raise ValueError if EPS BeginBinary bytecount is negative (#9708)
@@ -357,6 +357,9 @@ def read_comment(s: str) -> bool:
trailer_reached = True
elif bytes_mv[:14] == b"%%BeginBinary:":
bytecount = int(byte_arr[14:bytes_read])
+ if bytecount < 0:
+ msg = "BeginBinary bytecount cannot be negative"
+ raise ValueError(msg)
self.fp.seek(bytecount, os.SEEK_CUR)
bytes_read = 0
Exploit Details
- GitHub Security Advisory: Advisory containing technical description and proof of concept behavior.
Mitigation Strategies
- Upgrade to Pillow version 12.3.0 or higher.
- Restrict accepted formats when calling Image.open() to prevent automatic sniffing from executing the EPS parser.
- Reject file uploads starting with PostScript headers (%!PS) at the web gateway or load balancer.
- Isolate worker processes utilizing limits on containerized CPU and memory allocation to contain infinite-loop exploitation.
Remediation Steps:
- Audit the environment to confirm the installed Pillow version using: pip show Pillow
- Execute: pip install --upgrade Pillow>=12.3.0 to install the patched package.
- Identify all locations utilizing Image.open() and constrain the acceptable format array (e.g., Image.open(f, formats=['PNG', 'JPEG'])).
- Ensure applications running image processing logic reside within limited container processes with resource constraints.
References
- GitHub Security Advisory GHSA-pg7v-jwj7-p798
- Fix Commit
- Pillow Pull Request #9708
- Pillow Release 12.3.0
- CVE Record on CVE.org
- NVD CVE-2026-59203
Read the full report for CVE-2026-59203 on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)