CVE-2026-112397: Pillow Zero-Width Image Causes Out-of-Bounds Access

pillow Updated 20 Oct 2026

Summary

20/10/2026
Yes i
High
8.7

CVE-2026-112397: Pillow: Out-of-bounds access in _imagingmorph on a zero-width image. Affects pillow versions < 13.0.0. Fixed in 13.0.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Pillow is a widely used Python Imaging Library that provides easy-to-use methods for opening, manipulating, and saving various image file formats. It supports a range of operations, including image processing and morphological transformations. However, it is vulnerable to a specific issue where it accepts images with a declared width of zero, leading to potential crashes and memory corruption when certain operations are performed.

Vulnerability Detail

The vulnerability arises from the Pillow library's PPM and PGM file parsers, which do not enforce a lower-bound check on the width of the image. This allows for the creation of a zero-width image, which can lead to out-of-bounds access when the MorphOp.apply() method is called. Specifically, the native code attempts to index a row buffer at outrow[width - 1], resulting in an attempt to access an invalid memory location. This can cause segmentation faults and potential memory corruption, particularly when processing untrusted input.

How To Fix

Latest published version: 13.0.0 as of 22 Oct 2026

pip install --upgrade "pillow==13.0.0"

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid processing images that may have a width of zero. You can implement a check in your code to validate the dimensions of images before passing them to the MorphOp.apply() method. For example:

from PIL import Image, ImageMorph

im = Image.new("L", (0, 5))
if im.width > 0:
    ImageMorph.MorphOp(op_name="dilation4").apply(im)
else:
    print('Image width is zero, skipping operation.')

Conclusion

The CVE-2026-112397 vulnerability in the Pillow library poses a significant risk due to its potential for causing crashes and memory corruption when handling zero-width images. It is crucial for developers to update to the latest version of Pillow and implement necessary checks in their applications to mitigate this risk.

See every vulnerability recorded for pillow →

Share this vulnerability

FAQ

CVE-2026-112397 is a vulnerability in the Pillow library that allows for out-of-bounds access when processing zero-width images, potentially leading to crashes and memory corruption.

If your application uses Pillow versions 12.3.0 or earlier and processes images from untrusted sources, it may be affected. You can check your application's dependencies using tools like Vulert.

The CVSS score for this vulnerability is 8.7, indicating a high severity level.

If you cannot update Pillow, implement checks in your code to ensure that images being processed have valid dimensions, specifically that the width is greater than zero.

You can find more information about CVE-2026-112397 on the official GitHub advisory page or by using Vulert to monitor your dependencies for vulnerabilities.

Related vulnerabilities

Recent vulnerabilities recorded for pillow.

How To Fix

Latest published version: 13.0.0 as of 22 Oct 2026

pip install --upgrade "pillow==13.0.0"

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback