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-96638 Overview
CVE-2026-96638 is a memory-exhaustion denial-of-service vulnerability in Pillow, the widely used Python imaging library. The flaw resides in BmpRleDecoder.decode() within src/PIL/BmpImagePlugin.py and affects releases from 9.1.0 up to, but not including, 13.0.0. Crafted run-length-encoded (RLE) BMP files can trigger uncapped writes during delta escapes and absolute-mode runs, inflating the output buffer well beyond the destination length. A kilobyte-sized file with a permitted large width can expand the internal data bytearray to hundreds of megabytes. The project resolved the issue in Pillow 13.0.0. The weakness is categorized under CWE-400 (Uncontrolled Resource Consumption).
Critical Impact
A single malicious BMP file processed by an application using a vulnerable Pillow release can exhaust available memory and crash the host process.
Affected Products
- Pillow versions 9.1.0 through 12.x (prior to 13.0.0)
- Python applications that decode untrusted BMP images via Pillow
- Web services, image pipelines, and thumbnail generators built on the affected Pillow range
Discovery Timeline
- 2026-10-21 - CVE-2026-96638 published to the National Vulnerability Database
- 2026-10-22 - Last updated in the NVD database
Technical Details for CVE-2026-96638
Vulnerability Analysis
The vulnerability affects the BMP RLE decoding path in Pillow. When BmpRleDecoder.decode() processes RLE4 or RLE8 streams, it handles two expansion operations without enforcing a per-branch cap against the remaining dest_length. The first is the delta escape (0x00 0x02), which appends right + up * self.state.xsize zero bytes to shift the current pixel position. The second is absolute-mode runs, which copy literal pixel bytes from the stream. Because neither branch limits output to the space still available in the destination, a single delta can append roughly 255 image rows of zeros per iteration. Repeating this pattern with a legally parsed large xsize lets a small input file grow the data bytearray to hundreds of megabytes or more, exhausting process memory.
Root Cause
The root cause is missing bounds enforcement inside the RLE decode loop. The decoder trusted the stream's deltas and runs without comparing the growth against dest_length - len(data). There is no integer overflow or memory corruption — the pathological growth is the direct consequence of unbounded concatenation inside a decoder that accepts attacker-controlled offsets.
Attack Vector
Exploitation requires an application to decode an attacker-supplied BMP image. User interaction is involved in the sense that the victim service or user must open or process the file. No authentication or privileges are required on the target when the processing endpoint accepts uploads. Image upload endpoints, document converters, chat clients, and automated thumbnail workers are the typical exposure surfaces.
# Patched logic in src/PIL/BmpImagePlugin.py (Pillow 13.0.0)
if len(bytes_read) < 2:
break
right, up = bytes_read
- data += b"\\x00" * (right + up * self.state.xsize)
+ data += b"\\x00" * min(
+ dest_length - len(data), right + up * self.state.xsize
+ )
x = len(data) % self.state.xsize
else:
# absolute mode
Source: python-pillow/Pillow commit e7794835. The fix clamps delta expansion to the remaining destination length, preventing runaway growth.
Detection Methods for CVE-2026-96638
Indicators of Compromise
- Python worker processes terminated by the OOM killer shortly after receiving BMP uploads.
- Small BMP files (a few kilobytes) that trigger multi-hundred-megabyte memory spikes in Pillow-backed services.
- BMP headers advertising large biWidth combined with RLE4 or RLE8 compression and sequences of delta escape bytes (0x00 0x02).
Detection Strategies
- Inventory Python environments and dependency manifests (requirements.txt, poetry.lock, Pipfile.lock, SBOMs) for Pillow versions between 9.1.0 and 12.x.
- Instrument image-ingest endpoints to log file size, decoded dimensions, and peak resident memory per request for correlation.
- Add pre-decode validation that rejects BMP files whose declared width or height exceeds application limits.
Monitoring Recommendations
- Alert on repeated OOM terminations or sudden RSS growth in processes that call PIL.Image.open on user content.
- Track outbound 5xx errors and worker restarts from image-processing services, which can indicate denial-of-service attempts.
- Correlate upload telemetry with container memory limits to surface clients submitting crafted BMP payloads.
How to Mitigate CVE-2026-96638
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later across all Python environments that process untrusted images.
- Rebuild and redeploy container images, serverless functions, and virtual environments that pin an affected Pillow release.
- Enforce strict memory and CPU limits on image-processing workers so an exploitation attempt cannot destabilize shared infrastructure.
Patch Information
The fix is included in Pillow 13.0.0. The upstream commit e7794835 and pull request #10015 clamp both delta and absolute-mode expansions to the remaining dest_length. Full release notes are available in the Pillow 13.0.0 release and the vendor advisory GHSA-24rc-8hj2-v98c.
Workarounds
- Reject BMP uploads at the application edge until Pillow can be upgraded.
- Validate image dimensions and file size before invoking Pillow decoders, and refuse files declaring excessive biWidth or biHeight values.
- Isolate image decoding in a sandboxed subprocess with a hard memory ceiling (RLIMIT_AS, cgroup memory.max) so OOM events do not impact the parent service.
# Upgrade Pillow to the fixed 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

