Skip to main content
Vulnerability Database/CVE-2026-112398

CVE-2026-112398: Pillow FlashPix JPEG RCE Vulnerability

CVE-2026-112398 is a remote code execution vulnerability in Pillow Python imaging library affecting FlashPix JPEG-tile decoder. Attackers can exploit heap corruption via crafted OLE2 files to execute arbitrary code. This article covers technical details, affected versions, impact analysis, and mitigation strategies.

Published:

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-112398 Overview

CVE-2026-112398 is a heap buffer overflow [CWE-122] in the Pillow Python imaging library affecting all versions prior to 13.0.0. The flaw lives in the FlashPix (FPX) JPEG-tile decoder, where the raw mode is selected as LA with two bytes per pixel. When an unrecognized JPEG mode is decoded as JCS_UNKNOWN with four components, ImagingJpegDecode writes four-component scanlines into a two-byte tile buffer. An attacker who supplies a crafted OLE2 FlashPix file to an application with the optional olefile dependency installed can corrupt heap memory and potentially achieve arbitrary code execution.

Critical Impact

Opening or thumbnailing an untrusted FlashPix image through Pillow with olefile installed can lead to heap corruption and remote code execution in the host application.

Affected Products

  • Pillow versions prior to 13.0.0
  • Python applications that open or thumbnail untrusted images via Pillow
  • Deployments where the optional olefile dependency is installed alongside Pillow

Discovery Timeline

  • 2026-10-19 - CVE-2026-112398 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-112398

Vulnerability Analysis

Pillow's FlashPix plugin reads JPEG-compressed tiles embedded in an OLE2 FPX container. The decoder prepares a scanline buffer sized from the tile extents and the chosen unpacker, not from the JPEG stream's own header. The FPX code path hardcodes the raw mode to LA, which allocates two bytes per pixel.

When libjpeg encounters a JPEG with an unrecognized color space, it falls back to JCS_UNKNOWN and reports four components per pixel. ImagingJpegDecode then writes four bytes per pixel into a buffer sized for two, overflowing the heap-allocated tile buffer. The out-of-bounds write corrupts adjacent heap metadata and allocations, which an attacker can shape to redirect control flow.

Root Cause

The decoder trusts the raw-mode sizing derived from the FPX plugin instead of validating it against the actual JPEG header. There is no reconciliation between cinfo.output_width, cinfo.output_components, and the destination buffer's byte capacity before writes begin. Any JPEG that libjpeg classifies as JCS_UNKNOWN with more components than the raw mode expects will overflow.

Attack Vector

Exploitation requires an application built on Pillow to open or generate a thumbnail from an attacker-supplied FPX file, and the optional olefile package must be present. Common exposure includes web upload handlers, document processors, chat and mail attachment previews, and image pipelines. The attack vector is network-reachable where applications accept untrusted image uploads.

c
                break;
            }

+           /* The scanline buffer was sized from the tile extents and the
+              unpacker, not from the JPEG header, so make sure the lines
+              libjpeg is about to produce actually fit in it. */
+           if (context->cinfo.output_width > (JDIMENSION)state->xsize ||
+               (size_t)context->cinfo.output_components * context->cinfo.output_width >
+                   (size_t)state->bytes) {
+               jpeg_destroy_decompress(&context->cinfo);
+               state->errcode = IMAGING_CODEC_BROKEN;
+               return -1;
+           }
+
            state->state++;
            /* fall through */

Source: Pillow commit 242a059. The patch rejects JPEG streams whose scanlines are wider or carry more components than the destination tile buffer can hold, returning IMAGING_CODEC_BROKEN instead of writing past the allocation.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-112398

Indicators of Compromise

  • Python worker processes crashing with SIGSEGV, SIGABRT, or glibc heap corruption messages shortly after processing user-uploaded images
  • FPX or OLE2 files appearing in upload directories where only common web image formats are expected
  • Unexpected child processes or outbound connections spawned by image-processing workers

Detection Strategies

  • Inventory Python environments for Pillow versions below 13.0.0 with olefile co-installed using pip list or SBOM tooling
  • Add file-type scanning at upload boundaries to flag FPX and OLE2 compound documents masquerading as images
  • Run image-processing workloads under AddressSanitizer or heap hardening in staging to surface overflow attempts during fuzz testing

Monitoring Recommendations

  • Alert on repeated crashes, restarts, or OOM events in services that invoke PIL.Image.open or Image.thumbnail
  • Capture process telemetry on image-worker hosts, including unexpected execve, shell invocations, and network egress from Python runtimes
  • Correlate web-server upload logs with downstream processing errors to identify crafted payloads targeting the FPX decoder

How to Mitigate CVE-2026-112398

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later across all Python environments
  • If upgrade is not immediate, uninstall the optional olefile dependency to disable FPX decoding
  • Reject FPX and OLE2 compound files at upload ingress until patched builds are deployed

Patch Information

The fix is included in Pillow 13.0.0. See the Pillow 13.0.0 release notes and the GHSA-5x8w-8jj5-q52h advisory. The upstream patch in commit 242a059 validates cinfo.output_width and cinfo.output_components against the destination buffer before any scanline is written.

Workarounds

  • Remove olefile from the runtime environment, which prevents Pillow from registering the FPX plugin
  • Restrict accepted MIME types and file magic to formats actually required by the application
  • Isolate image decoding in a sandboxed worker with seccomp or a container limited to read-only filesystem and no network access
bash
# Upgrade Pillow to the patched release
pip install --upgrade "Pillow>=13.0.0"

# Temporary mitigation: remove the optional FPX dependency
pip uninstall -y olefile

# Verify installed versions
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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.