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

CVE-2026-96644: Pillow Buffer Overflow Vulnerability

CVE-2026-96644 is a buffer overflow vulnerability in Pillow Python imaging library affecting Windows systems. Attackers can exploit improper dimension handling to read beyond heap buffers. 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-96644 Overview

CVE-2026-96644 is an out-of-bounds read vulnerability [CWE-125] in the Pillow Python imaging library on Windows. Versions prior to 13.0.0 fail to validate 32-bit WMF (Windows Metafile) and EMF (Enhanced Metafile) dimensions in src/PIL/WmfImagePlugin.py before passing them to the native drawwmf handler in src/display.c. The native handler allocates a Device-Independent Bitmap (DIB) using 16-bit-truncated bcWidth and bcHeight fields but copies pixel data using the untruncated full dimensions. A crafted wide, short metafile bypasses the decompression-bomb pixel-count check and triggers a heap buffer over-read.

Critical Impact

Processing an attacker-supplied WMF or EMF file in Pillow on Windows can disclose adjacent heap memory or crash the Python process.

Affected Products

  • Pillow versions prior to 13.0.0 (Windows platform only)
  • Python applications using PIL.WmfImagePlugin to parse WMF or EMF files
  • Image processing pipelines on Windows that ingest untrusted metafile input

Discovery Timeline

  • 2026-10-21 - CVE-2026-96644 published to the National Vulnerability Database
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-96644

Vulnerability Analysis

The flaw sits at the boundary between Pillow's Python-side metafile parser and its native C renderer. WmfImagePlugin.py accepts 32-bit width and height values from a WMF or EMF header without range checking. These values are then passed to drawwmf in src/display.c, which stores them into the bcWidth and bcHeight fields of a BITMAPCOREHEADER structure. Those fields are 16-bit WORDs, so assignment silently truncates the upper bits.

The DIB allocation is sized from the truncated 16-bit values, while the subsequent PyBytes_FromStringAndSize buffer read uses the original full 32-bit dimensions. The size mismatch produces a heap buffer over-read. The existing decompression-bomb check validates total pixel count, so a wide-but-short image (for example width 0x1_0000 and height 1) passes the check while still triggering truncation.

Root Cause

The root cause is numeric truncation at a type boundary combined with inconsistent use of the pre- and post-truncation values. The allocation uses truncated sizes; the copy uses full sizes. No validation rejects dimensions that would not round-trip through a 16-bit unsigned field.

Attack Vector

Exploitation requires a victim to load a crafted WMF or EMF file through Pillow on Windows. User interaction is required, typically opening or processing an attacker-supplied image. The impact is limited to information disclosure of adjacent heap memory or a process crash. The non-Windows code paths are not affected.

c
/* Patch in src/display.c - reject dimensions that would truncate
 * when assigned to BITMAPCOREHEADER's 16-bit bcWidth/bcHeight fields */
if (width <= 0 || height <= 0 || width > 65535 || height > 65535) {
    PyErr_SetString(PyExc_ValueError, "invalid dimensions");
    return NULL;
}

/* step 1: copy metafile contents into METAFILE object */
if (datasize > 22 && GET32(data, 0) == 0x9ac6cdd7) {

Source: GitHub Commit 4cf46be

Detection Methods for CVE-2026-96644

Indicators of Compromise

  • Unhandled ValueError: invalid dimensions exceptions raised from PIL.WmfImagePlugin on Windows hosts after patching
  • Python process crashes or access violations in _imaging or display handler modules when processing .wmf or .emf files
  • Inbound WMF or EMF files with header width or height values exceeding 65535 pixels

Detection Strategies

  • Inventory Windows systems running Python with Pillow installed and compare against version 13.0.0 using pip show Pillow
  • Inspect WMF and EMF files received through upload portals, email gateways, or document processors for oversized dimension fields
  • Review application logs for repeated image parsing failures tied to specific client sources

Monitoring Recommendations

  • Monitor Windows image processing services for abnormal memory reads, segmentation faults, or Python crash dumps
  • Alert on new or unknown WMF or EMF files written to directories consumed by Pillow-based workers
  • Track outbound data volumes from image processing hosts to detect staged exfiltration following memory disclosure

How to Mitigate CVE-2026-96644

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later on all Windows systems: pip install --upgrade "Pillow>=13.0.0"
  • Audit application dependency manifests, container images, and virtual environments for pinned Pillow versions below 13.0.0
  • Block ingestion of WMF and EMF files from untrusted sources until patching is complete

Patch Information

The fix is included in Pillow 13.0.0 via pull request #10120 and commit 4cf46be. The patch rejects WMF and EMF dimensions that fall outside the 0 to 65535 range before any native allocation occurs. See GHSA-9v9v-9qvf-h2hj for the full advisory.

Workarounds

  • Disable WMF and EMF handling by removing or not registering PIL.WmfImagePlugin in applications that do not require metafile support
  • Validate image dimensions out-of-band before passing files to Pillow, rejecting any WMF or EMF with width or height greater than 65535
  • Run image processing in sandboxed, low-privilege Windows worker processes to contain disclosure and crash impact
bash
# Verify installed Pillow version and upgrade on Windows
python -m pip show Pillow
python -m pip install --upgrade "Pillow>=13.0.0"

# Optional: unregister the WMF plugin at application startup
python -c "from PIL import Image, WmfImagePlugin; \
  [Image.OPEN.pop(k) for k in list(Image.OPEN) if 'WMF' in k or 'EMF' in k]"

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.