CVE-2026-112397: Pillow: Out-of-bounds access in _imagingmorph on a zero-width image

Published Oct 19, 2026
·
Updated

Summary A PPM or PGM file can declare a width of 0, which Pillow accepts, producing an image of size (0, N). Passing that image to ImageMorph.MorphOp.apply() makes the native morphology code index a row buffer at outrow[width - 1], which is outrow[-1] when the width is 0. The process crashes.

Details The PPM parser reads width and height with no lower-bound check:

- src/PIL/PpmImagePlugin.py:119

The native apply() writes the row edges with no guard that the width is positive:

- src/imagingmorph.c:81 sets outrow[0] = outrow[width - 1] = 0;

match() and getonpixels() use the same edge-indexing pattern.

PoC python from PIL import Image, ImageMorph

A width-0 image (also producible from a crafted PPM header). apply() indexes outrow[width - 1] == outrow[-1] in native code. im = Image.new("L", (0, 5)) ImageMorph.MorphOp(opname="dilation4").apply(im)

Run it: $ python 03poc.py Segmentation fault (core dumped)

Observed on a source build of commit 3e2ab96.

Under AddressSanitizer: ==ERROR: AddressSanitizer: SEGV on unknown address (pc ... in apply) #0 apply src/imagingmorph.c:81 SUMMARY: AddressSanitizer: SEGV src/imagingmorph.c:81 in apply With width 0 the outrow[width - 1] write lands on an unmapped page, so it surfaces as a SEGV pinned to the edge-write line rather than a redzone overflow.

Impact Out-of-bounds write in a C extension. Affects any application that runs a morphology operation on an image opened from untrusted input. Result is a crash and possible memory corruption.

Other sources

Pillow is a Python imaging library. Prior to 13.0.0, Pillow's ImageMorph.MorphOp.apply() can access memory before a row buffer for a zero-width image. PPM and PGM input can create an image with width zero, and the native morphology routine indexes outrow[width - 1] without rejecting that geometry. An attacker can supply such an image to an application that applies a morphology operation. This can crash the process. This issue is fixed in version 13.0.0.

— Ubuntu

Affected Software

15 affected componentsFixes available
pypi/Pillow<13.0.0
pip/pillow<=12.3.0
13.0.0
Python Pillow<13.0.0
bitnami/pillow<13.0.0
13.0.0
debian/pillow<=9.4.0-1.1+deb12u1, <=11.1.0-5+deb13u4, <=11.1.0-5+deb13u3, <=12.3.0-1
13.0.0-1
ubuntu/pillow*
ubuntu/pillow*
ubuntu/pillow*
ubuntu/pillow-python2*
ubuntu/pillow*
ubuntu/pillow*
ubuntu/pillow*
ubuntu/pillow*
IBM App Connect Operator<=CD: 12.1.0 - 12.21.0 12.0 LTS: 12.0.0 - 12.0.28 13 LTS: 13.0.0 - 13.6.0
IBM App Connect EnterpriseCertified Containers Operands<=CD: 12.0.11.1-r1 - 12.0.12.5-r1, 13.0.1.0-r1 - 13.0.6.2-r1 12.0 LTS: 12.0.12-r1 - 12.0.12-r28 13 LTS: 13.0.7.0-r1 - 13.0.9.0-r1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/Pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0
  2. Upgrade

    Upgrade bitnami/pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0
  3. Upgrade

    Upgrade debian/pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0-1
  4. Upgrade

    Upgrade Pillow to a version that resolves this vulnerability.

    Fixed in 13.0.0

Event History

Oct 19, 2026
CVE Published
via Ubuntu·12:00 AM
Data Sourced
via Ubuntu·12:00 AM
RemedyDescriptionSeverityAffected Software
CVE Published
via MITRE·09:17 PM
Data Sourced
via MITRE·09:17 PM
DescriptionWeakness
Data Sourced
via OSV·09:17 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·09:22 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·10:17 PM
RemedyDescriptionSeverityWeaknessAffected Software
Oct 20, 2026
Advisory Published
via GitHub·08:56 PM
Data Sourced
via GitHub·08:56 PM
DescriptionWeaknessAffected Software
Oct 26, 2026
Advisory Published
via OSV·05:55 AM
Nov 9, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software
Nov 12, 2026
Data Sourced
via OSV·11:46 PM
Affected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

Which applications are exposed to this issue?

Applications using Pillow before 13.0.0 are exposed if they process attacker-supplied PPM or PGM images and apply ImageMorph.MorphOp.apply() to them. The triggering image must have zero width.

2

What does an attacker need to do to trigger the vulnerability?

An attacker needs to provide a crafted PPM or PGM image that creates a zero-width image and cause the application to apply a morphology operation. No authentication or user interaction is required according to the supplied CVSS vector.

3

What is the expected impact of successful exploitation?

The documented impact is a process crash caused by access before a row buffer in the native morphology routine. The supplied CVSS vector indicates impact to availability, with no stated confidentiality or integrity impact.

4

What should teams do to remediate the issue?

Upgrade Pillow to version 13.0.0, which fixes the issue. If upgrading is not immediately possible, avoid applying morphology operations to untrusted PPM or PGM inputs and reject zero-width images before calling ImageMorph.MorphOp.apply().

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203