PyPI: pillow

CVE-2026-112402

Safety vulnerability ID: SFTY-20261021-43268

Affected versions of the Pillow package are vulnerable to Use After Free (CWE-416) due to `ImagingScaleAffine()` deleting an `Imaging` structure it does not own when its internal allocation fails. When `calloc()` for the per-column lookup table fails inside `ImagingScaleAffine()` in `src/libImaging/Geometry.c`, the function calls `ImagingDelete(imOut)` even though, when reached via `Image.transform()`, `imOut` is the struct backing a live Python `ImagingCore` object; `_dealloc()` in `src/_imaging.c` subsequently calls `ImagingDelete()` on the same struct again, writing to and freeing already-freed memory. An attacker who can control the output size passed to `Image.transform()` (via `Transform.EXTENT` or `Transform.AFFINE` with a pure scale/translate matrix and default NEAREST resampling) can request a very wide, single-row output so that the output image allocates successfully while the larger lookup table allocation fails, triggering the double free and crashing the worker process with corrupted heap state, which is especially reachable on workers constrained by an address-space limit (`ulimit -v`, `uwsgi --limit-as`, `systemd LimitAS=`) or on 32-bit processes.

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

Overview

Pillow: Double free in ImagingScaleAffine on calloc failure via Image.transform

Advisory

pillow – Use After Free

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