diff mbox series

[meta-python,wrynose] python3-pillow: fix CVE-2026-59204

Message ID 20260922162751.3658333-1-aravind.bandari@windriver.com
State New
Headers show
Series [meta-python,wrynose] python3-pillow: fix CVE-2026-59204 | expand

Commit Message

Aravind Bandari Sept. 22, 2026, 4:27 p.m. UTC
Pillow 8.2.0 through 12.2.0 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.

Calculate JPEG2000 total_component_width for each tile in isolation.

Backport the patch to fix CVE-2026-59204
https://github.com/python-pillow/Pillow/commit/13ada41172142f2fd9f0906f615a00ea623a11ca

Reference:
https://nvd.nist.gov/vuln/detail/CVE-2026-59204

Signed-off-by: Aravind Bandari <aravind.bandari@windriver.com>
---
 .../python3-pillow/CVE-2026-59204.patch       | 37 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59204.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59204.patch b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59204.patch
new file mode 100644
index 0000000000..a706271c00
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59204.patch
@@ -0,0 +1,37 @@ 
+From ca189db3cc625bf06cef39b09c8a61d91e7be080 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <3112309+radarhere@users.noreply.github.com>
+Date: Mon, 22 Jun 2026 10:34:18 +1000
+Subject: [PATCH] Calculate JPEG2000 total_component_width for each tile in
+ isolation (#9704)
+
+CVE: CVE-2026-59204
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/13ada41172142f2fd9f0906f615a00ea623a11ca]
+Signed-off-by: Aravind Bandari <aravind.bandari@windriver.com>
+
+---
+ src/libImaging/Jpeg2KDecode.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libImaging/Jpeg2KDecode.c b/src/libImaging/Jpeg2KDecode.c
+index 1123d7bc9..536313471 100644
+--- a/src/libImaging/Jpeg2KDecode.c
++++ b/src/libImaging/Jpeg2KDecode.c
+@@ -645,7 +645,6 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) {
+     size_t tile_bytes = 0;
+     unsigned n, tile_height, tile_width;
+     int subsampling;
+-    int total_component_width = 0;
+ 
+     stream = opj_stream_create(BUFFER_SIZE, OPJ_TRUE);
+ 
+@@ -851,6 +850,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) {
+          a, and then a malicious file could have a smaller tile_bytes
+         */
+ 
++        int total_component_width = 0;
+         for (n = 0; n < tile_info.nb_comps; n++) {
+             // see csize /acsize calcs
+             int csize = (image->comps[n].prec + 7) >> 3;
+-- 
+2.53.0
+
diff --git a/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb b/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
index f3fcb2d3c1..1dcaeacd93 100644
--- a/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
+++ b/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
@@ -7,6 +7,7 @@  LIC_FILES_CHKSUM = "file://LICENSE;md5=a6f0ac3777cfc96ded1b825e32ae7c99"
 
 SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;tag=${PV} \
            file://0001-support-cross-compiling.patch \
+           file://CVE-2026-59204.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"