HIGHCVSS v4 8.7Vulnerability

CVE-2026-112397

### 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 ```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(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.

Properties

Summary
Pillow: Out-of-bounds access in _imagingmorph on a zero-width image
Severity
high
Nvd fetched at
2026-10-20T21:14:08.448323+00:00
Epss score
0.00436
Cvss score
8.7
Cvss severity
HIGH
Retrieved at
2026-10-21T01:24:48+00:00
Ghsa published
2026-10-20T20:56:22Z
Source url
https://github.com/advisories/GHSA-58r4-6rv3-gfh8
Ghsa updated
2026-10-20T20:56:23Z
Ghsa id
GHSA-58r4-6rv3-gfh8
Last source
FIRST EPSS
Score
8.7
Cvss version
4.0
Cve id
CVE-2026-112397
Cvss vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
First seen by Signal
2026-10-20T00:27:55+00:00
Is ghsa only
false
Vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Published at
2026-10-19T22:17:06.970

Related Entities (3)

AFFECTS (1)

→[Software]pip/Pillow

HAS_WEAKNESS (1)

→[Weakness]Out-of-bounds Write

VULNERABLE_TO (1)

←[Software]pip/Pillow

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-112397 (CVSS v4 8.7) — Ninja Signal Threat Intelligence | Ninja Signal