Skip to contentSkip to conversation

python3-pillow: Security fixes

PATCH New Yogita Urade 1 participant 10 messages Oct 16

lore
Share & tools
lore
#0 lore raw

cover python3-pillow: Security fixes

Backport fixes for eight upstream security-fix patches covering ten CVEs to python3-pillow 12.2.0 in Wrynose.

One upstream commit fixes CVE-2026-54059, CVE-2026-54060 and CVE-2026-55379.

The series also marks CVE-2026-55798 as not applicable because it affects Pillow’s Windows viewer command handling, which is not used by the Linux target.

The series updates the recipe to apply the fixes. The patches retain upstream references.

Yogita Urade (9):
python3-pillow: Fix CVE-2026-54059 CVE-2026-54060 CVE-2026-55379
python3-pillow: Fix CVE-2026-55380
python3-pillow: Fix CVE-2026-59197
python3-pillow: Fix CVE-2026-59198
python3-pillow: Fix CVE-2026-59199
python3-pillow: Fix CVE-2026-59200
python3-pillow: Fix CVE-2026-59203
python3-pillow: Fix CVE-2026-59205
python3-pillow: CVE_STATUS for CVE-2026-55798

 ...-54059_CVE-2026-54060_CVE-2026-55379.patch | 168 ++++++++++++++++++
 .../python3-pillow/CVE-2026-55380.patch       |  62 +++++++
 .../python3-pillow/CVE-2026-59197.patch       |  74 ++++++++
 .../python3-pillow/CVE-2026-59198.patch       |  57 ++++++
 .../python3-pillow/CVE-2026-59199.patch       |  84 +++++++++
 .../python3-pillow/CVE-2026-59200.patch       |  82 +++++++++
 .../python3-pillow/CVE-2026-59203.patch       |  45 +++++
 .../python3-pillow/CVE-2026-59205.patch       |  66 +++++++
 .../python/python3-pillow_12.2.0.bb           |   9 +
 9 files changed, 647 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-55380.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59197.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59198.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59199.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59200.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59203.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59205.patch
Signature · 1 line
2.35.6
#1 lore raw

PATCH 1/9 python3-pillow: Fix CVE-2026-54059 CVE-2026-54060 CVE-2026-55379

This patch applies the upstream fix as referenced in [2], [3] and [4], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/0a263e6264aa5399988d9acd3bbfbca2ca3ec77d
[2] https://nvd.nist.gov/vuln/detail/cve-2026-54059
[3] https://nvd.nist.gov/vuln/detail/CVE-2026-54060
[4] https://nvd.nist.gov/vuln/detail/cve-2026-55379

---
 ...-54059_CVE-2026-54060_CVE-2026-55379.patch | 168 ++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |   1 +
 2 files changed, 169 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch new file +168 -0
new file mode 100644
index 0000000000..72a83a178e
@@ -0,0 +1,168 @@
+From 7d525ae2ccf9109079f6f640ad88c8cb117853d9 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Tue, 23 Jun 2026 11:41:22 +1000
+Subject: [PATCH] Add decompression bomb checks to FontFile classes (#9711)
+
+CVE: CVE-2026-54059 CVE-2026-54060 CVE-2026-55379
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/0a263e6264aa5399988d9acd3bbfbca2ca3ec77d]
+
+Backport Changes:
+- Wrynose 12.2.0 handles standard and jumbo PCF metrics in separate loops,
+  so the decompression-bomb check is added at both call sites in
+  src/PIL/PcfFontFile.py file, upstream’s shared append helper needs only
+  one check.
+
+(cherry picked from commit 0a263e6264aa5399988d9acd3bbfbca2ca3ec77d)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_font_bdf.py | 10 +++++++++-
+ Tests/test_font_pcf.py | 21 ++++++++++++++++++++-
+ Tests/test_fontfile.py |  7 +++++++
+ src/PIL/BdfFontFile.py |  1 +
+ src/PIL/FontFile.py    |  3 ++-
+ src/PIL/PcfFontFile.py |  2 ++
+ 6 files changed, 41 insertions(+), 3 deletions(-)
+diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py
+index 321dd8560..d5b080add 100644
+--- a/Tests/test_font_pcf.py
++++ b/Tests/test_font_pcf.py
+@@ -1,12 +1,13 @@
+ from __future__ import annotations
+ 
+ import os
++from io import BytesIO
+ from pathlib import Path
+ from typing import AnyStr
+ 
+ import pytest
+ 
+-from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile
++from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile, _binary
+ 
+ from .helper import (
+     assert_image_equal_tofile,
+@@ -117,3 +118,21 @@ def test_high_characters(request: pytest.FixtureRequest, tmp_path: Path) -> None
+     _test_high_characters(request, tmp_path, message)
+     # accept bytes instances.
+     _test_high_characters(request, tmp_path, message.encode("latin1"))
++
++
++def test_decompression_bomb() -> None:
++    with open(fontname, "rb") as fp:
++        data = fp.read()
++    b = BytesIO(
++        data[:900]
++        + _binary.o32le(0)  # jumbo format
++        + _binary.o32le(1)  # number of metrics
++        + _binary.o16le(0)  # left
++        + _binary.o16le(65535)  # right
++        + _binary.o16le(0)  # width
++        + _binary.o16le(0)  # ascent
++        + _binary.o16le(65535)  # descent
++        + _binary.o16le(0)  # attributes
++    )
++    with pytest.raises(Image.DecompressionBombError):
++        PcfFontFile.PcfFontFile(b)
+diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py
+index b923293b0..52947ff04 100644
+--- a/src/PIL/PcfFontFile.py
++++ b/src/PIL/PcfFontFile.py
+@@ -170,6 +170,7 @@ class PcfFontFile(FontFile.FontFile):
+                 descent = i8(fp.read(1)) - 128
+                 xsize = right - left
+                 ysize = ascent + descent
++                Image._decompression_bomb_check((xsize, ysize))
+                 append((xsize, ysize, left, right, width, ascent, descent, 0))
+ 
+         else:
+@@ -183,6 +184,7 @@ class PcfFontFile(FontFile.FontFile):
+                 attributes = i16(fp.read(2))
+                 xsize = right - left
+                 ysize = ascent + descent
++                Image._decompression_bomb_check((xsize, ysize))
+                 append((xsize, ysize, left, right, width, ascent, descent, attributes))
+ 
+         return metrics
+
+diff --git a/Tests/test_font_bdf.py b/Tests/test_font_bdf.py
+index b4155c8793b..033b5f8fbd5 100644
+--- a/Tests/test_font_bdf.py
++++ b/Tests/test_font_bdf.py
+@@ -4,7 +4,7 @@
+ 
+ import pytest
+ 
+-from PIL import BdfFontFile, FontFile
++from PIL import BdfFontFile, FontFile, Image
+ 
+ filename = "Tests/images/courB08.bdf"
+ 
+@@ -24,6 +24,14 @@ def test_zero_width_chars() -> None:
+     BdfFontFile.BdfFontFile(io.BytesIO(data))
+ 
+ 
++def test_decompression_bomb() -> None:
++    with open(filename, "rb") as fp:
++        data = fp.read()
++    b = io.BytesIO(data.replace(b"BBX 1 1", b"BBX 13378 13378"))
++    with pytest.raises(Image.DecompressionBombError):
++        BdfFontFile.BdfFontFile(b)
++
++
+ def test_invalid_file() -> None:
+     with open("Tests/images/flower.jpg", "rb") as fp:
+         with pytest.raises(SyntaxError):
+
+diff --git a/Tests/test_fontfile.py b/Tests/test_fontfile.py
+index 1a9069fd892..bf857e230b8 100644
+--- a/Tests/test_fontfile.py
++++ b/Tests/test_fontfile.py
+@@ -30,6 +30,13 @@ def test_compile() -> None:
+     assert font.ysize == 2
+ 
+ 
++def test_decompression_bomb() -> None:
++    font = FontFile.FontFile()
++    font.glyph[0] = ((0, 0), (0, 0, 0, 0), (0, 0, 10000, 10000), Image.new("L", (0, 0)))
++    with pytest.raises(Image.DecompressionBombError):
++        font.compile()
++
++
+ def test_save(tmp_path: Path) -> None:
+     tempname = str(tmp_path / "temp.pil")
+ 
+
+diff --git a/src/PIL/BdfFontFile.py b/src/PIL/BdfFontFile.py
+index 1c8c28ff038..098779bfd6e 100644
+--- a/src/PIL/BdfFontFile.py
++++ b/src/PIL/BdfFontFile.py
+@@ -70,6 +70,7 @@ def bdf_char(
+     # and x and y displacement (BBxoff0, BByoff0)
+     # of the lower left corner from the origin of the character.
+     width, height, x_disp, y_disp = (int(p) for p in props["BBX"].split())
++    Image._decompression_bomb_check((width, height))
+ 
+     # The word DWIDTH
+     # followed by the width in x and y of the character in device pixels.
+
+diff --git a/src/PIL/FontFile.py b/src/PIL/FontFile.py
+index 341431d3f45..c3be4ae3ddd 100644
+--- a/src/PIL/FontFile.py
++++ b/src/PIL/FontFile.py
+@@ -74,7 +74,7 @@ def compile(self) -> None:
+             if glyph:
+                 d, dst, src, im = glyph
+                 h = max(h, src[3] - src[1])
+-                w = w + (src[2] - src[0])
++                w += src[2] - src[0]
+                 if w > WIDTH:
+                     lines += 1
+                     w = src[2] - src[0]
+@@ -89,6 +89,7 @@ def compile(self) -> None:
+         self.ysize = h
+ 
+         # paste glyphs into bitmap
++        Image._decompression_bomb_check((xsize, ysize))
+         self.bitmap = Image.new("1", (xsize, ysize))
+         self.metrics: list[
+             tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int]]
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index d5c65fbd11..aa7de55fab 100644
@@ -9,6 +9,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://0001-support-cross-compiling.patch \
            file://CVE-2026-54058.patch \
            file://CVE-2026-59204.patch \
+           file://CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#2 lore raw

PATCH 2/9 python3-pillow: Fix CVE-2026-55380

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/f39b0ae6624eb2d7c5c5d651d9bb5fdbd96a8675
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-phj9-mv4w-65pm

---
 .../python3-pillow/CVE-2026-55380.patch       | 62 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-55380.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-55380.patch new file +62 -0
new file mode 100644
index 0000000000..16321294c9
@@ -0,0 +1,62 @@
+From 176781ac99ebf9aa5486384e6e2e4896b30d95b5 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Sun, 21 Jun 2026 14:06:24 +1000
+Subject: [PATCH] Add decompression bomb check to GdImageFile (#9693)
+
+CVE: CVE-2026-55380
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/f39b0ae6624eb2d7c5c5d651d9bb5fdbd96a8675]
+
+(cherry picked from commit f39b0ae6624eb2d7c5c5d651d9bb5fdbd96a8675)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_file_gd.py  | 8 +++++++-
+ src/PIL/GdImageFile.py | 3 ++-
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/Tests/test_file_gd.py b/Tests/test_file_gd.py
+index 8a49fd4fa..7d9e85976 100644
+--- a/Tests/test_file_gd.py
++++ b/Tests/test_file_gd.py
+@@ -4,7 +4,7 @@ from io import BytesIO
+ 
+ import pytest
+ 
+-from PIL import GdImageFile, UnidentifiedImageError
++from PIL import GdImageFile, Image, UnidentifiedImageError, _binary
+ 
+ from .helper import assert_image_similar_tofile
+ 
+@@ -31,6 +31,12 @@ def test_bad_mode() -> None:
+         GdImageFile.open(TEST_GD_FILE, "bad mode")
+ 
+ 
++def test_decompression_bomb() -> None:
++    b = BytesIO(_binary.o16be(65535) + _binary.o16be(50000) + _binary.o16be(50000))
++    with pytest.raises(Image.DecompressionBombError):
++        GdImageFile.open(b)
++
++
+ def test_invalid_file() -> None:
+     invalid_file = "Tests/images/flower.jpg"
+ 
+diff --git a/src/PIL/GdImageFile.py b/src/PIL/GdImageFile.py
+index d73bc1982..4ff96f1fa 100644
+--- a/src/PIL/GdImageFile.py
++++ b/src/PIL/GdImageFile.py
+@@ -30,7 +30,7 @@ from __future__ import annotations
+ 
+ from typing import IO
+ 
+-from . import ImageFile, ImagePalette, UnidentifiedImageError
++from . import Image, ImageFile, ImagePalette, UnidentifiedImageError
+ from ._binary import i16be as i16
+ from ._binary import i32be as i32
+ from ._typing import StrOrBytesPath
+@@ -59,6 +59,7 @@ class GdImageFile(ImageFile.ImageFile):
+ 
+         self._mode = "P"
+         self._size = i16(s, 2), i16(s, 4)
++        Image._decompression_bomb_check(self.size)
+ 
+         true_color = s[6]
+         true_color_offset = 2 if true_color else 0
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index aa7de55fab..d5576560e7 100644
@@ -10,6 +10,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-54058.patch \
            file://CVE-2026-59204.patch \
            file://CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch \
+           file://CVE-2026-55380.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#3 lore raw

PATCH 3/9 python3-pillow: Fix CVE-2026-59197

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/cce3bdb867c77a3420261ed1bfdb6b0787ec8fc1
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-xj96-63gp-2gmr

---
 .../python3-pillow/CVE-2026-59197.patch       | 74 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 75 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59197.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59197.patch new file +74 -0
new file mode 100644
index 0000000000..415866a19e
@@ -0,0 +1,74 @@
+From cce3bdb867c77a3420261ed1bfdb6b0787ec8fc1 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Sat, 20 Jun 2026 11:53:14 +1000
+Subject: [PATCH] Validate large filter sizes when initializing RankFilter
+ (#9695)
+
+CVE: CVE-2026-59197
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/cce3bdb867c77a3420261ed1bfdb6b0787ec8fc1]
+
+Backport Changes:
+- Adapted the ImagingExpand check to Pillow 12.2.0's two-margin API.
+  It checks the larger margin and guards against zero before division;
+  the regression test passes both margins.
+
+(cherry picked from commit cce3bdb867c77a3420261ed1bfdb6b0787ec8fc1)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_image_filter.py | 5 +++++
+ src/PIL/ImageFilter.py     | 3 +++
+ src/libImaging/Filter.c    | 5 +++++
+ 3 files changed, 13 insertions(+)
+
+diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py
+index e566cd055..4bed605 100644
+--- a/Tests/test_image_filter.py
++++ b/Tests/test_image_filter.py
+@@ -141,6 +141,11 @@ def test_rankfilter_properties() -> None:
+     assert rankfilter.size == 1
+     assert rankfilter.rank == 2
+ 
++    with pytest.raises(ValueError, match="filter size too large"):
++        ImageFilter.RankFilter(23171, 1)
++    im = Image.new("1", (1, 1))
++    with pytest.raises(ValueError, match="filter size too large"):
++        im.im.expand(23171, 23171)
+ 
+ def test_builtinfilter_p() -> None:
+     builtin_filter = ImageFilter.BuiltinFilter()
+
+diff --git a/src/PIL/ImageFilter.py b/src/PIL/ImageFilter.py
+index 9326eeeda..2c73c27bc 100644
+--- a/src/PIL/ImageFilter.py
++++ b/src/PIL/ImageFilter.py
+@@ -99,6 +99,9 @@ class RankFilter(Filter):
+     name = "Rank"
+ 
+     def __init__(self, size: int, rank: int) -> None:
++        if size * size * 4 > (2**31 - 1):
++            msg = "filter size too large"
++            raise ValueError(msg)
+         self.size = size
+         self.rank = rank
+
+diff --git a/src/libImaging/Filter.c b/src/libImaging/Filter.c
+index cefb8fc..5288754 100644
+--- a/src/libImaging/Filter.c
++++ b/src/libImaging/Filter.c
+@@ -54,11 +54,16 @@ Imaging
+ ImagingExpand(Imaging imIn, int xmargin, int ymargin) {
+     Imaging imOut;
+     int x, y;
++    int margin;
+     ImagingSectionCookie cookie;
+ 
+     if (xmargin < 0 && ymargin < 0) {
+         return (Imaging)ImagingError_ValueError("bad kernel size");
+     }
++    margin = xmargin > ymargin ? xmargin : ymargin;
++    if (margin > 0 && margin > (INT_MAX / (int)sizeof(FLOAT32)) / margin) {
++        return (Imaging)ImagingError_ValueError("filter size too large");
++    }
+ 
+     imOut = ImagingNewDirty(
+         imIn->mode, imIn->xsize + 2 * xmargin, imIn->ysize + 2 * ymargin
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index d5576560e7..f9d91e0889 100644
@@ -11,6 +11,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-59204.patch \
            file://CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch \
            file://CVE-2026-55380.patch \
+           file://CVE-2026-59197.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#4 lore raw

PATCH 4/9 python3-pillow: Fix CVE-2026-59198

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/eada3cbd7fb9963ee90673fb7b5270124a0d5f4b
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-fj7v-r99m-22gq

---
 .../python3-pillow/CVE-2026-59198.patch       | 57 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59198.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59198.patch new file +57 -0
new file mode 100644
index 0000000000..e794d26832
@@ -0,0 +1,57 @@
+From 49ea10f3c83475ad30c1b0581e2aaa3e75f4af4f Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Tue, 23 Jun 2026 09:46:33 +1000
+Subject: [PATCH] Prevent saving 1 mode images as TGA with run-length encoding
+ (#9709)
+
+CVE: CVE-2026-59198
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/eada3cbd7fb9963ee90673fb7b5270124a0d5f4b]
+
+(cherry picked from commit eada3cbd7fb9963ee90673fb7b5270124a0d5f4b)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_file_tga.py    | 12 +++++++++++-
+ src/PIL/TgaImagePlugin.py |  4 ++++
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py
+index 7ec562342..82bcf48ca 100644
+--- a/Tests/test_file_tga.py
++++ b/Tests/test_file_tga.py
+@@ -179,10 +179,20 @@ def test_save_wrong_mode(tmp_path: Path) -> None:
+     im = hopper("PA")
+     out = tmp_path / "temp.tga"
+ 
+-    with pytest.raises(OSError):
++    with pytest.raises(OSError, match="cannot write mode PA as TGA"):
+         im.save(out)
+ 
+ 
++def test_save_1_mode_rle(tmp_path: Path) -> None:
++    im = Image.new("1", (1, 1))
++    out = tmp_path / "temp.tga"
++
++    with pytest.raises(
++        OSError, match="cannot write mode 1 as TGA with run-length encoding"
++    ):
++        im.save(out, compression="tga_rle")
++
++
+ def test_save_mapdepth() -> None:
+     # This image has been manually hexedited from 200x32_p_bl_raw.tga
+     # to include an origin
+diff --git a/src/PIL/TgaImagePlugin.py b/src/PIL/TgaImagePlugin.py
+index b2989a4b7..8fd63b1df 100644
+--- a/src/PIL/TgaImagePlugin.py
++++ b/src/PIL/TgaImagePlugin.py
+@@ -205,6 +205,10 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
+         compression = im.encoderinfo.get("compression", im.info.get("compression"))
+         rle = compression == "tga_rle"
+     if rle:
++        if im.mode == "1":
++            msg = f"cannot write mode {im.mode} as TGA with run-length encoding"
++            raise OSError(msg)
++
+         imagetype += 8
+ 
+     id_section = im.encoderinfo.get("id_section", im.info.get("id_section", ""))
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index f9d91e0889..331b99622b 100644
@@ -12,6 +12,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-54059_CVE-2026-54060_CVE-2026-55379.patch \
            file://CVE-2026-55380.patch \
            file://CVE-2026-59197.patch \
+           file://CVE-2026-59198.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#5 lore raw

PATCH 5/9 python3-pillow: Fix CVE-2026-59199

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/ceefc348eb3c3844c7f9796ef2cc3a7dd5fbba7b
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-6r8x-57c9-28j4

---
 .../python3-pillow/CVE-2026-59199.patch       | 84 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 85 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59199.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59199.patch new file +84 -0
new file mode 100644
index 0000000000..4418b73e99
@@ -0,0 +1,84 @@
+From 0d706085cfb87ffac6eea54f1a42ce8bd3f16513 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Mon, 22 Jun 2026 12:56:41 +1000
+Subject: [PATCH] Use int64_t to calculate paste box dimensions (#9703)
+
+CVE: CVE-2026-59199
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/ceefc348eb3c3844c7f9796ef2cc3a7dd5fbba7b]
+
+(cherry picked from commit ceefc348eb3c3844c7f9796ef2cc3a7dd5fbba7b)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_image_paste.py | 14 ++++++++++++++
+ src/libImaging/Paste.c    | 12 ++++++------
+ 2 files changed, 20 insertions(+), 6 deletions(-)
+
+diff --git a/Tests/test_image_paste.py b/Tests/test_image_paste.py
+index 37e4df103..f9b72e46f 100644
+--- a/Tests/test_image_paste.py
++++ b/Tests/test_image_paste.py
+@@ -357,6 +357,20 @@ class TestImagingPaste:
+         im.copy().paste(im2)
+         im.copy().paste(im2, (0, 0))
+ 
++    @pytest.mark.parametrize(
++        "box",
++        (
++            (2**31 - 1, 0, -(2**31), 1),
++            (0, 2**31 - 1, 1, -(2**31)),
++        ),
++    )
++    def test_overflow(self, box: tuple[int, int, int, int]) -> None:
++        im = Image.new("1", (1, 1))
++        im.paste(1, box)
++
++        with pytest.raises(ValueError, match="images do not match"):
++            im.paste(im.copy(), box)
++
+     def test_incorrect_abbreviated_form(self) -> None:
+         im = Image.new("L", (1, 1))
+         with pytest.raises(ValueError):
+diff --git a/src/libImaging/Paste.c b/src/libImaging/Paste.c
+index f4b72c5d8..bf72d3a1c 100644
+--- a/src/libImaging/Paste.c
++++ b/src/libImaging/Paste.c
+@@ -274,7 +274,7 @@ int
+ ImagingPaste(
+     Imaging imOut, Imaging imIn, Imaging imMask, int dx0, int dy0, int dx1, int dy1
+ ) {
+-    int xsize, ysize;
++    int64_t xsize, ysize;
+     int pixelsize;
+     int sx0, sy0;
+     ImagingSectionCookie cookie;
+@@ -286,8 +286,8 @@ ImagingPaste(
+ 
+     pixelsize = imOut->pixelsize;
+ 
+-    xsize = dx1 - dx0;
+-    ysize = dy1 - dy0;
++    xsize = (int64_t)dx1 - dx0;
++    ysize = (int64_t)dy1 - dy0;
+ 
+     if (xsize != imIn->xsize || ysize != imIn->ysize || pixelsize != imIn->pixelsize) {
+         (void)ImagingError_Mismatch();
+@@ -598,7 +598,7 @@ ImagingFill2(
+     Imaging imOut, const void *ink, Imaging imMask, int dx0, int dy0, int dx1, int dy1
+ ) {
+     ImagingSectionCookie cookie;
+-    int xsize, ysize;
++    int64_t xsize, ysize;
+     int pixelsize;
+     int sx0, sy0;
+ 
+@@ -609,8 +609,8 @@ ImagingFill2(
+ 
+     pixelsize = imOut->pixelsize;
+ 
+-    xsize = dx1 - dx0;
+-    ysize = dy1 - dy0;
++    xsize = (int64_t)dx1 - dx0;
++    ysize = (int64_t)dy1 - dy0;
+ 
+     if (imMask && (xsize != imMask->xsize || ysize != imMask->ysize)) {
+         (void)ImagingError_Mismatch();
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index 331b99622b..5acd020d8f 100644
@@ -13,6 +13,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-55380.patch \
            file://CVE-2026-59197.patch \
            file://CVE-2026-59198.patch \
+           file://CVE-2026-59199.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#6 lore raw

PATCH 6/9 python3-pillow: Fix CVE-2026-59200

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/f7a31ea75e460e108c37126da1f47812f21f6b09
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-jjj6-mw9f-p565

---
 .../python3-pillow/CVE-2026-59200.patch       | 82 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 83 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59200.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59200.patch new file +82 -0
new file mode 100644
index 0000000000..ee5f0b6db5
@@ -0,0 +1,82 @@
+From 9ce0814ba3aec3d4ba57f15593ebe063bf5ea205 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Tue, 30 Jun 2026 09:17:05 +1000
+Subject: [PATCH] Add max_length to PdfStream decode() (#9718)
+
+CVE: CVE-2026-59200
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/f7a31ea75e460e108c37126da1f47812f21f6b09]
+
+(cherry picked from commit f7a31ea75e460e108c37126da1f47812f21f6b09)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_pdfparser.py | 11 +++++++++++
+ src/PIL/PdfParser.py    | 15 +++++++++------
+ 2 files changed, 20 insertions(+), 6 deletions(-)
+
+diff --git a/Tests/test_pdfparser.py b/Tests/test_pdfparser.py
+index cba6cd053..4c522eb7a 100644
+--- a/Tests/test_pdfparser.py
++++ b/Tests/test_pdfparser.py
+@@ -1,6 +1,7 @@
+ from __future__ import annotations
+ 
+ import time
++import zlib
+ 
+ import pytest
+ 
+@@ -95,6 +96,16 @@ def test_parsing() -> None:
+             assert time.strftime("%Y%m%d%H%M%S", getattr(d, name)) == value
+ 
+ 
++def test_pdfstream_flatedecode() -> None:
++    d = PdfDict({b"Filter": b"FlateDecode"})
++    buf = zlib.compress(b"test")
++    s = PdfStream(d, buf)
++    assert s.decode() == b"test"
++
++    with pytest.raises(ValueError, match="Decompressed data too large"):
++        s.decode(3)
++
++
+ def test_pdf_repr() -> None:
+     assert bytes(IndirectReference(1, 2)) == b"1 2 R"
+     assert bytes(IndirectObjectDef(*IndirectReference(1, 2))) == b"1 2 obj"
+diff --git a/src/PIL/PdfParser.py b/src/PIL/PdfParser.py
+index f7f3a4643..10079ac66 100644
+--- a/src/PIL/PdfParser.py
++++ b/src/PIL/PdfParser.py
+@@ -10,6 +10,8 @@ import time
+ import zlib
+ from typing import Any, NamedTuple
+ 
++from . import ImageFile
++
+ TYPE_CHECKING = False
+ if TYPE_CHECKING:
+     from typing import IO
+@@ -320,17 +322,18 @@ class PdfStream:
+         self.dictionary = dictionary
+         self.buf = buf
+ 
+-    def decode(self) -> bytes:
++    def decode(self, max_length: int = ImageFile.SAFEBLOCK) -> bytes:
+         try:
+             filter = self.dictionary[b"Filter"]
+         except KeyError:
+             return self.buf
+         if filter == b"FlateDecode":
+-            try:
+-                expected_length = self.dictionary[b"DL"]
+-            except KeyError:
+-                expected_length = self.dictionary[b"Length"]
+-            return zlib.decompress(self.buf, bufsize=int(expected_length))
++            dobj = zlib.decompressobj()
++            plaintext = dobj.decompress(self.buf, max_length)
++            if dobj.unconsumed_tail:
++                msg = "Decompressed data too large"
++                raise ValueError(msg)
++            return plaintext
+         else:
+             msg = f"stream filter {repr(filter)} unknown/unsupported"
+             raise NotImplementedError(msg)
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index 5acd020d8f..3a2efbf851 100644
@@ -14,6 +14,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-59197.patch \
            file://CVE-2026-59198.patch \
            file://CVE-2026-59199.patch \
+           file://CVE-2026-59200.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#7 lore raw

PATCH 7/9 python3-pillow: Fix CVE-2026-59203

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/03992618118b4a76b6163cd72ab5ecd684133b83
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-pg7v-jwj7-p798

---
 .../python3-pillow/CVE-2026-59203.patch       | 45 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59203.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59203.patch new file +45 -0
new file mode 100644
index 0000000000..73dad2b301
@@ -0,0 +1,45 @@
+From 157289420e2b730688452c58a95a89974b25538d Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Tue, 23 Jun 2026 09:20:48 +1000
+Subject: [PATCH] Raise ValueError if EPS BeginBinary bytecount is negative
+ (#9708)
+
+CVE: CVE-2026-59203
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/03992618118b4a76b6163cd72ab5ecd684133b83]
+
+(cherry picked from commit 03992618118b4a76b6163cd72ab5ecd684133b83)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_file_eps.py    | 4 ++++
+ src/PIL/EpsImagePlugin.py | 3 +++
+ 2 files changed, 7 insertions(+)
+
+diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py
+index d4e8db4f4..d1886e9e2 100644
+--- a/Tests/test_file_eps.py
++++ b/Tests/test_file_eps.py
+@@ -204,6 +204,10 @@ def test_begin_binary() -> None:
+     with Image.open(io.BytesIO(data)) as img:
+         assert img.size == (399, 480)
+ 
++    data[76867:76873] = b"    -1"
++    with pytest.raises(ValueError, match="BeginBinary bytecount cannot be negative"):
++        Image.open(io.BytesIO(data))
++
+ 
+ @mark_if_feature_version(
+     pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
+diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py
+index aeb7b0c93..363ba19e1 100644
+--- a/src/PIL/EpsImagePlugin.py
++++ b/src/PIL/EpsImagePlugin.py
+@@ -357,6 +357,9 @@ class EpsImageFile(ImageFile.ImageFile):
+                 trailer_reached = True
+             elif bytes_mv[:14] == b"%%BeginBinary:":
+                 bytecount = int(byte_arr[14:bytes_read])
++                if bytecount < 0:
++                    msg = "BeginBinary bytecount cannot be negative"
++                    raise ValueError(msg)
+                 self.fp.seek(bytecount, os.SEEK_CUR)
+             bytes_read = 0
+
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index 3a2efbf851..c9926ba076 100644
@@ -15,6 +15,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-59198.patch \
            file://CVE-2026-59199.patch \
            file://CVE-2026-59200.patch \
+           file://CVE-2026-59203.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#8 lore raw

PATCH 8/9 python3-pillow: Fix CVE-2026-59205

In reply to Yogita Urade

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

[1] https://github.com/python-pillow/Pillow/commit/a9ffc42bedf4fc0a7ef8d6486e7f9e81e3397721
[2] https://github.com/python-pillow/Pillow/security/advisories/GHSA-9hw9-ch79-4vh6

---
 .../python3-pillow/CVE-2026-59205.patch       | 66 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 67 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59205.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2026-59205.patch new file +66 -0
new file mode 100644
index 0000000000..5cac7e05d1
@@ -0,0 +1,66 @@
+From a9ffc42bedf4fc0a7ef8d6486e7f9e81e3397721 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <[email protected]>
+Date: Sat, 20 Jun 2026 21:18:14 +1000
+Subject: [PATCH] Raise error if image modes do not match ImageCms transform
+ modes (#9715)
+
+CVE: CVE-2026-59205
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/a9ffc42bedf4fc0a7ef8d6486e7f9e81e3397721]
+
+(cherry picked from commit 066e349b8e20f6e0400683ff988ac72eea24c049)
+(cherry picked from commit 7f6e9d696913bba9fd1a6cf0b53f4a313dc25329)
+(cherry picked from commit 642d806703c62d4160f3eb8ff25fb63cbedadd98)
+Signed-off-by: Yogita Urade <[email protected]>
+---
+ Tests/test_imagecms.py | 4 ++++
+ src/PIL/ImageCms.py    | 16 +++++++++-------
+ 2 files changed, 13 insertions(+), 7 deletions(-)
+
+diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py
+index d73ab34282b..3382a34e47c 100644
+--- a/Tests/test_imagecms.py
++++ b/Tests/test_imagecms.py
+@@ -196,6 +196,10 @@ def test_exceptions() -> None:
+     psRGB = ImageCms.createProfile("sRGB")
+     pLab = ImageCms.createProfile("LAB")
+     t = ImageCms.buildTransform(pLab, psRGB, "LAB", "RGB")
++    with pytest.raises(ValueError, match="mode mismatch"):
++        t.apply(hopper("RGBA"))
++    with pytest.raises(ValueError, match="mode mismatch"):
++        t.apply(hopper("LAB"), hopper("RGBA"))
+     with pytest.raises(ValueError, match="mode mismatch"):
+         t.apply_in_place(hopper("RGBA"))
+ 
+diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py
+index 513e28acf..388a9296f 100644
+--- a/src/PIL/ImageCms.py
++++ b/src/PIL/ImageCms.py
+@@ -317,19 +317,21 @@ class ImageCmsTransform(Image.ImagePointHandler):
+         return self.apply(im)
+ 
+     def apply(self, im: Image.Image, imOut: Image.Image | None = None) -> Image.Image:
+-        if imOut is None:
++        if im.mode != self.input_mode:
++            msg = "mode mismatch"
++            raise ValueError(msg)
++        if imOut is not None:
++            if imOut.mode != self.output_mode:
++                msg = "mode mismatch"
++                raise ValueError(msg)
++        else:
+             imOut = Image.new(self.output_mode, im.size, None)
+         self.transform.apply(im.getim(), imOut.getim())
+         imOut.info["icc_profile"] = self.output_profile.tobytes()
+         return imOut
+ 
+     def apply_in_place(self, im: Image.Image) -> Image.Image:
+-        if im.mode != self.output_mode:
+-            msg = "mode mismatch"
+-            raise ValueError(msg)  # wrong output mode
+-        self.transform.apply(im.getim(), im.getim())
+-        im.info["icc_profile"] = self.output_profile.tobytes()
+-        return im
++        return self.apply(im, im)
+ 
+ 
+ def get_display_profile(handle: SupportsInt | None = None) -> ImageCmsProfile | None:
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index c9926ba076..e5ef7b34bf 100644
@@ -16,6 +16,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-59199.patch \
            file://CVE-2026-59200.patch \
            file://CVE-2026-59203.patch \
+           file://CVE-2026-59205.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
 
Signature · 1 line
2.35.6
#9 lore raw

PATCH 9/9 python3-pillow: CVE_STATUS for CVE-2026-55798

In reply to Yogita Urade

Analysis:
- The vulnerable code is WindowsViewer.get_command() constructing an unescaped cmd.exe command from a file path. [1]
- Linux uses UnixViewer, which quotes the path, so this Windows command path is not used by the target recipe. [1]
- Hence marking this CVE not applicable for the Linux target.

[1] https://github.com/python-pillow/Pillow/security/advisories/GHSA-4x4j-2g7c-83w6

---
 meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb | 1 +
 1 file changed, 1 insertion(+)
meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb +1 -0
index e5ef7b34bf..33fd1d8872 100644
@@ -70,6 +70,7 @@ RDEPENDS:${PN}-ptest += " \
 "
 
 CVE_PRODUCT = "pillow"
+CVE_STATUS[CVE-2026-55798] = "not-applicable-platform: The CVE affects WindowsViewer/cmd.exe; the Linux target uses UnixViewer"
 
 
 RPROVIDES:${PN} += "python3-imaging"
Signature · 1 line
2.35.6