Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-96641 Overview
CVE-2026-96641 is an integer overflow vulnerability [CWE-190] in the Pillow Python imaging library affecting all versions prior to 13.0.0. The flaw resides in the PILfont text-width accumulation logic in src/_imaging.c. The code checks positive glyph advances against INT_MAX but fails to validate negative advances against INT_MIN. Repeated signed 16-bit advances of -32768 can trigger a signed C integer overflow in the xsize += dx accumulator, producing a large positive width from what should be a negative mathematical result. Applications relying on getlength(), getsize(), or derived layout, quota, serialization, or allocation calculations may experience logic-integrity errors or excessive resource consumption.
Critical Impact
A crafted font input can cause integer overflow in Pillow's text width calculation, resulting in corrupted size values that break downstream allocation, quota, and serialization logic.
Affected Products
- Python Pillow imaging library versions prior to 13.0.0
- Applications using PIL.ImageFont.getlength() or getsize() on PILfont rendering paths
- Downstream services performing text layout, quota enforcement, or buffer allocation based on Pillow text metrics
Discovery Timeline
- 2026-10-21 - CVE CVE-2026-96641 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-96641
Vulnerability Analysis
The vulnerability stems from asymmetric bounds checking in the PILfont text-width accumulation routine. The accumulator xsize is a signed C integer that sums per-glyph advance values dx. The original code validates upper-bound overflow by checking positive advances against INT_MAX but omits the corresponding lower-bound check against INT_MIN.
Glyph advance values are signed 16-bit integers, meaning each dx can be as small as -32768. An attacker who supplies a font or text input containing repeated maximally-negative advances can drive the signed accumulator below INT_MIN. The result is undefined behavior in C that commonly manifests as wraparound to a large positive value.
Downstream code treats the resulting width as a legitimate measurement. Allocation routines, serialization buffers, and quota enforcement checks then operate on corrupted dimensions. The high-level mask path retains a decompression-bomb check that limits the worst-case rendering impact, but logic-integrity errors persist in any caller that trusts the returned width.
Root Cause
The root cause is incomplete signed integer overflow validation in src/_imaging.c. The accumulation loop guards against positive overflow but ignores the symmetric negative-overflow case, violating the invariant that both bounds of a signed accumulator must be checked when inputs can be negative.
Attack Vector
Exploitation requires user interaction to process attacker-controlled font or text data through Pillow's PILfont APIs. A remote attacker can deliver a crafted font or text payload to any service that calls getlength() or getsize(). The impact is limited to availability and logic integrity; confidentiality and integrity of unrelated data are not directly affected.
// Security patch in src/_imaging.c - Raise OverflowError if text width goes below INT_MIN (#10010)
PyErr_SetString(PyExc_OverflowError, "Width too large");
return -1;
}
+ if (dx < 0 && xsize < INT_MIN - dx) {
+ PyErr_SetString(PyExc_OverflowError, "Width too small");
+ return -1;
+ }
xsize += dx;
}
Source: GitHub Commit 80de4be
The patch adds the missing symmetric check: before accumulating a negative dx, it verifies that the subtraction would not drive xsize below INT_MIN, raising a Python OverflowError if the bound would be violated.
Detection Methods for CVE-2026-96641
Indicators of Compromise
- Unhandled Python exceptions originating from PIL._imaging text rendering functions on previously stable workloads
- Anomalous memory allocation requests or out-of-memory errors in services processing user-supplied fonts or text
- Unexpectedly large text dimensions returned by getlength() or getsize() for short input strings
Detection Strategies
- Inventory Python environments and container images to identify Pillow versions prior to 13.0.0 using dependency scanners such as pip-audit or SCA tooling
- Instrument applications that call PILfont APIs to log inputs producing anomalously large width values
- Monitor web-facing services that accept font uploads or custom text rendering for repeated requests containing non-standard glyph advance patterns
Monitoring Recommendations
- Alert on process-level memory spikes in workers handling image or text rendering jobs
- Track frequency of OverflowError exceptions originating from Pillow after patching, which may indicate ongoing exploitation attempts
- Review application logs for crashes or restarts correlating with font or text-processing requests
How to Mitigate CVE-2026-96641
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later across all Python environments, container images, and build pipelines
- Audit application code paths that call getlength(), getsize(), or custom PILfont rendering for attacker-controlled font or text inputs
- Enforce input validation on font files and text payloads before passing them to Pillow
Patch Information
The fix is included in Pillow 13.0.0. The patch adds a bounds check against INT_MIN in the text-width accumulation loop in src/_imaging.c. Full details are available in the GitHub Security Advisory GHSA-4rm8-3hmm-39fg, Pillow Release 13.0.0 notes, and GitHub Pull Request #10010.
Workarounds
- Restrict Pillow text and font processing to trusted, pre-validated inputs where upgrading is not immediately feasible
- Impose resource limits such as RLIMIT_AS or container memory caps on worker processes handling image rendering
- Reject font files containing glyph advance values at or near the signed 16-bit minimum during input preprocessing
# Configuration example - upgrade Pillow and verify version
pip install --upgrade 'Pillow>=13.0.0'
python -c "import PIL; print(PIL.__version__)"
# Audit installed packages for vulnerable versions
pip-audit --vulnerability-service osv
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

