CVE-2026-112398 in Pillow
Summary
by MITRE • 10/20/2026
Pillow is a Python imaging library. Prior to 13.0.0, Pillow's FlashPix JPEG-tile decoder can write decoded scanlines beyond the allocated tile buffer. FlashPix (FPX) JPEG decoding selects raw mode LA with two bytes per pixel, while an unrecognized JPEG mode can be decoded as JCS_UNKNOWN with four components, causing ImagingJpegDecode to write four-component scanlines into the two-byte tile buffer. An attacker can supply a crafted OLE2 FlashPix file to an application with the optional olefile dependency installed that opens or thumbnails untrusted input. This can corrupt heap memory and may allow arbitrary code execution. This issue is fixed in version 13.0.0.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 10/20/2026
The vulnerability identified in Pillow, a widely used Python imaging library, stems from a critical buffer overflow within the FlashPix JPEG-tile decoder component prior to version 13.0.0. The core technical flaw arises from an inconsistency between the mode selected for raw data processing and the actual number of color components present in the input stream. Specifically, when decoding FlashPix files formatted as JPEG tiles, the library initially selects a raw mode designated as LA, which allocates a tile buffer sized for two bytes per pixel to handle luminance and alpha channels. However, if the underlying JPEG decoder encounters an unrecognized or ambiguous color space mode, it may default to JCS_UNKNOWN, interpreting the image data as having four components instead of two. This discrepancy creates a scenario where the ImagingJpegDecode function proceeds to write scanlines containing four-component pixel data into a buffer that was allocated for only two-byte pixels.
This mismatch results in heap memory corruption because the decoder writes significantly more data than the allocated space can accommodate. The overflow occurs during the processing of tile-based JPEG images, which are commonly found in FlashPix (FPX) files encapsulated within OLE2 containers. For this vulnerability to be exploitable, an application must have the optional olefile dependency installed and must actively open or generate thumbnails for untrusted input files. An attacker can craft a malicious FPX file that triggers this specific decoding path, causing the heap buffer overflow when the library attempts to process the image data. The resulting memory corruption is severe enough to potentially allow arbitrary code execution if an attacker can control the contents of the overwritten memory regions and manipulate subsequent allocations or function pointers within the application's address space.
From a classification perspective, this vulnerability aligns with CWE-120, which describes buffer copy without checking size limits, specifically manifesting as a heap-based buffer overflow. The attack vector leverages the handling of external input through image parsing libraries, mapping to MITRE ATT&CK technique T1566.001, known as Spearphishing Attachment, where malicious files are delivered via email or other means to trick users into opening them in vulnerable applications such as document viewers, media players, or web browsers that utilize Pillow for thumbnail generation or image previewing. The impact extends beyond simple denial of service; the ability to corrupt heap memory provides a pathway for privilege escalation and full system compromise depending on the context in which the affected application runs.
Mitigation strategies primarily involve upgrading Pillow to version 13.0.0 or later, where this logic error has been corrected by ensuring that buffer allocations match the actual number of components determined during decoding. Organizations relying on Python-based image processing pipelines should audit their dependencies and enforce strict version control policies for imaging libraries. Additionally, applications that process untrusted images should implement additional safeguards such as input validation to verify file headers before passing them to decoders, sandboxing mechanisms to limit the impact of potential exploits, and disabling unnecessary optional dependencies like olefile if they are not strictly required by the application's functionality. Regular security assessments and static analysis tools can help identify similar mismatches in image processing codebases where buffer sizes might be calculated based on assumed rather than actual data dimensions.