Listen to this Post
CVE-2026-54058 is an out-of-bounds read vulnerability in the Python Pillow imaging library, affecting all versions prior to 12.3.0. The flaw resides in the McIdas AREA image plugin when handling uncompressed images opened from a filename. When Pillow loads such an image, it memory-maps the file and uses the `mmap` raw codec path to build row pointers directly into the mapped region via `PyImaging_MapBuffer` in src/map.c.
The McIdas AREA file format contains header words that are fully attacker-controlled. Specifically, the plugin (McIdasImagePlugin.py) derives critical parameters — stride, offset, xsize, and ysize — directly from 32-bit header words without any validation. The stride value is computed as w
+ w[bash] w[bash] w[bash]</code>, where all these words are taken from the file header. The plugin then constructs a tile with the `raw` codec and passes this attacker-controlled stride to the image loader. The core issue lies in `map.c` and <code>ImageFile.py</code>. The loader validates that <code>offset + ysize stride <= buffer_len</code>, ensuring the mapping does not exceed the file size. However, it never checks that the stride is at least the natural row width (<code>xsize pixelsize</code>). An attacker can supply a stride far smaller than the natural row width — for example, setting stride to 1 while the image width is large. This causes each row pointer to read `xsize pixelsize` bytes from a region that extends far beyond the actual mapped memory. When an application subsequently accesses the pixel data — through operations like <code>Image.tobytes()</code>, <code>getpixel()</code>, <code>convert()</code>, or `save()` — the library reads past the mapped region. This results in either disclosure of adjacent process memory (information leak) or a fatal signal such as SIGBUS, leading to denial of service. The vulnerability is triggered without user interaction beyond supplying a crafted image file, making it particularly dangerous for services that automatically process uploaded images. The issue was addressed in Pillow version 12.3.0 by adding proper validation to ensure the stride is not smaller than the natural row width. <h2 style="color: blue;">DailyCVE Form:</h2> Platform: Python Pillow Version: < 12.3.0 Vulnerability: Out-of-bounds Read Severity: High (CVSS 8.3) date: 2026-07-14 <h2 style="color: blue;">Prediction: 2026-07-14 (fixed)</h2> <h2 style="color: blue;">What Undercode Say:</h2> Analytics show active exploitation attempts in the wild targeting image processing pipelines. Below are relevant commands and code snippets demonstrating the vulnerable code paths. <h2 style="color: blue;">Check installed Pillow version:</h2> [bash] python3 -c "import PIL; print(PIL.<strong>version</strong>)"
Verify if system is vulnerable (Debian/Ubuntu):
apt policy python3-pil | grep Installed
Vulnerable code snippet from `McIdasImagePlugin.py` (lines 66-68):
stride = w[bash] + w[bash] w[bash] w[bash] attacker-controlled
tile = ("raw", (0, 0, xsize, 1), offset, ("L", 1, stride))
Vulnerable validation in `ImageFile.py` (line 343) — missing stride check:
if offset + ysize stride <= len(data): No check for stride >= linesize im = core.map_buffer(data, (xsize, ysize), ...)
Exploit:
An attacker crafts a McIdas AREA image with header words that set stride to a small value (e.g., 1) while keeping xsize large. When the image is loaded via `Image.open()` and pixel access is performed, the library reads out-of-bounds memory. A minimal proof-of-concept:
from PIL import Image
Attacker-controlled McIdas AREA file with stride=1, xsize=10000
img = Image.open("malicious.area")
data = img.tobytes() Triggers OOB read
The OOB read can leak sensitive heap data or cause a crash:
python3 -c "from PIL import Image; Image.open('malicious.area').tobytes()"
Expected output: Segmentation fault (SIGBUS) or memory disclosure
Protection:
Upgrade to Pillow 12.3.0 or later, which includes the fix. For Debian-based systems:
sudo apt update && sudo apt install python3-pil=12.3.0-1
For pip installations:
pip install --upgrade Pillow>=12.3.0
If immediate upgrade is not possible, avoid processing untrusted McIdas AREA files, or disable the McIdas plugin temporarily by removing or renaming McIdasImagePlugin.py. Additionally, consider running image processing in isolated sandboxes with restricted memory access.
Impact:
- Confidentiality: An attacker can read adjacent process memory, potentially exposing sensitive data such as API keys, credentials, or other secrets residing in the same memory space.
- Availability: The out-of-bounds read can trigger a SIGBUS or segmentation fault, causing the application to crash and leading to denial of service.
- Integrity: No direct integrity violation, but information leakage can facilitate further attacks.
- Attack Vector: Remote, unauthenticated, requiring only that the attacker supply a malicious image file to a vulnerable service.
- Affected Deployments: Any application using Pillow < 12.3.0 to process McIdas AREA images from filenames, including web services, batch processors, and CLI tools.
- CVSS Score: 8.3 (High) per CVSS v4.0, with vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:H/SC:N/SI:N/SA:N.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: nvd.nist.gov
Extra Source Hub:
Undercode

