CVE-2026-59204
JSON

8.7high

Pillow JPEG2000 tiled decode retains a growing scratch buffer and can be used for denial of service

Severity
8.7high CVSS:4.0 by GitHub_M
Exploit likelihood
0.39% (higher than 34% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-vjc4-5qp5-m44jBIT-PILLOW-2026-59204PYSEC-2026-3496

Description

Pillow is a Python imaging library. From 8.2.0 through 12.2.0, src/libImaging/Jpeg2KDecode.c accumulates total_component_width across every tile in a JPEG2000 image instead of recomputing it per tile, allowing a crafted tiled JPEG2000 file to force substantially higher transient memory usage and trigger out-of-memory failures during decoding. This issue is fixed in version 12.3.0.

Affected

Product or packageVersionsReported by
python-pillow Pillow>= 8.2.0, < 12.3.0CVE List
pillow (PyPI)from 8.2.0 before 12.3.0GitHub Advisory Database, PyPA Advisory Database
python pillowfrom 8.2.0 before 12.3.0NVD
pillow (Bitnami)from 8.2.0 before 12.3.0Bitnami Vulnerability Database

All scores

GitHub_M8.7high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Bitnami Vulnerability Databasehigh rating

Classification

CWE-770CWE-789

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

Pillow is a Python imaging library. From 8.2.0 through 12.2.0, src/libImaging/Jpeg2KDecode.c accumulates total_component_width across every tile in a JPEG2000 image instead of recomputing it per tile, allowing a crafted tiled JPEG2000 file to force substantially higher transient memory usage and trigger out-of-memory failures during decoding. This issue is fixed in version 12.3.0.

GitHub Advisory Database
Summary

src/libImaging/Jpeg2KDecode.c:853 accumulates total_component_width across every tile in a JPEG2000 image instead of recomputing it per tile. That accumulated value is then used in the tile_bytes calculation at src/libImaging/Jpeg2KDecode.c:868, which can make the decoder grow state->buffer via realloc at src/libImaging/Jpeg2KDecode.c:876 up to roughly one full image's decompressed size even when each tile is small. A crafted tiled JPEG2000 file can therefore force substantially higher transient memory usage and trigger out-of-memory failures during decoding. Based on current evidence, the supported impact is denial of service, not memory corruption.

Details
  • Location: src/libImaging/Jpeg2KDecode.c:853
  • Root cause: total_component_width is initialized only once before the tile loop and keeps growing across tiles. It is then used to derive tile_bytes, so later tiles are treated as if they had the combined component width of all earlier tiles.
  • Dangerous operation: tile_bytes is promoted into tile_info.data_size, then state->buffer is grown with realloc at src/libImaging/Jpeg2KDecode.c:876.
  • Reachability: any attacker-controlled JPEG2000 image with many tiles reaches this path during normal Image.open(...).load() decoding.
PoC

The attached helper script and testcase were used: exercise_j2k_tile_realloc.zip

Generate the testcase:

pythonexercise_j2k_tile_realloc.py make poc_3664_rgba_tile1832.jp2 \
  --size 3664 --tile 1832

Expected geometry from the helper:

  • image size: 3664 x 3664
  • mode: RGBA
  • tile size: 1832 x 1832 (2x2 tiles)
  • image_bytes=53699584
  • uncapped RSS observed:
    • vulnerable build: maxrss_kb=180264
    • fixed comparison build: maxrss_kb=138404

Load it with the current vulnerable build:

python exercise_j2k_tile_realloc.py load poc_3664_rgba_tile1832.jp2

Load it again under a 160 MB address-space cap:

python exercise_j2k_tile_realloc.py load poc_3664_rgba_tile1832.jp2 --limit-mb 160
Impact

Conservative impact: denial of service through memory exhaustion during JPEG2000 decoding.

NVD (es)

Pillow es una biblioteca de procesamiento de imágenes de Python. Desde la versión 8.2.0 hasta la 12.2.0, src/libImaging/Jpeg2KDecode.c acumula total_component_width en cada mosaico de una imagen JPEG2000 en lugar de recalcularlo por mosaico, lo que permite que un archivo JPEG2000 en mosaico manipulado fuerce un uso de memoria transitoria sustancialmente mayor y desencadene fallos por falta de memoria durante la decodificación. Este problema se ha solucionado en la versión 12.3.0.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-59204 changed 2026-07-21CVE Terms of Use
GitHub Advisory DatabaseGHSA-vjc4-5qp5-m44j changed 2026-09-10CC-BY-4.0
NVDCVE-2026-59204 changed 2026-10-24Public domain
PyPA Advisory DatabasePYSEC-2026-3496 changed 2026-07-23CC-BY-4.0
Bitnami Vulnerability DatabaseBIT-PILLOW-2026-59204 changed 2026-09-08Apache-2.0