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-112901 Overview
CVE-2026-112901 is a regular expression denial of service (ReDoS) vulnerability in Pillow, the widely used Python imaging library. The flaw resides in the X BitMap (XBM) header parser within XbmImageFile._open. When an application calls Image.open() on a small crafted XBM file, XbmImagePlugin applies a backtracking regular expression to attacker-controlled header content before image dimensions are validated. A worker thread can stall for minutes on a few hundred bytes of input, denying service to legitimate requests. The issue affects all Pillow versions prior to 13.0.0 and is tracked under [CWE-1333] (Inefficient Regular Expression Complexity).
Critical Impact
A single malicious XBM upload can exhaust a worker process, degrading availability of any application that opens untrusted images with Pillow.
Affected Products
- Pillow versions prior to 13.0.0
- Python applications that call Image.open() on untrusted XBM input
- Image-processing pipelines and web services relying on Pillow for user-supplied uploads
Discovery Timeline
- 2026-10-19 - CVE-2026-112901 published to NVD
- 2026-10-20 - Last updated in NVD database
Technical Details for CVE-2026-112901
Vulnerability Analysis
The XBM format uses a C-style header beginning with #define directives that declare image dimensions. The legacy parser in XbmImagePlugin applied a regular expression with backtracking behavior across the entire attacker-supplied header before validating or accepting dimensions. Crafted input that includes repetitive, ambiguous character sequences forces the regex engine into catastrophic backtracking.
The result is a single-request CPU exhaustion condition. A worker thread blocks for minutes on an input of only a few hundred bytes. Services that process user-uploaded images with Pillow — thumbnailers, avatar handlers, document converters, and ingestion pipelines — can be stalled with minimal attacker effort.
Root Cause
The root cause is the use of a backtracking regular expression against untrusted header data prior to dimension validation. Because parsing precedes any sanity check, the attacker controls both the input length and its structural ambiguity. The fix in version 13.0.0 replaces regex-based parsing with line-by-line reads of the XBM header, eliminating the backtracking surface entirely.
Attack Vector
Exploitation requires only the ability to supply an XBM file to a process that calls Image.open(). No authentication, user interaction, or elevated privileges are needed when the target is a network-reachable image handler. Repeated submissions amplify the impact into a sustained denial of service against the hosting application.
# Security patch in src/PIL/XbmImagePlugin.py
# Read XBM header line by line, instead of through regex (#10109)
def _accept(prefix: bytes) -> bool:
- return prefix.lstrip().startswith(b"#define")
+ return prefix.startswith((b"#define", b"\n#define"))
Source: GitHub Pillow Commit 2852a3e
Detection Methods for CVE-2026-112901
Indicators of Compromise
- Sustained high CPU usage in Python worker processes that handle image uploads, correlated with requests containing XBM content.
- Request timeouts, 502/504 responses, or thread pool exhaustion on image-processing endpoints.
- XBM files in upload directories whose header contains unusually long or repetitive sequences before any #define width directive.
Detection Strategies
- Inventory Python environments for Pillow versions prior to 13.0.0 using pip list or software composition analysis tooling.
- Instrument image-handling functions with per-request CPU and wall-clock timers to flag parsing operations that exceed normal bounds.
- Add file-type and content inspection at the ingestion layer to log or block XBM content when it is not a supported format for the application.
Monitoring Recommendations
- Alert on process-level CPU saturation lasting more than a few seconds in image-processing workers.
- Track upload endpoint latency distributions and alert on tail-latency regressions tied to specific MIME types.
- Capture and retain samples of inputs that trigger parser timeouts for offline analysis.
How to Mitigate CVE-2026-112901
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later in all production and development environments.
- Reject XBM uploads at the application gateway if the format is not required by the application.
- Enforce strict request timeouts and CPU limits on worker processes that call Image.open().
Patch Information
The fix is included in Pillow 13.0.0. The parser now reads the XBM header line by line instead of applying a backtracking regex. See the GitHub Pillow Security Advisory GHSA-xgh8-jp6q-p5x8 and the GitHub Pillow Release 13.0.0 notes for the full change set.
Workarounds
- Restrict accepted image formats using an allowlist and drop XBM before it reaches Pillow.
- Run image parsing in a sandboxed subprocess with hard CPU and memory ceilings so a stalled worker cannot affect the main service.
- Validate file size and header structure before invoking Image.open() on untrusted content.
# Upgrade Pillow to the patched release
pip install --upgrade "Pillow>=13.0.0"
# Verify the installed version
python -c "import PIL; print(PIL.__version__)"
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

