diff options
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch')
-rw-r--r-- | meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch b/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch new file mode 100644 index 0000000000..b93425ee58 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From 557ba59d13de919d04b3fd4cdef8634f7d4b3348 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrew Murray <radarhere@users.noreply.github.com> | ||
3 | Date: Sat, 30 Dec 2023 09:30:12 +1100 | ||
4 | Subject: [PATCH] Include further builtins | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/557ba59d13de919d04b3fd4cdef8634f7d4b3348] | ||
7 | CVE: CVE-2023-50447 | ||
8 | Signed-off-by: Vijay Anusuri <vanusuri@mvista.com> | ||
9 | --- | ||
10 | Tests/test_imagemath.py | 4 ++++ | ||
11 | src/PIL/ImageMath.py | 2 +- | ||
12 | 2 files changed, 5 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/Tests/test_imagemath.py b/Tests/test_imagemath.py | ||
15 | index 14a58a532..5bba832e2 100644 | ||
16 | --- a/Tests/test_imagemath.py | ||
17 | +++ b/Tests/test_imagemath.py | ||
18 | @@ -60,6 +60,10 @@ class TestImageMath(PillowTestCase): | ||
19 | with pytest.raises(ValueError): | ||
20 | ImageMath.eval("1", {"__": None}) | ||
21 | |||
22 | + def test_prevent_builtins(): | ||
23 | + with pytest.raises(ValueError): | ||
24 | + ImageMath.eval("(lambda: exec('exit()'))()", {"exec": None}) | ||
25 | + | ||
26 | def test_logical(self): | ||
27 | self.assertEqual(pixel(ImageMath.eval("not A", images)), 0) | ||
28 | self.assertEqual(pixel(ImageMath.eval("A and B", images)), "L 2") | ||
29 | diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py | ||
30 | index 776604e3f..c6bc22180 100644 | ||
31 | --- a/src/PIL/ImageMath.py | ||
32 | +++ b/src/PIL/ImageMath.py | ||
33 | @@ -259,7 +259,7 @@ def eval(expression, _dict={}, **kw): | ||
34 | # build execution namespace | ||
35 | args = ops.copy() | ||
36 | for k in list(_dict.keys()) + list(kw.keys()): | ||
37 | - if "__" in k or hasattr(__builtins__, k): | ||
38 | + if "__" in k or hasattr(builtins, k): | ||
39 | msg = f"'{k}' not allowed" | ||
40 | raise ValueError(msg) | ||
41 | |||
42 | -- | ||
43 | 2.25.1 | ||
44 | |||