Tetrak
GitHub ↗
Security · Pillow

A rank filter on a zero-size image dereferences a null pointer

Pillow: NULL dereference in ImagingExpand via rank filters on zero-size images

Advisory
CVE-2026-112392
Library
Pillow, pillow on PyPI
Published
Severity
not scored upstream
Affected
< 12.3.0
Fixed in
12.3.0
Reaches you
through another call

What triggers it

Applying a median, minimum, maximum or rank filter to an image with zero width or height.

What sillybos does

Refused by default

sillybos refuses the triggering file under its default policy, through the dimensions check.

The trigger is an image with a zero width or height, handed to a rank filter. A file whose header gives a zero dimension is refused under every policy before Pillow sees it, so from a file the image cannot come; only an image the program makes itself (Image.new with a zero side, or a crop to nothing) reaches the filter. The check claims the refusal for the file.

Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; confirmed by a person on 2026-11-03. Re-bucketed on 2026-11-03: the file that carries the trigger is refused.

Proved by this test in the sillybos suite, which builds the triggering file from bytes and checks that it is refused:

How to protect yourself

In general. Upgrade to Pillow 12.3.0.

Specifically. Run the check on files from outside, which refuses a zero dimension; and never filter an image whose size the program has reduced to nothing.

The general advice applies to every row here.

Sources