diff mbox series

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

Message ID 20261201092150.2476960-1-Poornima.Lokesh@windriver.com
State New
Headers show
Series [meta-python,wrynose] python3-pillow: fix CVE-2026-112900 | expand

Commit Message

Poornima Lokesh Dec. 1, 2026, 9:21 a.m. UTC
Pillow is a Python imaging library. From 2.6.0 until 13.0.0, Pillow is
vulnerable to argument injection when invoking Ghostscript for EPS
input. EpsImagePlugin.Ghostscript passes a caller-controlled input
filename after -f without converting it to a safe absolute path, so a
name beginning with a hyphen can be interpreted as a Ghostscript option.
An attacker who controls the filename can inject Ghostscript arguments.
Arbitrary command execution specifically requires a leading @
argument-file filename and control of the referenced text file
containing additional Ghostscript arguments; the reported chain
reproduces with the default -dSAFER invocation. This issue is fixed in
version 13.0.0.

Reference:
[https://nvd.nist.gov/vuln/detail/cve-2026-112900]
[https://security-tracker.debian.org/tracker/CVE-2026-112900]

Backport the patch to fix CVE-2026-112900
[https://github.com/python-pillow/Pillow/commit/a2c363141da31a265dd536c945677db4b64f3ec9]

Signed-off-by: Poornima Lokesh <Poornima.Lokesh@windriver.com>
---
 .../python3-pillow/CVE-2026-112900.patch      | 59 +++++++++++++++++++
 .../python/python3-pillow_12.2.0.bb           |  1 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112900.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112900.patch b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112900.patch
new file mode 100644
index 0000000000..08ee228d5c
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112900.patch
@@ -0,0 +1,59 @@ 
+From a2c363141da31a265dd536c945677db4b64f3ec9 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <3112309+radarhere@users.noreply.github.com>
+Date: Thu, 1 Oct 2026 14:44:00 +1000
+Subject: [PATCH] Transform EPS file name to an absolute path before invoking
+ Ghostscript (#10090)
+
+CVE: CVE-2026-112900
+
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/a2c363141da31a265dd536c945677db4b64f3ec9]
+
+Signed-off-by: Poornima Lokesh <Poornima.Lokesh@windriver.com>
+---
+ Tests/test_file_eps.py    | 16 ++++++++++++++++
+ src/PIL/EpsImagePlugin.py |  5 ++++-
+ 2 files changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py
+index 70eced62ac9..035b2f73232 100644
+--- a/Tests/test_file_eps.py
++++ b/Tests/test_file_eps.py
+@@ -301,6 +301,22 @@ def test_image_mode_not_supported(tmp_path: Path) -> None:
+         im.save(tmpfile)
+ 
+ 
++@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
++def test_filename_not_parsed_as_ghostscript_argument(
++    tmp_path: Path, monkeypatch: pytest.MonkeyPatch
++) -> None:
++    # Check that a filename starting with "-" is not passed to Ghostscript unmodified
++    # If it was, the help functionality would be triggered instead
++    monkeypatch.chdir(tmp_path)
++    name = "-h"
++    with open(name, "wb") as f:
++        f.write(b"\n".join(simple_eps_file))
++
++    with Image.open(name) as im:
++        im.load()
++        assert im.size == (100, 100)
++
++
+ @pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
+ @skip_unless_feature("zlib")
+ def test_render_scale1() -> None:
+diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py
+index 5eaefe339a5..a3336894ada 100644
+--- a/src/PIL/EpsImagePlugin.py
++++ b/src/PIL/EpsImagePlugin.py
+@@ -103,7 +103,10 @@ def Ghostscript(
+ 
+     infile_temp = None
+     if hasattr(fp, "name") and os.path.exists(fp.name):
+-        infile = fp.name
++        # Make the path absolute so that a filename beginning with "-" or "@"
++        # can never be interpreted by Ghostscript's argument parser
++        # as an option or an @-file token
++        infile = os.path.abspath(fp.name)
+     else:
+         in_fd, infile_temp = tempfile.mkstemp()
+         os.close(in_fd)
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 f1d5b66434..d30f8508d8 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
@@ -18,6 +18,7 @@  SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
            file://CVE-2026-59203.patch \
            file://CVE-2026-59205.patch \
            file://CVE-2026-112393.patch \
+           file://CVE-2026-112900.patch \
            "
 SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"