summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python
diff options
context:
space:
mode:
authorPraveen Kumar <praveen.kumar@windriver.com>2025-06-27 15:50:54 +0530
committerSteve Sakoman <steve@sakoman.com>2025-07-04 07:50:16 -0700
commitf53d6b5b2f0662e97907f84e28f6b1feecd14a51 (patch)
treee9065cedd27b3612062a1077fff37de461cb5932 /meta/recipes-devtools/python
parent0372024fe7ab2cea5eddf686f9bee0f8f07a2000 (diff)
downloadpoky-f53d6b5b2f0662e97907f84e28f6b1feecd14a51.tar.gz
python3-setuptools: fix CVE-2025-47273
setuptools is a package that allows users to download, build, install, upgrade, and uninstall Python packages. A path traversal vulnerability in `PackageIndex` is present in setuptools prior to version 78.1.1. An attacker would be allowed to write files to arbitrary locations on the filesystem with the permissions of the process running the Python code, which could escalate to remote code execution depending on the context. Version 78.1.1 fixes the issue. Reference: https://nvd.nist.gov/vuln/detail/CVE-2025-47273 Upstream-patch: https://github.com/pypa/setuptools/commit/d8390feaa99091d1ba9626bec0e4ba7072fc507a https://github.com/pypa/setuptools/commit/250a6d17978f9f6ac3ac887091f2d32886fbbb0b (From OE-Core rev: cfb2d77f841ae21cae0ba7d6263dc3e1e0280400) Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools/python')
-rw-r--r--meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273-pre1.patch55
-rw-r--r--meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch60
-rw-r--r--meta/recipes-devtools/python/python3-setuptools_76.0.0.bb5
3 files changed, 119 insertions, 1 deletions
diff --git a/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273-pre1.patch b/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273-pre1.patch
new file mode 100644
index 0000000000..d75f05fc68
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273-pre1.patch
@@ -0,0 +1,55 @@
1From d8390feaa99091d1ba9626bec0e4ba7072fc507a Mon Sep 17 00:00:00 2001
2From: "Jason R. Coombs" <jaraco@jaraco.com>
3Date: Sat, 19 Apr 2025 12:49:55 -0400
4Subject: [PATCH] Extract _resolve_download_filename with test.
5
6CVE: CVE-2025-47273 #Dependency Patch
7
8Upstream-Status: Backport [https://github.com/pypa/setuptools/commit/d8390feaa99091d1ba9626bec0e4ba7072fc507a]
9
10Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com>
11---
12 setuptools/package_index.py | 20 ++++++++++++++++----
13 1 file changed, 16 insertions(+), 4 deletions(-)
14
15diff --git a/setuptools/package_index.py b/setuptools/package_index.py
16index 1a6abeb..b317735 100644
17--- a/setuptools/package_index.py
18+++ b/setuptools/package_index.py
19@@ -807,9 +807,16 @@ class PackageIndex(Environment):
20 else:
21 raise DistutilsError(f"Download error for {url}: {v}") from v
22
23- def _download_url(self, url, tmpdir):
24- # Determine download filename
25- #
26+ @staticmethod
27+ def _resolve_download_filename(url, tmpdir):
28+ """
29+ >>> du = PackageIndex._resolve_download_filename
30+ >>> root = getfixture('tmp_path')
31+ >>> url = 'https://files.pythonhosted.org/packages/a9/5a/0db.../setuptools-78.1.0.tar.gz'
32+ >>> import pathlib
33+ >>> str(pathlib.Path(du(url, root)).relative_to(root))
34+ 'setuptools-78.1.0.tar.gz'
35+ """
36 name, _fragment = egg_info_for_url(url)
37 if name:
38 while '..' in name:
39@@ -820,8 +827,13 @@ class PackageIndex(Environment):
40 if name.endswith('.egg.zip'):
41 name = name[:-4] # strip the extra .zip before download
42
43- filename = os.path.join(tmpdir, name)
44+ return os.path.join(tmpdir, name)
45
46+ def _download_url(self, url, tmpdir):
47+ """
48+ Determine the download filename.
49+ """
50+ filename = self._resolve_download_filename(url, tmpdir)
51 return self._download_vcs(url, filename) or self._download_other(url, filename)
52
53 @staticmethod
54--
552.40.0
diff --git a/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch b/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch
new file mode 100644
index 0000000000..3c44a2a321
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch
@@ -0,0 +1,60 @@
1From 250a6d17978f9f6ac3ac887091f2d32886fbbb0b Mon Sep 17 00:00:00 2001
2From: "Jason R. Coombs" <jaraco@jaraco.com>
3Date: Sat, 19 Apr 2025 13:03:47 -0400
4Subject: [PATCH] Add a check to ensure the name resolves relative to the
5 tmpdir.
6
7Closes #4946
8
9CVE: CVE-2025-47273
10
11Upstream-Status: Backport [https://github.com/pypa/setuptools/commit/250a6d17978f9f6ac3ac887091f2d32886fbbb0b]
12
13Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com>
14---
15 setuptools/package_index.py | 18 ++++++++++++++++--
16 1 file changed, 16 insertions(+), 2 deletions(-)
17
18diff --git a/setuptools/package_index.py b/setuptools/package_index.py
19index b317735..a8f868e 100644
20--- a/setuptools/package_index.py
21+++ b/setuptools/package_index.py
22@@ -810,12 +810,20 @@ class PackageIndex(Environment):
23 @staticmethod
24 def _resolve_download_filename(url, tmpdir):
25 """
26+ >>> import pathlib
27 >>> du = PackageIndex._resolve_download_filename
28 >>> root = getfixture('tmp_path')
29 >>> url = 'https://files.pythonhosted.org/packages/a9/5a/0db.../setuptools-78.1.0.tar.gz'
30- >>> import pathlib
31 >>> str(pathlib.Path(du(url, root)).relative_to(root))
32 'setuptools-78.1.0.tar.gz'
33+
34+ Ensures the target is always in tmpdir.
35+
36+ >>> url = 'https://anyhost/%2fhome%2fuser%2f.ssh%2fauthorized_keys'
37+ >>> du(url, root)
38+ Traceback (most recent call last):
39+ ...
40+ ValueError: Invalid filename...
41 """
42 name, _fragment = egg_info_for_url(url)
43 if name:
44@@ -827,7 +835,13 @@ class PackageIndex(Environment):
45 if name.endswith('.egg.zip'):
46 name = name[:-4] # strip the extra .zip before download
47
48- return os.path.join(tmpdir, name)
49+ filename = os.path.join(tmpdir, name)
50+
51+ # ensure path resolves within the tmpdir
52+ if not filename.startswith(str(tmpdir)):
53+ raise ValueError(f"Invalid filename {filename}")
54+
55+ return filename
56
57 def _download_url(self, url, tmpdir):
58 """
59--
602.40.0
diff --git a/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb b/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb
index 71c8eb1a1f..91d8fdd73b 100644
--- a/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb
+++ b/meta/recipes-devtools/python/python3-setuptools_76.0.0.bb
@@ -11,7 +11,10 @@ CVE_PRODUCT = "python3-setuptools python:setuptools"
11SRC_URI:append:class-native = " file://0001-conditionally-do-not-fetch-code-by-easy_install.patch" 11SRC_URI:append:class-native = " file://0001-conditionally-do-not-fetch-code-by-easy_install.patch"
12 12
13SRC_URI += " \ 13SRC_URI += " \
14 file://0001-_distutils-sysconfig.py-make-it-possible-to-substite.patch" 14 file://0001-_distutils-sysconfig.py-make-it-possible-to-substite.patch \
15 file://CVE-2025-47273-pre1.patch \
16 file://CVE-2025-47273.patch \
17"
15 18
16SRC_URI[sha256sum] = "43b4ee60e10b0d0ee98ad11918e114c70701bc6051662a9a675a0496c1a158f4" 19SRC_URI[sha256sum] = "43b4ee60e10b0d0ee98ad11918e114c70701bc6051662a9a675a0496c1a158f4"
17 20