PyPI: pillow

CVE-2026-112399

Safety vulnerability ID: SFTY-20261021-76942

Affected versions of the Pillow package are vulnerable to Memory Allocation with Excessive Size Value due to allocating a disposal buffer sized from attacker-controlled image header dimensions before the decompression bomb check executes. The `PngImageFile._seek()` method, invoked from `_open()` when an `fcTL` chunk requests `OP_BACKGROUND` (or `OP_PREVIOUS` on frame 0, which is rewritten to `OP_BACKGROUND`) disposal, calls `Image.core.fill(self.mode, self.size)` using the full IHDR-declared width and height, allocating and zero-filling the entire canvas inside the plugin factory, which runs before `Image.open()`'s `_decompression_bomb_check(im.size)` is reached. An attacker can craft a small, well-formed APNG file (as little as 126 bytes) declaring extreme IHDR dimensions with a minimal `fcTL` frame rectangle to make any application that calls `Image.open()` on untrusted input allocate and write multiple gigabytes of memory per file with no further calls such as `load()` required, causing severe memory exhaustion or an operating-system out-of-memory kill of the process, and sustained or concurrent exploitation can degrade or crash services accepting image uploads.

Created at: Oct 22, 2026Updated at: Oct 22, 2026

Overview

Pillow: APNG background disposal allocates full canvas before decompression bomb check

Advisory

pillow – Memory Allocation with Excessive Size Value

Affected Package

Affecting pillow package, versions>= 8.1.0, < 13.0.0

Also affects

---

How to Fix

Upgradepillowto13.0.0or higher.

Mitigation and Workarounds

---

Vulnerable Functions

Functions linked to known vulnerabilities.

Vulnerable function data is available for Enterprise customers

Book a call with us to see Safety in action.

Safety

Verified by Safety

Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.

Learn more