Skip to content
Wednesday, October 21, 2026AboutContactRSS
Pillow FlashPix Heap Corruption Allows Code Execution in Python Apps
Vulnerabilities

Pillow FlashPix Heap Corruption Allows Code Execution in Python Apps

A crafted FlashPix file can crash or control Python applications using Pillow versions prior to 13.0.0 by overflowing memory buffers during image decoding.

Key points

  • CVE-2026-112398 allows arbitrary code execution via heap corruption in Pillow's FlashPix decoder.
  • The flaw affects Pillow versions prior to 13.0.0 and requires the optional olefile dependency.
  • Attackers supply a crafted OLE2 FlashPix file to trigger the buffer overflow during thumbnailing.

Python applications using the Pillow imaging library face a critical risk from a heap corruption flaw in its FlashPix decoder. The vulnerability, tracked as CVE-2026-112398, allows attackers to execute arbitrary code by supplying a specially crafted image file. This issue impacts all Pillow versions prior to 13.0.0. The National Vulnerability Database rates the flaw as critical with a CVSS score of 9.2. The bug stems from how the library handles memory allocation when decoding specific image formats.

Root cause

The vulnerability exists within Pillow's handling of FlashPix JPEG tiles. According to the NVD record, the decoder allocates a buffer based on the expectation of two bytes per pixel for the LA raw mode. However, if an unrecognized JPEG mode is encountered, the system decodes the data as JCS_UNKNOWN with four components. This mismatch causes the ImagingJpegDecode function to write four-component scanlines into the smaller, two-byte tile buffer. The result is a write beyond the allocated buffer, leading to heap memory corruption.

Attack path

An attacker must supply a crafted OLE2 FlashPix file to a vulnerable application. The target application must have the optional olefile dependency installed to process the file format. The flaw is triggered when the application opens or generates thumbnails for untrusted input containing the malicious file. The heap corruption caused by the buffer overflow can then be leveraged to execute arbitrary code on the host system. This means any service that automatically previews or processes uploaded images is potentially exposed to remote code execution.

Affected versions

  • Pillow versions prior to 13.0.0 are affected by this vulnerability.
  • The issue is fixed in version 13.0.0.
  • The vulnerability requires the optional olefile dependency to be active in the application environment.

Mitigation

  • Upgrade Pillow to version 13.0.0 or later to resolve the heap corruption issue.
  • Remove the optional olefile dependency if FlashPix support is not required by the application.
  • Validate and sanitize all image inputs before processing them with the library.
  • Restrict image processing services to trusted inputs only to reduce the attack surface.

Signals worth monitoring

Security operations teams should monitor for unexpected process crashes or segmentation faults in applications handling image uploads. Watch for anomalous outbound network connections from image processing services, which may indicate command-and-control communication after exploitation. Check logs for attempts to load or process unusual file extensions like FPX. Verify that image parsing errors are logged and not silently ignored. Ensure that sandboxing or container isolation is enforced for services handling untrusted media files to limit the impact of potential code execution.

What to do and how to stay safe: Pillow

  • Audit your Python dependencies to identify if Pillow versions prior to 13.0.0 are installed in production environments.
  • Verify whether your applications use the optional olefile dependency, which is required for this specific attack vector.
  • Implement strict input validation to reject files with unexpected headers or structures before they reach the image decoder.
  • Set up automated alerts for crashes in image processing services to detect potential exploitation attempts early.

Step-by-step guide: Attack Surface Management: 6 Common Misreadings and Correct Views

General security guidance from the NetSec Observer newsroom. It is not confirmed advice from the organisations named in this story.

Frequently asked questions

What is the CVSS score for CVE-2026-112398?

The National Vulnerability Database rates CVE-2026-112398 as critical with a CVSS score of 9.2.

Does this vulnerability require user interaction?

The vulnerability is triggered when an application opens or thumbnails a crafted file, which may happen automatically in some services.

Which CWEs are associated with this flaw?

The flaw is associated with CWE-122 (Heap-based Buffer Overflow) and CWE-787 (Out-of-bounds Write).

Sources

  1. CVE Program
PillowCVE-2026-112398PythonHeap CorruptionFlashPix

Related stories