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-59199

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

Alon Barad
Alon Barad
Software Engineer

Jul 21, 2026·6 min read·7 visits

Executive Summary (TL;DR)

A signed integer overflow in Pillow before 12.3.0 allows unauthenticated remote attackers to bypass memory safety checks and perform a native heap out-of-bounds write via crafted coordinates, leading to a denial of service.

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.

Vulnerability Overview

Pillow, the standard Python Imaging Library fork, processes digital images using a high-performance native C extension layer named libImaging. This layer is responsible for intensive pixel manipulations, layout calculations, and coordinate transformation mapping. Because these operations are executed in native C, any parsing or calculation of dimensions must be strictly validated before memory is allocated or accessed.

The vulnerability is classified as a signed 32-bit integer overflow (CWE-190) that cascades into an out-of-bounds write (CWE-787). It affects multiple high-level, coordinate-based APIs, including Image.paste, Image.crop, and Image.alpha_composite. When an application accepts untrusted coordinates from external inputs, it exposes this internal native layer to arbitrary input manipulation.

By supplying coordinates close to the bounds of a signed 32-bit integer, an attacker can manipulate the internal dimension calculations. This manipulation bypasses safety boundaries and allows write access outside the allocated target row buffers. The consequence is native heap memory corruption, typically leading to immediate program termination.

Root Cause Analysis

The root cause of this vulnerability lies in the mathematical subtraction used to calculate the height and width of image bounding boxes within Pasteurization and Filling utilities. Specifically, the functions ImagingPaste and ImagingFill2 in src/libImaging/Paste.c calculate the xsize and ysize of the destination region using the equations: xsize = dx1 - dx0 and ysize = dy1 - dy0. Because dx0, dy0, dx1, and dy1 are standard signed 32-bit integers, their values can range from -2147483648 to 2147483647.

When dx0 is set to a large positive value such as 2147483646 and dx1 is set to a large negative value such as -2147483648, the subtraction results in -4294967294. In signed 32-bit two's complement representation, this mathematical value wraps around and is interpreted as positive 2. This wrapped value matches the positive width of the incoming source image, successfully bypassing the inequality mismatch safety checks.

Furthermore, the subsequent boundary check compares dx0 + xsize against the target output image width. Since dx0 is 2147483646 and xsize is evaluated as 2, their sum is 2147483648, which wraps around to -2147483648. Because this negative value is mathematically smaller than the target output image width, the boundary check fails to identify an out-of-bounds condition and permits the execution flow to continue unchecked.

Code Analysis

To understand the exact flaw and its resolution, we must analyze the code structure before and after the security patch. In the vulnerable version of src/libImaging/Paste.c, variables storing sizes are declared as standard 32-bit signed integers, which are susceptible to overflow.

// VULNERABLE CODE PATH (Paste.c)
int xsize, ysize;
 
// Subtraction performed in 32-bit signed arithmetic
xsize = dx1 - dx0;
ysize = dy1 - dy0;

The corresponding fix, introduced in commit ceefc348eb3c3844c7f9796ef2cc3a7dd5fbba7b, promotes the size tracking variables to 64-bit integers and introduces explicit casting. This prevents the wraparound behavior during subtraction.

// PATCHED CODE PATH (Paste.c)
int64_t xsize, ysize;
 
// Subtraction promoted to 64-bit space to prevent overflow
xsize = (int64_t)dx1 - dx0;
ysize = (int64_t)dy1 - dy0;

By casting dx1 to a 64-bit signed integer before subtraction, the compiler executes the operation in 64-bit space. The intermediate value of -4294967294 is preserved accurately as a negative 64-bit integer, which fails the mismatch comparison against the positive 32-bit source image size and triggers an early error exit.

Exploitation Methodology

Exploitation of this vulnerability requires the ability to supply coordinate parameters to Pillow APIs. When the coordinates bypass the boundary checks, the application proceeds to the pixel copying stage, calculating a target memory address via pointer arithmetic: Row Destination + (dx0 * pixelsize).

If the color mode is RGBA, the pixelsize is 4 bytes. For a dx0 value of 2147483646, the multiplication is computed as 2147483646 * 4, which equals 8589934584. In 32-bit signed math, this calculation wraps around to -8, which is then sign-extended on 64-bit systems to a large negative offset. Consequently, the destination pointer is adjusted backward by 8 bytes.

When memcpy is invoked to copy the row data, the write operation begins exactly 8 bytes before the beginning of the allocated heap row buffer, corrupting metadata or adjacent heap chunks. The overall process and physical memory layout can be visualized in the diagram below:

Impact Assessment

The security consequences of a native heap backward underwrite are severe. Memory corruptions occurring in heap chunk headers can compromise the integrity of the dynamic memory allocator. This corruption typically triggers immediate application termination or a segmentation fault when the affected or adjacent heap blocks are later freed by the system.

An attacker can utilize this vulnerability to perform targeted denial of service attacks against services processing user-supplied images or bounding boxes. If the environment operates in a multi-threaded process or within a persistent worker architecture, a single exploit payload can terminate the processing daemon and disrupt service availability.

While remote code execution is theoretically possible by overwriting adjacent function pointers or critical class metadata, the level of precision required depends heavily on the specific allocator behavior and surrounding heap layout. No weaponized exploits for remote code execution have been publicly observed in active campaigns, classifying the threat maturity primarily as a denial of service vector.

Remediation & Mitigation

The primary remediation for this vulnerability is upgrading the Pillow dependency to version 12.3.0 or higher. This release integrates the 64-bit integer calculation patch, which completely mitigates the integer overflow condition.

If upgrading immediately is not feasible, application-layer coordinate validation must be enforced. Any coordinate inputs passed to Image.paste, Image.crop, or Image.alpha_composite must be restricted to safe, realistic limits corresponding to the physical boundaries of the canvas. The following validation check illustrates how to intercept unsafe inputs:

def validate_coordinates(box, max_width, max_height):
    if box:
        for coord in box:
            if not (-65536 <= coord <= 65536):
                raise ValueError("Coordinate exceeds safe limit")

Additionally, high-risk image parsing workflows should run within isolated, sandboxed environments with low privileges. Restricting container memory space and applying seccomp profiles can limit the potential blast radius of native heap memory corruption exploits.

Official Patches

Python PillowFix coordinate calculation overflows in Paste and Fill
Python PillowGHSA security advisory for Pillow integer overflow

Fix Analysis (1)

Technical Appendix

CVSS Score
7.5/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Probability
0.39%
Top 69% most exploited

Affected Systems

Pillow prior to version 12.3.0

Affected Versions Detail

Product
Affected Versions
Fixed Version
Pillow
Python Pillow
< 12.3.012.3.0
AttributeDetail
CWE IDCWE-190, CWE-787
Attack VectorNetwork (Remote)
CVSS Score7.5 (High)
EPSS Score0.0039 (Percentile: 31.40%)
ImpactDenial of Service, Native Heap Corruption
Exploit StatusProof of Concept
KEV StatusNot Listed

MITRE ATT&CK Mapping

T1203Exploitation for Client Execution
Execution
T1068Exploitation for Privilege Escalation
Privilege Escalation
CWE-190
Integer Overflow or Wraparound

The software performs an calculation that can produce an integer overflow or wraparound, which can lead to unexpected behavior or security issues.

Vulnerability Timeline

Initial drafting of the STRIDE threat model by Pillow developers
2026-04-14
Security patch submitted via Pull Request #9703
2026-06-22
Official publication of CVE-2026-59199 and advisory GHSA-6r8x-57c9-28j4
2026-07-14
Public release of Pillow version 12.3.0 containing the fix
2026-07-14

References & Sources

  • [1]NVD CVE-2026-59199 Record
  • [2]Pillow Security Advisory GHSA-6r8x-57c9-28j4
  • [3]Fix Pull Request #9703
  • [4]Fix Commit ceefc348
  • [5]Pillow Release 12.3.0 Notes

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

•12 minutes 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
0 views•6 min read
•about 1 hour 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 2 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 3 hours ago•CVE-2026-59197
8.2

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

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.

Alon Barad
Alon Barad
4 views•3 min read
•about 4 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-59200
7.5

CVE-2026-59200: Remote Denial of Service via PDF Decompression Bomb in Pillow

CVE-2026-59200 is a high-severity uncontrolled resource consumption vulnerability in the Pillow Python Imaging Library. The flaw resides in the PDF stream decoder, allowing remote, unauthenticated attackers to trigger host out-of-memory crashes by submitting malicious PDF decompression bombs.

Alon Barad
Alon Barad
7 views•5 min read