PyPI: pillow

CVE-2026-112396

Safety vulnerability ID: SFTY-20261021-53359

Affected versions of the Pillow package are vulnerable to Use After Free due to improper cleanup when libtiff rejects a tag during TIFF encoding to an in-memory buffer. In `ImagingLibTiffEncode`, when `TIFFWriteScanline` fails, the function frees `clientstate->data` but leaves `clientstate->tiff` open and non-null, so subsequent teardown via `ImagingLibTiffEncodeCleanup` calls `TIFFClose`, which flushes buffered data through `_tiffWriteProc` and reallocs/memcpys into the already-freed buffer. An attacker can exploit this by supplying a crafted image with an invalid TIFF tag (such as Predictor=3 on integer sample data) that causes encoding to an in-memory target like `BytesIO` to fail, triggering a write into freed heap memory that can crash the process or potentially be leveraged for remote code execution.

Created at: Oct 26, 2026Updated at: Oct 26, 2026

Overview

Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer

Advisory

pillow – Use After Free

Affected Package

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