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-112402 Overview
CVE-2026-112402 is a double free vulnerability in Pillow, the widely used Python imaging library. The flaw affects versions prior to 13.0.0 and resides in the ImagingScaleAffine fast path used by Image.transform() operations. When the output image allocation succeeds but a subsequent per-column lookup table allocation fails, the error path releases image storage that later cleanup also releases. An attacker who can drive a large Image.transform() call under memory pressure may trigger a process crash or memory corruption. The issue is tracked as CWE-416 and resolved in Pillow 13.0.0.
Critical Impact
Remote attackers who control image transform parameters can crash Python processes using Pillow and potentially corrupt memory on affected hosts.
Affected Products
- Pillow versions prior to 13.0.0
- Python applications using Image.transform() with Transform.EXTENT or scale-and-translate Transform.AFFINE
- Services performing image resampling with the default NEAREST filter on untrusted input
Discovery Timeline
- 2026-10-19 - CVE-2026-112402 published to NVD
- 2026-10-20 - Last updated in NVD database
Technical Details for CVE-2026-112402
Vulnerability Analysis
The flaw is a double free (CWE-416) in Pillow's C extension that handles affine transforms. Pillow exposes Image.transform() for geometric operations such as rotation, scaling, and extent cropping. When a transform resolves to a pure scale-and-translate affine with NEAREST resampling, Pillow dispatches to the optimized ImagingScaleAffine fast path in src/libImaging/Geometry.c. Inside this path, Pillow first allocates the output image through ImagingNewDirty, then allocates an auxiliary per-column index table xintab via calloc. If the output allocation succeeds but the xintab allocation fails under memory pressure, the error branch calls ImagingDelete(imOut) on the output image. Control then returns to the caller in src/_imaging.c, which treats the pointer as still valid and later releases it again, producing the double free.
Root Cause
The root cause is inconsistent ownership of the imOut buffer across the error path. The scaling helper takes responsibility for freeing imOut on an allocation failure, while the calling code also frees it during normal cleanup. The fix removes the premature ImagingDelete(imOut) from ImagingScaleAffine and introduces explicit error checking in the caller so that cleanup happens exactly once.
Attack Vector
Exploitation requires the attacker to influence the dimensions passed to Image.transform() and to apply enough memory pressure that the secondary calloc fails while the primary ImagingNewDirty succeeds. In network-facing services that accept user-supplied image dimensions or transformation parameters, this condition can be reached remotely without authentication. The immediate consequence is process termination; memory corruption with potential for further impact is possible depending on allocator behavior.
// Patch excerpt — src/libImaging/Geometry.c
/* malloc check ok, uses calloc for overflow */
xintab = (int *)calloc(out_xsize, sizeof(int));
if (!xintab) {
- ImagingDelete(imOut);
ImagingError_MemoryError();
return -1;
}
// Patch excerpt — src/_imaging.c
a[5] = box[1];
imOut = ImagingNewDirty(imIn->mode, xsize, ysize);
+if (!imOut) {
+ return NULL;
+}
-ImagingTransform(
- imOut, imIn, IMAGING_TRANSFORM_AFFINE, 0, 0, xsize, ysize, a, filter, 1
-);
+if (ImagingTransform(
+ imOut, imIn, IMAGING_TRANSFORM_AFFINE, 0, 0, xsize, ysize, a, filter, 1
+ )) {
+ ImagingDelete(imOut);
+ return NULL;
+}
Source: python-pillow/Pillow commit aafa6c75
Detection Methods for CVE-2026-112402
Indicators of Compromise
- Unexpected crashes or SIGABRT signals from Python worker processes that import PIL or Pillow
- MemoryError entries in application logs correlated with Image.transform() calls on large dimensions
- Glibc diagnostics such as double free or corruption in container or systemd journal output for Pillow-based services
Detection Strategies
- Inventory Python environments and container images for Pillow versions below 13.0.0 using pip list or SBOM analysis
- Instrument web endpoints that accept image uploads or transformation parameters to log output dimensions and resampling filter
- Enable allocator diagnostics such as MALLOC_CHECK_=3 or AddressSanitizer in test environments to confirm the double free path
Monitoring Recommendations
- Alert on repeated crash-restart cycles in services that process user-supplied imagery
- Track memory pressure and OOM-killer events on hosts running Pillow workloads
- Review access logs for abnormally large width or height parameters submitted to image processing APIs
How to Mitigate CVE-2026-112402
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later in all Python environments, containers, and virtualenvs
- Rebuild and redeploy container images that pin Pillow as a transitive dependency
- Audit application code paths that call Image.transform() with attacker-controlled dimensions or affine parameters
Patch Information
The fix is shipped in Pillow 13.0.0 and described in GitHub Security Advisory GHSA-7mwm-ghpf-9vrm. The patch removes the premature ImagingDelete in ImagingScaleAffine and adds explicit error handling in _imaging.c so that imOut is freed exactly once.
Workarounds
- Validate and cap image dimensions before calling Image.transform() to reduce the chance of allocation failure
- Reject or sanitize transformation parameters that resolve to extremely large output images
- Isolate image processing in sandboxed worker processes so that a crash does not affect the parent service
# Upgrade Pillow to the fixed release
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

