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.
Overview
Pillow: P;2L and P;4L decoders may read 1 to 3 bytes past the passed buffer size
Advisory
pillow – Buffer Over-read
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20261021-49711/CVE-2026-112394
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-4558-3h8r-v8xp
- https://nvd.nist.gov/vuln/detail/CVE-2026-112394
- https://github.com/python-pillow/Pillow/pull/9723
- https://github.com/python-pillow/Pillow/commit/392ee6f0d19a4adb766a63e9a99f3c28193b8d31
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/advisories/GHSA-4558-3h8r-v8xp
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
