CVE-2026-59197
Received Received - Intake

Heap Out-of-Bounds Write in Pillow Image Library

Vulnerability report for CVE-2026-59197, including description, CVSS score, EPSS score, affected products, exploitability, helpful resources, and attack-flow context.

Publication date: 2026-07-14

Last updated on: 2026-07-14

Assigner: GitHub, Inc.

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.

CVSS Scores

EPSS Scores

Probability:
Percentile:

Meta Information

Published
2026-07-14
Last Modified
2026-07-14
Generated
2026-07-15
AI Q&A
2026-07-14
EPSS Evaluated
N/A
NVD
EUVD

Affected Vendors & Products

Showing 2 associated CPEs
Vendor Product Version / Range
python pillow 12.3.0
python pillow to 12.3.0 (exc)

Helpful Resources

Exploitability

CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-190 The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.
CWE-787 The product writes data past the end, or before the beginning, of the intended buffer.

Attack-Flow Graph

AI Quick Actions

Instant insights powered by AI
Executive Summary

CVE-2026-59197 is a heap out-of-bounds write vulnerability in the Pillow library, a Python imaging library. The issue occurs in the ImageFilter.RankFilter class when processing a very large odd filter size.

The vulnerability arises because the filter size validation happens after the image.expand() call. This call performs unchecked signed integer arithmetic in the ImagingExpand() function, leading to incorrect output image dimensions. As a result, the border-expansion loop writes beyond the allocated memory, causing a heap out-of-bounds write.

This flaw can be exploited through public classes like RankFilter, MedianFilter, MinFilter, and MaxFilter without requiring private APIs or custom Python objects. Attackers may also influence the out-of-bounds write value if they control the source image.

The vulnerability affects Pillow versions up to 12.2.0 and is fixed in version 12.3.0. The fix involves validating the rank-filter size before calling image.expand() and hardening ImagingExpand() against invalid margins and overflow.

Impact Analysis

This vulnerability can impact you in several ways if you are using an affected version of the Pillow library (versions up to 12.2.0).

  • Memory corruption: The heap out-of-bounds write can corrupt memory, leading to crashes or unpredictable behavior in your application.
  • Security risks: If an attacker exploits this vulnerability, they could potentially execute arbitrary code or cause a denial-of-service condition by crashing the application.
  • Data integrity issues: The vulnerability can affect the integrity of your application by allowing unauthorized modifications to memory, which may lead to incorrect processing of image data.
  • Exploitation through image processing: If your application processes images from untrusted sources, an attacker could craft a malicious image file to trigger this vulnerability.
Compliance Impact

This vulnerability can impact compliance with common standards and regulations in the following ways:

  • GDPR (General Data Protection Regulation): If your application processes personal data of EU citizens and the vulnerability leads to unauthorized access or data corruption, it could result in a breach of data integrity or confidentiality. This may require reporting under GDPR and could lead to fines or other penalties.
  • HIPAA (Health Insurance Portability and Accountability Act): For applications handling protected health information (PHI), this vulnerability could compromise the integrity or availability of PHI. HIPAA requires safeguards to ensure the confidentiality, integrity, and availability of PHI, and a breach could result in non-compliance.
  • Other standards: Compliance frameworks like ISO 27001, SOC 2, or PCI DSS require organizations to maintain secure systems and protect against vulnerabilities that could lead to data breaches or system compromise. This vulnerability could indicate a failure to apply security patches or validate inputs properly, potentially leading to non-compliance.

To maintain compliance, it is critical to update to the patched version of Pillow (12.3.0 or later) and ensure that your systems are protected against known vulnerabilities.

Detection Guidance

Detecting CVE-2026-59197 on your system involves checking for vulnerable versions of the Pillow library and identifying potential exploitation attempts.

  • Check the installed version of Pillow. The vulnerability affects versions up to 12.2.0. You can use the following Python command to check the version: pip show Pillow or python -c "import PIL; print(PIL.__version__)". If the version is 12.2.0 or earlier, the system is vulnerable.
  • Monitor for unusual image processing activity, particularly involving large filter sizes in RankFilter, MedianFilter, MinFilter, or MaxFilter. Exploitation may involve maliciously crafted image files or filter parameters.
  • Review application logs for errors related to memory corruption or crashes during image processing, especially those involving the ImageFilter.RankFilter class.

Network-level detection is challenging since this is a local library vulnerability. However, if your applications process user-uploaded images, inspect incoming image files for unusually large filter parameters or malformed data that could trigger the vulnerability.

Mitigation Strategies

To mitigate CVE-2026-59197, follow these immediate steps:

  • Upgrade Pillow to version 12.3.0 or later. This is the most effective mitigation. Use the command: pip install --upgrade Pillow==12.3.0.
  • If upgrading is not immediately possible, apply temporary workarounds by restricting the use of RankFilter, MedianFilter, MinFilter, and MaxFilter with large filter sizes. Validate input parameters in your code to ensure filter sizes are within safe limits (e.g., size squared multiplied by 4 should not exceed 2^31 - 1).
  • Review and sanitize image inputs, especially those from untrusted sources, to prevent attackers from supplying maliciously crafted filter sizes or image data.
  • Monitor systems for signs of exploitation, such as crashes or memory corruption errors during image processing, and investigate any suspicious activity.

Chat Assistant

Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-59197. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70

EPSS Chart