mirror of
https://git.yoctoproject.org/poky
synced 2026-06-12 22:53:49 +02:00
python3-requests: backport fix for CVE-2026-25645
When unpacking zip files requests uses predictable paths. Backport a fix to use randomly generated pathnames to mitigate injection attacks. (From OE-Core rev: b23ec9773d67f8767904731afa86fe5ede08f97f) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit fe846d71b647fb06e6a87cb45a2dd9b0889e2891) Signed-off-by: Deepak Rathore <deeratho@cisco.com> Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Paul Barker <paul@pbarker.dev>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
From 66d21cb07bd6255b1280291c4fafb71803cdb3b7 Mon Sep 17 00:00:00 2001
|
||||
From: Nate Prewitt <nate.prewitt@gmail.com>
|
||||
Date: Wed, 25 Mar 2026 08:57:56 -0600
|
||||
Subject: [PATCH] Merge commit from fork
|
||||
|
||||
Prior to version 2.33.0, the `requests.utils.extract_zipped_paths()` utility function
|
||||
uses a predictable filename when extracting files from zip archives into the system
|
||||
temporary directory. If the target file already exists, it is reused without validation.
|
||||
A local attacker with write access to the temp directory could pre-create a malicious
|
||||
file that would be loaded in place of the legitimate one. Standard usage of the Requests
|
||||
library is not affected by this vulnerability. Only applications that call
|
||||
`extract_zipped_paths()` directly are impacted. Starting in version 2.33.0, the library
|
||||
extracts files to a non-deterministic location. If developers are unable to upgrade,
|
||||
they can set `TMPDIR` in their environment to a directory with restricted write access.
|
||||
|
||||
CVE: CVE-2026-25645
|
||||
Upstream-Status: Backport [https://github.com/psf/requests/commit/66d21cb07bd6255b1280291c4fafb71803cdb3b7]
|
||||
Signed-off-by: Ross Burton <ross.burton@arm.com>
|
||||
---
|
||||
src/requests/utils.py | 13 +++++++------
|
||||
1 file changed, 7 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/requests/utils.py b/src/requests/utils.py
|
||||
index d8803e6e91..54959bb8ab 100644
|
||||
--- a/src/requests/utils.py
|
||||
+++ b/src/requests/utils.py
|
||||
@@ -282,12 +282,13 @@ def extract_zipped_paths(path):
|
||||
return path
|
||||
|
||||
# we have a valid zip archive and a valid member of that archive
|
||||
- tmp = tempfile.gettempdir()
|
||||
- extracted_path = os.path.join(tmp, member.split("/")[-1])
|
||||
- if not os.path.exists(extracted_path):
|
||||
- # use read + write to avoid the creating nested folders, we only want the file, avoids mkdir racing condition
|
||||
- with atomic_open(extracted_path) as file_handler:
|
||||
- file_handler.write(zip_file.read(member))
|
||||
+ suffix = os.path.splitext(member.split("/")[-1])[-1]
|
||||
+ fd, extracted_path = tempfile.mkstemp(suffix=suffix)
|
||||
+ try:
|
||||
+ os.write(fd, zip_file.read(member))
|
||||
+ finally:
|
||||
+ os.close(fd)
|
||||
+
|
||||
return extracted_path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user