CVE-2026-59197
Python vulnerability analysis and mitigation

Overview

CVE-2026-59197 is a heap out-of-bounds write vulnerability in Pillow's ImageFilter.RankFilter API, caused by an integer overflow in ImagingExpand. All versions of Pillow prior to 12.3.0 are affected, including the entire version history from 1.0 through 12.2.0. The vulnerability was disclosed on July 7, 2026 via a GitHub Security Advisory, with CVE assignment on July 14, 2026. It carries a CVSS v3.1 base score of 8.2 (High) (GitHub Advisory, Red Hat Bugzilla).

Technical details

The root cause is a combination of CWE-190 (Integer Overflow or Wraparound) and CWE-787 (Out-of-bounds Write). ImageFilter.RankFilter.filter() calls image.expand(size // 2, size // 2) before validating the filter size; when a very large odd value such as 4294967295 (0xFFFFFFFF) is supplied, the expansion margin becomes 2147483647 (INT_MAX). The native C function ImagingExpand() in src/libImaging/Filter.c then computes output image dimensions using unchecked signed integer arithmetic, causing the result to wrap to a tiny allocation (e.g., 1×1 pixels). The subsequent border-expansion loop iterates using the original huge margin, writing far past the allocated buffer. The vulnerability is reachable through documented public classes — RankFilter, MedianFilter, MinFilter, and MaxFilter — without requiring any private API, ctypes, or custom Python objects (GitHub Advisory, Fix Commit).

Impact

Successful exploitation causes a native heap buffer overflow write in Pillow's C extension, which can crash the application (denial of service) or potentially enable arbitrary code execution through heap memory corruption. In mode L images, 1-byte out-of-bounds stores occur; in modes I and F, 4-byte stores occur, and if the image is also attacker-supplied, the value written out of bounds can be attacker-influenced. Applications that accept untrusted filter size parameters or process user-supplied images with rank-filter operations are directly at risk (GitHub Advisory).

Exploitability

A public proof-of-concept (PoC) is available in the official GitHub Security Advisory, consisting of minimal Python code that triggers an ASAN-confirmed heap-buffer-overflow crash. The vulnerability requires no authentication, no privileges, and no user interaction, and NVD has classified it as automatable. There is no evidence of active in-the-wild exploitation at this time, and it has not been added to the CISA KEV catalog. The EPSS score is approximately 0.397% (GitHub Advisory, Feedly).

Exploitation steps

  1. Identify a target application: Find a web service or application that uses Pillow < 12.3.0 and exposes image filtering functionality (e.g., image processing APIs, thumbnail generators, or upload handlers that apply rank-based filters).
  2. Craft a malicious filter invocation: Prepare a Python payload or HTTP request that causes the application to call a rank-filter (e.g., MedianFilter, MinFilter, MaxFilter, or RankFilter) with a very large odd integer size such as 4294967295.
  3. Trigger the overflow: Submit the crafted input so the application executes code equivalent to:
from PIL import Image, ImageFilter
im = Image.new("L", (3, 3), 128)
im.filter(ImageFilter.MedianFilter(4294967295))
  1. Achieve heap corruption: The integer overflow in ImagingExpand() causes a tiny heap allocation followed by a massive out-of-bounds write loop, corrupting adjacent heap memory and crashing the process or potentially enabling code execution.
  2. Escalate (optional): For a 4-byte write primitive, supply a mode I image with attacker-controlled pixel values to influence the bytes written out of bounds, potentially enabling heap exploitation techniques for code execution (GitHub Advisory).

Indicators of compromise

  • Logs: Application crash logs or Python tracebacks referencing ImagingExpand, Filter.c, or _imaging.c; ASAN output containing heap-buffer-overflow WRITE in ImagingExpand.
  • Process: Unexpected termination (segfault/SIGABRT) of Python processes running Pillow-based image processing; core dump files generated by the Pillow worker process.
  • Network: Requests to image processing endpoints supplying unusually large integer values (e.g., near 4294967295) as filter size parameters in API calls or multipart form data.
  • File System: Core dump files (e.g., core.*) in the application working directory following crashes of Pillow-based services.

Mitigation and workarounds

Upgrade Pillow to version 12.3.0 or later, which validates the rank-filter size before calling image.expand() and adds an overflow check in ImagingExpand() in the C layer (Pillow 12.3.0 Release, Fix Commit). Red Hat has addressed this in RHSA-2026:48021 for Red Hat Enterprise Linux 8, and SUSE has issued SUSE-SU-2026:3084-1 and SUSE-SU-2026:3268-1 (Red Hat Bugzilla). As a temporary workaround if upgrading is not immediately possible, implement input validation in application code to reject filter size values where size * size * 4 > (2**31 - 1) before passing them to any Pillow rank-filter API.

Community reactions

Red Hat triaged the issue as high severity and issued a security errata (RHSA-2026:48021) for RHEL 8 within approximately two weeks of disclosure. SUSE issued two separate security updates covering affected distributions. The vulnerability was detected by Nessus and Qualys scanners shortly after disclosure, and coverage appeared across Linux security news outlets including LinuxSecurity.com and Pro-Linux.de (Red Hat Bugzilla).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-63003MEDIUM6.5
  • Python logoPython
  • django-cms
NoYesAug 20, 2026
CVE-2026-54624MEDIUM6.5
  • Python logoPython
  • django-cms
NoYesAug 20, 2026
CVE-2026-54622MEDIUM6.5
  • Python logoPython
  • django-cms
NoYesAug 20, 2026
CVE-2026-75526MEDIUM4.4
  • Python logoPython
  • django-cms
NoYesAug 20, 2026
CVE-2026-61663MEDIUM4.3
  • Python logoPython
  • django-cms
NoYesAug 20, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management