All vulnerabilities
CVE-2026-112397GHSA-58r4-6rv3-gfh8

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

python-pillow PillowpipLibraries & packages
CVSS
8.7High
ExploitationPublic exploit codeCISA's assessment says proof of concept code is public, assessed 19 Oct 2026. Not in the KEV catalogCISA via CVE List
Exploit odds (EPSS)0.44%Chance of exploitation activity in the next 30 days, higher than 36% of CVEs. Scored 23 Oct 2026FIRST EPSS
Fixed in13.0.0Fixed versionGitHub
Published19 Oct 2026Updated 20 Oct 2026CVE List

What fixes it

  • 13.0.0Pillow, pipGitHub
  • 13.0.0pillow, PyPIOSVpip install "pillow>=13.0.0"

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

Description

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 get_on_pixels() use the same edge-indexing pattern.

PoC

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(op_name="dilation4").apply(im)

Run it:

$ python 03_poc.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.

Text from GitHub Advisory Database

Affected versions 53

  • Pillow, pip<= 12.3.0GitHub
  • Pillowaffected: < 13.0.0CVE List
  • pillow, PyPIfrom first release, fixed in 13.0.0OSV
  • pillow, PyPI1.0OSV
  • pillow, PyPI1.1OSV
  • pillow, PyPI1.2OSV
  • pillow, PyPI1.3OSV
  • pillow, PyPI1.4OSV
  • pillow, PyPI1.5OSV
  • pillow, PyPI1.6OSV
  • pillow, PyPI1.7.0OSV
  • pillow, PyPI1.7.1OSV
  • pillow, PyPI1.7.2OSV
  • pillow, PyPI1.7.3OSV
  • pillow, PyPI1.7.4OSV
  • pillow, PyPI1.7.5OSV
  • pillow, PyPI1.7.6OSV
  • pillow, PyPI1.7.7OSV
  • pillow, PyPI1.7.8OSV
  • pillow, PyPI10.0.0OSV
  • pillow, PyPI10.0.1OSV
  • pillow, PyPI10.1.0OSV
  • pillow, PyPI10.2.0OSV
  • pillow, PyPI10.3.0OSV
  • pillow, PyPI10.4.0OSV
  • pillow, PyPI11.0.0OSV
  • pillow, PyPI11.1.0OSV
  • pillow, PyPI11.2.1OSV
  • pillow, PyPI11.3.0OSV
  • pillow, PyPI12.0.0OSV
  • pillow, PyPI12.1.0OSV
  • pillow, PyPI12.1.1OSV
  • pillow, PyPI12.2.0OSV
  • pillow, PyPI12.3.0OSV
  • pillow, PyPI2.0.0OSV
  • pillow, PyPI2.1.0OSV
  • pillow, PyPI2.2.0OSV
  • pillow, PyPI2.2.1OSV
  • pillow, PyPI2.2.2OSV
  • pillow, PyPI2.3.0OSV
  • pillow, PyPI2.3.1OSV
  • pillow, PyPI2.3.2OSV
  • pillow, PyPI2.4.0OSV
  • pillow, PyPI2.5.0OSV
  • pillow, PyPI2.5.1OSV
  • pillow, PyPI2.5.2OSV
  • pillow, PyPI2.5.3OSV
  • pillow, PyPI2.6.0OSV
  • pillow, PyPI2.6.1OSV
  • pillow, PyPI2.6.2OSV
  • pillow, PyPI2.7.0OSV
  • pillow, PyPI2.8.0OSV
  • pillow, PyPI2.8.1OSV

References 5