PyPI: pillow
CVE-2026-112392
Safety vulnerability ID: SFTY-20261021-39022
Affected versions of the Pillow package are vulnerable to NULL Pointer Dereference due to missing validation of zero-size images before accessing pixel data. The `ImagingExpand()` function in `src/libImaging/Filter.c`, which is invoked by `RankFilter.filter()` (and therefore by `MedianFilter`, `MinFilter`, and `MaxFilter`) through the core `expand()` method, reads `imIn->image[y][0]` and the first/last rows to replicate edge pixels without checking whether the input image has any pixels, so when `ImagingAllocateArray` leaves the line pointers NULL for a zero-width or zero-height image, the first read dereferences NULL. An attacker who can supply crop coordinates with equal left/right or top/bottom edges, or an uploaded multi-page TIFF whose second IFD declares a zero `ImageLength`, can cause `Image.filter()` to be called on a zero-size image and crash the entire Python process with SIGSEGV, resulting in a Denial of Service.
Overview
Pillow: NULL dereference in ImagingExpand via rank filters on zero-size images
Advisory
pillow – NULL Pointer Dereference
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20261021-39022/CVE-2026-112392
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-27h8-gf7j-v5hc
- https://nvd.nist.gov/vuln/detail/CVE-2026-112392
- https://github.com/python-pillow/Pillow/commit/443e3130a8c11594fd0e296afad497e11e678961
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/advisories/GHSA-27h8-gf7j-v5hc
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
