CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-59197

CVE-2026-59197: Heap Out-of-Bounds Write and Division-by-Zero in Pillow libImaging

Alon Barad
Alon Barad
Software Engineer

Jul 21, 2026·3 min read·4 visits

Executive Summary (TL;DR)

Integer overflow in Pillow image expansion leads to heap out-of-bounds write. Initial patch introduces a division-by-zero crash.

A heap out-of-bounds write vulnerability exists in Pillow prior to version 12.3.0 due to an integer overflow during image expansion calculations. The subsequent patch introduced a division-by-zero regression causing denial of service.

Vulnerability Overview

Pillow is a Python Imaging Library that provides image processing capabilities. The vulnerability exists within the native C extension libImaging, specifically in the image expansion and filtering code paths.\n\nAn attacker can trigger this vulnerability by providing an extremely large filter size parameter to ranking filters. This input flows from the Python layer into native C functions without sufficient prior validation.\n\nThe resulting calculation causes a signed integer overflow. This leads to severe memory corruption or application crashes.

Root Cause Analysis

The root cause lies in src/libImaging/Filter.c within the ImagingExpand function. When an application initializes a filter, the Python layer calculates the margin parameter using floor division.\n\nFor extremely large filter sizes, this division yields a margin value close to INT_MAX. When passed to the C library, the output dimensions are computed via addition and multiplication.\n\nSpecifically, the formula imIn->xsize + 2 * margin overflows the 32-bit signed integer limits. This mathematical wraparound results in a very small dimension value.\n\nConsequently, the library allocates an undersized destination buffer. However, the subsequent copying loop still uses the original large margin, resulting in an out-of-bounds write.

Code Analysis

The vulnerable calculation path computes the destination buffer size based on the overflowed dimensions.\n\nc\n/* Vulnerable dimension calculation */\nint xsize = imIn->xsize + 2 * margin;\nint ysize = imIn->ysize + 2 * margin;\n\n/* Allocation of undersized buffer */\nimOut = ImagingNewDirty(imIn->mode, xsize, ysize);\n\n\nThe loop then iterates using the un-overflowed margin to copy pixels.\n\nc\n/* Out-of-bounds copy loop */\nfor (y = 0; y < margin; y++) {\n for (x = 0; x < margin; x++) {\n imOut->image[y][x] = imIn->image[...];\n }\n}\n\n\nThe patch attempted to check bounds but introduced a division-by-zero error.\n\nc\n/* Patched boundary check introducing regression */\nif (margin > INT_MAX / (margin * (int)sizeof(FLOAT32))) {\n return (Imaging)ImagingError_ValueError(\"filter size too large\");\n}\n

Exploitation and Impact

An attacker can exploit this flaw by submitting images or filter size parameters designed to trigger the overflow. This allows sequential overwriting of heap data with pixel values derived from the input image.\n\nControl over pixel values enables targeted heap corruption. This can lead to remote code execution in contexts where untrusted input dictates filter dimensions.\n\nAdditionally, the patch regression allows a straightforward denial of service attack. Passing a filter size of 1 translates to a margin of 0, triggering the division-by-zero trap.

Remediation and Patches

Users should upgrade to Pillow version 12.3.0 or later to resolve the heap out-of-bounds write. This release contains validation checks that prevent large values from reaching the C execution layer.\n\nFor systems where upgrading is not immediately possible, strict input validation should be enforced. Applications should restrict filter size parameters to reasonable boundaries.\n\nFurthermore, the division-by-zero issue can be mitigated by ensuring that the margin parameter is non-zero before invoking the expansion functions.

Technical Appendix

CVSS Score
8.2/ 10

Affected Systems

Pillow (Python Imaging Library) versions prior to 12.3.0

Affected Versions Detail

Product
Affected Versions
Fixed Version
Pillow
Pillow
< 12.3.012.3.0
AttributeDetail
CWE IDCWE-190, CWE-787
Attack VectorNetwork
CVSS v3.1 Score8.2
ImpactHeap Out-of-Bounds Write / Denial of Service
Exploit StatusPoC Available

MITRE ATT&CK Mapping

T1203Exploitation for Client Execution
Execution

Vulnerability Timeline

CVE Published
2026-07-14

References & Sources

  • [1]GitHub Advisory
  • [2]Fix Commit
  • [3]Pull Request

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•18 minutes ago•GHSA-8WHX-365G-H9VV
2.3

GHSA-8whx-365g-h9vv: HTML5 Named Whitespace Bypass in Loofah allowed_uri? Validation

The Loofah Ruby gem version 2.25.0 and 2.25.1 contains an incomplete validation vulnerability in its public string-level utility Loofah::HTML5::Scrub.allowed_uri?. This helper fails to detect 'javascript:' URIs that are split by HTML5 named whitespace character references such as &Tab; and &NewLine;. Applications manually invoking this utility to validate links are vulnerable to stored Cross-Site Scripting (XSS), as browsers parse and remove these entities during rendering.

Alon Barad
Alon Barad
0 views•7 min read
•about 1 hour ago•CVE-2026-50525
7.5

CVE-2026-50525: Denial of Service Vulnerability in Microsoft .NET XML Cryptography Stack

CVE-2026-50525 is a high-severity Denial of Service (DoS) vulnerability in the Microsoft .NET XML Cryptography stack. The vulnerability resides in the `System.Security.Cryptography.Xml` library, specifically within the `EncryptedXml` processing engine. Unauthenticated remote attackers can exploit this flaw by sending specifically crafted XML documents containing nested or recursive structures, or utilizing resource-intensive transforms. Processing such payloads leads to infinite CPU loops, stack exhaustion, or memory starvation, resulting in application termination.

Amit Schendel
Amit Schendel
1 views•6 min read
•about 2 hours ago•CVE-2026-50659
6.5

CVE-2026-50659: SMTP Command and Header Injection in .NET System.Net.Mail

An improper encoding and escaping vulnerability in the .NET SMTP client component allows network-based attackers to perform SMTP command smuggling and email spoofing by injecting control characters into email fields.

Alon Barad
Alon Barad
2 views•8 min read
•about 3 hours ago•CVE-2026-50651
7.5

CVE-2026-50651: Denial of Service via Uncontrolled Resource Allocation in .NET System.Net.Http

CVE-2026-50651 is a high-severity Denial of Service vulnerability in Microsoft .NET runtimes, SDKs, and Visual Studio installations. It stems from a weakness in System.Net.Http (CWE-770), where the HTTP/2 connection handling state machine fails to throttle server-initiated protocol streams and control frames. An attacker-controlled server can exploit this by returning highly fragmented or infinite control and continuation frame sequences. This forces the client to allocate memory indefinitely on the managed heap, eventually provoking an unhandled Out-of-Memory (OOM) exception and application crash.

Amit Schendel
Amit Schendel
4 views•6 min read
•about 5 hours ago•CVE-2026-59198
6.5

CVE-2026-59198: Heap Out-of-Bounds Read in Pillow TGA RLE Encoder

CVE-2026-59198 is a high-severity heap out-of-bounds read vulnerability in Pillow, the Python imaging library, affecting versions from 5.2.0 up to 12.3.0. The vulnerability occurs in the TGA RLE compression path due to a calculation mismatch between the allocated packed 1-bit row buffer and the byte-level pixel stride assumption in the C-level encoder. This mismatch allows an attacker to leak up to approximately 57 KB of adjacent process heap memory directly into generated TGA image files.

Alon Barad
Alon Barad
3 views•8 min read
•about 6 hours ago•CVE-2026-59199
7.5

CVE-2026-59199: Signed 32-Bit Integer Overflow and Heap Backward Underwrite in Pillow

A critical signed 32-bit integer overflow vulnerability was identified in Pillow (Python Imaging Library) versions prior to 12.3.0. The vulnerability resides within the native C extension library (libImaging) during coordinate and bounding box calculations in functions like ImagingPaste and ImagingFill2. Exploitation can bypass bounds and clipping safety checks, leading to a controlled heap backward underwrite and application crash.

Alon Barad
Alon Barad
7 views•6 min read