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-112392 Overview
CVE-2026-112392 affects Pillow, the widely used Python imaging library, in versions prior to 13.0.0. The vulnerability resides in Pillow's rank-based image filters, which dereference invalid image storage when processing a zero-size image. The ImagingExpand() function allocates a non-empty output buffer and then faults while replicating edges by reading the first pixel from empty input storage. Any application that applies a rank, median, minimum, or maximum filter to attacker-controlled image input can be crashed. The flaw is tracked under CWE-476: NULL Pointer Dereference and is resolved in Pillow 13.0.0.
Critical Impact
Remote attackers can trigger a native process crash in any Python application that applies rank-based Pillow filters to untrusted images, leading to denial of service.
Affected Products
- Pillow versions prior to 13.0.0
- Python applications invoking ImageFilter.RankFilter, MedianFilter, MinFilter, or MaxFilter
- Downstream services and web applications that process user-supplied images through Pillow
Discovery Timeline
- 2026-10-19 - CVE-2026-112392 published to NVD
- 2026-10-20 - Last updated in NVD database
Technical Details for CVE-2026-112392
Vulnerability Analysis
The defect lives in src/libImaging/Filter.c within the ImagingExpand() helper used by rank-based filters. When a caller passes an Imaging object whose xsize or ysize is zero, ImagingExpand() still allocates an output image of size xsize + 2 * margin by ysize + 2 * margin. The function then attempts to replicate edge pixels by reading from the input image's pixel storage, which was never allocated for the zero-dimension input. The dereference of the empty storage pointer triggers a segmentation fault in the native CPython extension, terminating the process before ImagingRankFilter is ever reached.
Root Cause
The root cause is missing boundary validation for zero-dimension input in ImagingExpand(). The function assumes at least one row and column of valid pixel data exist in imIn, but Pillow permits construction of images with a zero width or height. Reading the first pixel from an unallocated row pointer produces a null or invalid pointer dereference inside the C extension.
Attack Vector
Exploitation requires an application to accept image input and apply one of the rank-family filters: RankFilter, MedianFilter, MinFilter, or MaxFilter. An attacker supplies a crafted image or triggers an application code path that constructs a zero-size image. When the filter runs, the native process crashes. On network-facing services such as image upload endpoints or thumbnail generators, this produces a denial-of-service condition.
return (Imaging)ImagingError_ValueError("filter size too large");
}
- imOut =
- ImagingNewDirty(imIn->mode, imIn->xsize + 2 * margin, imIn->ysize + 2 * margin);
+ int xsize = imIn->xsize + 2 * margin;
+ int ysize = imIn->ysize + 2 * margin;
+ if (imIn->xsize == 0 || imIn->ysize == 0) {
+ imOut = ImagingNew(imIn->mode, xsize, ysize);
+ if (!imOut) {
+ return NULL;
+ }
+ ImagingCopyPalette(imOut, imIn);
+ return imOut;
+ }
+
+ imOut = ImagingNewDirty(imIn->mode, xsize, ysize);
if (!imOut) {
return NULL;
}
Source: GitHub Pillow Commit 443e3130. The patch adds an explicit zero-dimension check and allocates a clean (ImagingNew) output rather than invoking the edge-replication path.
Detection Methods for CVE-2026-112392
Indicators of Compromise
- Unexpected SIGSEGV or abnormal termination of Python processes handling image uploads
- Repeated worker restarts or 502/504 responses from image processing microservices after specific upload events
- Application logs showing crashes inside _imaging C extension frames during RankFilter, MedianFilter, MinFilter, or MaxFilter calls
Detection Strategies
- Inventory Python environments for Pillow versions below 13.0.0 using pip list or software composition analysis tooling
- Static-scan application source for calls to ImageFilter.RankFilter, MedianFilter, MinFilter, and MaxFilter on externally sourced images
- Alert on process crash telemetry from image-processing workers that correlates with inbound upload requests
Monitoring Recommendations
- Forward Python application crash dumps and stderr output to centralized logging for correlation
- Monitor web application firewall and upload endpoint error rates for anomalous spikes tied to specific client IPs
- Track container or worker restart counts for image-processing services as a crash-loop signal
How to Mitigate CVE-2026-112392
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later across all Python environments
- Audit application code paths that pass user-supplied images into rank-family filters and reject zero-dimension inputs explicitly
- Rebuild and redeploy container images that bundle a vulnerable Pillow release
Patch Information
The fix is included in Pillow 13.0.0, released upstream with commit 443e3130a8c11594fd0e296afad497e11e678961. Install the fixed release with pip install --upgrade "Pillow>=13.0.0". Review the GitHub Security Advisory GHSA-27h8-gf7j-v5hc and the Pillow 13.0.0 release notes for the complete change set.
Workarounds
- Validate image dimensions before invoking any filter: reject images where width == 0 or height == 0
- Wrap filter calls in exception handlers and run image processing in isolated worker processes to contain crashes
- Apply input size limits at the ingress layer to drop malformed uploads before they reach Pillow
# Pin a fixed Pillow release in requirements.txt
Pillow>=13.0.0
# Or upgrade an existing environment
python -m 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

