summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch')
-rw-r--r--meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch59
1 files changed, 59 insertions, 0 deletions
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..be6617e0f6
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-setuptools/CVE-2025-47273.patch
@@ -0,0 +1,59 @@
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
9Upstream-Status: Backport [https://github.com/pypa/setuptools/commit/250a6d17978f9f6ac3ac887091f2d32886fbbb0b]
10CVE: CVE-2025-47273
11Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
12---
13 setuptools/package_index.py | 18 ++++++++++++++++--
14 1 file changed, 16 insertions(+), 2 deletions(-)
15
16diff --git a/setuptools/package_index.py b/setuptools/package_index.py
17index d460fcb..6c7874d 100644
18--- a/setuptools/package_index.py
19+++ b/setuptools/package_index.py
20@@ -818,12 +818,20 @@ class PackageIndex(Environment):
21 @staticmethod
22 def _resolve_download_filename(url, tmpdir):
23 """
24+ >>> import pathlib
25 >>> du = PackageIndex._resolve_download_filename
26 >>> root = getfixture('tmp_path')
27 >>> url = 'https://files.pythonhosted.org/packages/a9/5a/0db.../setuptools-78.1.0.tar.gz'
28- >>> import pathlib
29 >>> str(pathlib.Path(du(url, root)).relative_to(root))
30 'setuptools-78.1.0.tar.gz'
31+
32+ Ensures the target is always in tmpdir.
33+
34+ >>> url = 'https://anyhost/%2fhome%2fuser%2f.ssh%2fauthorized_keys'
35+ >>> du(url, root)
36+ Traceback (most recent call last):
37+ ...
38+ ValueError: Invalid filename...
39 """
40 name, fragment = egg_info_for_url(url)
41 if name:
42@@ -835,7 +843,13 @@ class PackageIndex(Environment):
43 if name.endswith('.egg.zip'):
44 name = name[:-4] # strip the extra .zip before download
45
46- return os.path.join(tmpdir, name)
47+ filename = os.path.join(tmpdir, name)
48+
49+ # ensure path resolves within the tmpdir
50+ if not filename.startswith(str(tmpdir)):
51+ raise ValueError(f"Invalid filename {filename}")
52+
53+ return filename
54
55 def _download_url(self, url, tmpdir):
56 """
57--
582.25.1
59