CVE-2026-59197 Pillow: Heap out-of-bounds write in Pillow `ImageFilter.RankFilter` via integer overflow in `ImagingExpand`

High 8.2 Published Updated

An attacker can trigger a heap out-of-bounds write in Pillow's RankFilter via integer overflow, potentially leading to code execution or crashes.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2026-59197?

CVE-2026-59197 is a high-severity memory corruption vulnerability in Python Pillow, published on 14 Jul 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Pillow is a Python imaging library. Prior to 12.3.0, Pillow's public rank-filter API can trigger a native heap out-of-bounds write when given a very large odd filter size because ImageFilter.RankFilter.filter() calls image.expand(size // 2, size // 2) before rank-filter size validation and ImagingExpand() computes output dimensions with unchecked signed int arithmetic. This issue is fixed in version 12.3.0.

Weakness: CWE-787, CWE-190

Which versions are affected by CVE-2026-59197?

4 open source packages ship an affected version, including pillow and Pillow. It affects 1 product.

PackageAffectedFixed in
pillow BitnamiAll versions12.3.0
pillow PyPIAll versions12.3.0
pillow PyPIAll versions12.3.0
Pillow PyPIAll versions12.3.0

Products include Python Pillow.

How do I fix CVE-2026-59197?

Upgrade pillow to 12.3.0 or later.

Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.

Is CVE-2026-59197 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-59197 exists.

All Python Pillow vulnerabilities

Sources

Also known as BIT-pillow-2026-59197, CLSA-2026-1786966627, DEBIAN-CVE-2026-59197, ECHO-5231-1622-6e83, GHSA-xj96-63gp-2gmr, MINI-26cp-2wc6-rwh7 and 13 more.

Is CVE-2026-59197 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free