PyPI: pillow
CVE-2026-112393
Safety vulnerability ID: SFTY-20261021-13350
Affected versions of the Pillow package are vulnerable to Heap-based Buffer Overflow due to incorrect buffer size calculation when writing TIFF data to in-memory targets. The `_tiffWriteProc` function in `src/libImaging/TiffDecode.c` sizes its `realloc()` call using `state->size + size` instead of the actual write position `state->loc + size`, so when libtiff seeks past the end of the current buffer (as it does while writing directory entries and out-of-line tag values) and then writes, the resulting `memcpy` can copy data past the end of the reallocated heap block; the same flaw also leaves the skipped-over padding bytes uninitialized, leaking stale heap memory into the output file. An attacker who can get an application to open an attacker-supplied TIFF (or one with a crafted ImageDescription, DocumentName, XMP packet, or embedded ICC profile) and re-save it as TIFF to a non-file target such as `io.BytesIO` can trigger an out-of-bounds heap write using attacker-controlled tag data, causing a crash via heap corruption, disclosure of adjacent heap memory in the generated file, and, as demonstrated, remote code execution when combined with a separate heap address disclosure.
Overview
Pillow: Heap buffer overflow in _tiffWriteProc when saving TIFF to BytesIO
Advisory
pillow – Heap-based Buffer Overflow
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20261021-13350/CVE-2026-112393
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-332p-7hrc-92wf
- https://nvd.nist.gov/vuln/detail/CVE-2026-112393
- https://github.com/python-pillow/Pillow/commit/11582e5ffbdceb973d5ee593f3105af5a9852b40
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/advisories/GHSA-332p-7hrc-92wf
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
