CVE-2026-112392 in Pillow
Summary
by MITRE • 10/20/2026
Pillow is a Python imaging library. Prior to 13.0.0, Pillow's rank-based filters can dereference invalid image storage for a zero-size image. ImagingExpand() allocates a non-empty output and then faults while replicating edges by reading the first pixel from empty input storage; ImagingRankFilter is never reached. An attacker can supply or cause creation of a zero-size image to an application that applies a rank, median, minimum, or maximum filter. This causes a native process crash. This issue is fixed in version 13.0.0.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 10/20/2026
The vulnerability identified involves the Pillow imaging library for Python, specifically affecting versions prior to 13.0.0. Pillow is widely used for image processing tasks such as opening, manipulating, and saving various image file formats. The specific flaw resides within the implementation of rank-based filters, which include operations like median, minimum, and maximum filtering. These filters are designed to process pixel data by evaluating neighboring pixels according to a defined ranking algorithm. However, in versions before 13.0.0, the internal logic fails to adequately handle edge cases where the input image has zero dimensions or an empty storage buffer. This oversight leads to a critical failure during the execution of these filters when applied to malformed inputs.
The technical root cause of this vulnerability lies in the function ImagingExpand and its interaction with rank-based filter implementations. When processing an image, ImagingExpand allocates memory for a non-empty output buffer regardless of the input size. Subsequently, the code attempts to replicate edges by reading pixel data from the first position of the input storage. If the input image is zero-sized, this storage is effectively empty or invalid. Attempting to read from this location results in an out-of-bounds memory access. This illegal memory operation triggers a native process crash before the actual rank filter logic, represented by ImagingRankFilter, can even be reached. The failure occurs at a low level within the C-based core of Pillow, making it difficult for higher-level Python code to catch or handle gracefully without crashing the entire application.
From an operational perspective, this vulnerability poses a significant risk to any service that accepts user-uploaded images and applies rank-based filters as part of its processing pipeline. An attacker can exploit this by supplying specially crafted image files with zero dimensions or causing the application to generate such images through other means. Upon receiving these inputs, the targeted application will crash due to the segmentation fault caused by the invalid memory dereference. This results in a denial-of-service condition for users relying on that service. In environments where Pillow is used within web servers or background processing workers, repeated exploitation can lead to resource exhaustion if not properly monitored, as crashed processes may need to be restarted, consuming system resources and potentially disrupting normal operations.
This vulnerability aligns with CWE-125, which describes Out-of-bounds Read vulnerabilities. It also relates to CWE-400, concerning Uncontrolled Resource Consumption, due to the potential for denial of service through process crashes. In terms of the MITRE ATT&CK framework, this exploitation technique falls under Tactic TA0004 Impact and specifically Technique T1499 Endpoint Denial of Service or potentially T1529 System Shutdown or Reboot if the crash leads to broader system instability in constrained environments. The attack vector is primarily classified as Network-based if images are uploaded via a web interface, but could also be Local if an attacker has direct access to trigger image processing functions within a local application context.
Mitigation strategies for this vulnerability involve immediate updates and defensive coding practices. The primary remediation is to upgrade Pillow to version 13.0.0 or later, where the developers have corrected the logic to properly handle zero-size images by either skipping invalid operations or allocating appropriate buffers based on input dimensions. For applications that cannot immediately update due to dependency constraints, implementing strict validation of image dimensions before applying filters can serve as a temporary workaround. Developers should check if an image has width and height greater than zero prior invoking rank-based filter functions. Additionally, integrating robust error handling mechanisms at the application level can help detect crashes or exceptions related to image processing and restart affected components gracefully without exposing sensitive system information to end users. Regular security audits of third-party library usage are essential to maintain resilience against such low-level memory management flaws.