Skip to contentSkip to conversation

python3-pillow: Fix for CVE-2023-50447

PATCH New [email protected] 1 participant 1 message Feb 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python3-pillow: Fix for CVE-2023-50447

From: Vijay Anusuri <[email protected]>

Upstream-Status: Backport
[https://github.com/python-pillow/Pillow/commit/45c726fd4daa63236a8f3653530f297dc87b160a
&
https://github.com/python-pillow/Pillow/commit/0ca3c33c59927e1c7e0c14dbc1eea1dfb2431a80
&
https://github.com/python-pillow/Pillow/commit/557ba59d13de919d04b3fd4cdef8634f7d4b3348]

---
 .../python3-pillow/CVE-2023-50447-1.patch     | 31 +++++++++++
 .../python3-pillow/CVE-2023-50447-2.patch     | 54 +++++++++++++++++++
 .../python3-pillow/CVE-2023-50447-3.patch     | 44 +++++++++++++++
 .../python/python3-pillow_6.2.1.bb            |  3 ++
 4 files changed, 132 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch
meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-1.patch new file +31 -0
new file mode 100644
index 000000000..f9e3c4950
@@ -0,0 +1,31 @@
+From 45c726fd4daa63236a8f3653530f297dc87b160a Mon Sep 17 00:00:00 2001
+From: Eric Soroos <[email protected]>
+Date: Fri, 27 Oct 2023 11:21:18 +0200
+Subject: [PATCH] Don't allow __ or builtins in env dictionarys for
+ ImageMath.eval
+
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/45c726fd4daa63236a8f3653530f297dc87b160a]
+CVE: CVE-2023-50447
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/PIL/ImageMath.py | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py
+index 392151c10..4cea3855e 100644
+--- a/src/PIL/ImageMath.py
++++ b/src/PIL/ImageMath.py
+@@ -261,6 +261,10 @@ def eval(expression, _dict={}, **kw):
+     args.update(_dict)
+     args.update(kw)
+     for k, v in list(args.items()):
++        if '__' in k or hasattr(__builtins__, k):
++            msg = f"'{k}' not allowed"
++            raise ValueError(msg)
++
+         if hasattr(v, "im"):
+             args[k] = _Operand(v)
+ 
+-- 
+2.25.1
+
meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-2.patch new file +54 -0

54 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch new file +44 -0

44 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-pillow_6.2.1.bb +3 -0
index eda0bd57d..6567b32d0 100644
@@ -9,6 +9,9 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=6.2.x;protocol=https
            file://0001-support-cross-compiling.patch \
            file://0001-explicitly-set-compile-options.patch \
            file://0001-CVE-2022-45198.patch \
+           file://CVE-2023-50447-1.patch \
+           file://CVE-2023-50447-2.patch \
+           file://CVE-2023-50447-3.patch \
 "
 SRCREV ?= "6e0f07bbe38def22d36ee176b2efd9ea74b453a6"
 
Signature · 1 line
2.25.1