Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

github логотип

GHSA-58r4-6rv3-gfh8

Опубликовано: 20 окт. 2026
Источник: github
Github: Прошло ревью
CVSS4: 8.7

Описание

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

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.

Пакеты

Наименование

Pillow

pip
Затронутые версииВерсия исправления

<= 12.3.0

13.0.0

EPSS

Процентиль: 48%
0.00573
Низкий

8.7 High

CVSS4

Дефекты

CWE-787

Связанные уязвимости

CVSS3: 7.5
ubuntu
29 дней назад

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.

CVSS3: 7.5
redhat
29 дней назад

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.

CVSS3: 7.5
nvd
29 дней назад

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.

CVSS3: 7.5
debian
29 дней назад

Pillow is a Python imaging library. Prior to 13.0.0, Pillow's ImageMor ...

rocky
18 дней назад

Important: python-pillow security update

EPSS

Процентиль: 48%
0.00573
Низкий

8.7 High

CVSS4

Дефекты

CWE-787