PyPI: pillow

CVE-2026-112394

Safety vulnerability ID: SFTY-20261021-49711

Affected versions of the Pillow package are vulnerable to Buffer Over-read due to a mismatch between the bounds check used by the raw decoder and the actual memory footprint required by the bit-plane unpackers. `ImagingRawDecode` computes the per-line byte count as `(xsize * bits + 7) / 8` and uses this value both to validate the input buffer size and to advance between lines, whereas the `unpackP2L` and `unpackP4L` unpackers treat `P;2L` and `P;4L` data as 2 or 4 separate bit planes, each independently padded to a whole byte via `s = (pixels + 7) / 8`, making their true required size larger than what the decoder accounts for in certain width values such as 1. An attacker can exploit this by supplying a crafted buffer to `Image.frombytes()` or `Image.frombuffer()` with the `P;2L` or `P;4L` raw mode and a susceptible width/height, causing the unpackers to read 1 to 3 bytes past the end of the allocated buffer, which can leak adjacent heap memory into decoded pixel data or crash the process if the overread reaches unmapped memory.

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

Overview

Pillow: P;2L and P;4L decoders may read 1 to 3 bytes past the passed buffer size

Advisory

pillow – Buffer Over-read

Affected Package

Affecting pillow package, versions<= 12.3.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