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

Published Oct 21, 2026
·
Updated

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.

Other sources

Pillow is a Python imaging library. Prior to 13.0.0 on Windows, src/PIL/WmfImagePlugin.py passes unchecked 32-bit WMF or EMF dimensions to the native drawwmf handler in src/display.c. The handler sizes a DIB allocation from 16-bit-truncated bcWidth and bcHeight fields but copies pixel data using the original full dimensions. A crafted wide, short metafile can pass the pixel-count decompression-bomb check and make the Windows-only renderer read beyond the heap buffer, potentially disclosing memory or crashing the process. This issue is fixed in version 13.0.0.

— MITRE

Affected Software

9 affected componentsFixes available
pypi/Pillow<13.0.0
pip/pillow<13.0.0
13.0.0
All of the following
Python Pillow<13.0.0
Microsoft Windows
bitnami/pillow<13.0.0
13.0.0
pip/pillow<13.0.0
13.0.0
ubuntu/pillow-python2*
IBM App Connect Operator<=CD: 12.1.0 - 12.21.0 12.0 LTS: 12.0.0 - 12.0.28 13 LTS: 13.0.0 - 13.6.0
IBM App Connect EnterpriseCertified Containers Operands<=CD: 12.0.11.1-r1 - 12.0.12.5-r1, 13.0.1.0-r1 - 13.0.6.2-r1 12.0 LTS: 12.0.12-r1 - 12.0.12-r28 13 LTS: 13.0.7.0-r1 - 13.0.9.0-r1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/Pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0
  2. Upgrade

    Upgrade bitnami/pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0
  3. Upgrade

    Upgrade pip/pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0
  4. Upgrade

    Upgrade Pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0

Event History

Oct 21, 2026
CVE Published
via MITRE·08:54 PM
Data Sourced
via MITRE·08:54 PM
DescriptionWeakness
Data Sourced
via OSV·08:54 PM
DescriptionSeverityWeakness
Advisory Published
via OSV·09:20 PM
Data Sourced
via NVD·09:20 PM
RemedyDescriptionSeverityWeaknessAffected Software
Oct 22, 2026
Advisory Published
via GitHub·04:03 PM
Data Sourced
via GitHub·04:03 PM
DescriptionWeaknessAffected Software
Nov 4, 2026
Data Sourced
via OSV·03:30 AM
Affected Software
Nov 9, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

Which deployments are affected?

The issue affects Pillow versions before 13.0.0 when running on Windows. The vulnerable path is the Windows-only WMF/EMF renderer; non-Windows builds are not described as affected.

2

What does an attacker need to exploit this?

An attacker needs to cause the application to render a crafted WMF or EMF metafile. The malicious file uses wide, short dimensions that bypass the pixel-count decompression-bomb check while triggering the mismatched allocation and copy sizes.

3

What is the likely impact?

The renderer can read beyond a heap buffer, which may disclose process memory or crash the process. The provided information does not establish code execution.

4

What should be done if an immediate upgrade is not possible?

Avoid rendering untrusted WMF and EMF files on Windows until Pillow can be upgraded. Version 13.0.0 contains the fix.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203