Skip to content

Commit 09b942e

Browse files
azurelinux-securityarchana25-ms
authored andcommitted
Patch python-wheel for CVE-2026-24049 [MEDIUM] (#16433)
Co-authored-by: Archana Shettigar <v-shettigara@microsoft.com>
1 parent d5be4a7 commit 09b942e

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
From 5d21b0f9ba9d397f45bb9003635be81df846f894 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= <alex.gronholm@nextday.fi>
3+
Date: Thu, 22 Jan 2026 01:41:14 +0200
4+
Subject: [PATCH] Fixed security issue around wheel unpack (#675)
5+
6+
A maliciously crafted wheel could cause the permissions of a file outside the unpack tree to be altered.
7+
8+
Fixes CVE-2026-24049.
9+
10+
Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com>
11+
Upstream-reference: https://github.com/pypa/wheel/commit/7a7d2de96b22a9adf9208afcc9547e1001569fef.patch
12+
---
13+
src/wheel/cli/unpack.py | 4 ++--
14+
tests/cli/test_unpack.py | 23 +++++++++++++++++++++++
15+
2 files changed, 25 insertions(+), 2 deletions(-)
16+
17+
diff --git a/src/wheel/cli/unpack.py b/src/wheel/cli/unpack.py
18+
index d48840e..83dc742 100644
19+
--- a/src/wheel/cli/unpack.py
20+
+++ b/src/wheel/cli/unpack.py
21+
@@ -19,12 +19,12 @@ def unpack(path: str, dest: str = ".") -> None:
22+
destination = Path(dest) / namever
23+
print(f"Unpacking to: {destination}...", end="", flush=True)
24+
for zinfo in wf.filelist:
25+
- wf.extract(zinfo, destination)
26+
+ target_path = Path(wf.extract(zinfo, destination))
27+
28+
# Set permissions to the same values as they were set in the archive
29+
# We have to do this manually due to
30+
# https://github.com/python/cpython/issues/59999
31+
permissions = zinfo.external_attr >> 16 & 0o777
32+
- destination.joinpath(zinfo.filename).chmod(permissions)
33+
+ target_path.chmod(permissions)
34+
35+
print("OK")
36+
diff --git a/tests/cli/test_unpack.py b/tests/cli/test_unpack.py
37+
index ae584af..75fe193 100644
38+
--- a/tests/cli/test_unpack.py
39+
+++ b/tests/cli/test_unpack.py
40+
@@ -34,3 +34,26 @@ def test_unpack_executable_bit(tmp_path):
41+
unpack(str(wheel_path), str(tmp_path))
42+
assert not script_path.is_dir()
43+
assert stat.S_IMODE(script_path.stat().st_mode) == 0o755
44+
+
45+
+
46+
+@pytest.mark.skipif(
47+
+ platform.system() == "Windows", reason="Windows does not support chmod()"
48+
+)
49+
+def test_chmod_outside_unpack_tree(tmp_path_factory: TempPathFactory) -> None:
50+
+ wheel_path = tmp_path_factory.mktemp("build") / "test-1.0-py3-none-any.whl"
51+
+ with WheelFile(wheel_path, "w") as wf:
52+
+ wf.writestr(
53+
+ "test-1.0.dist-info/METADATA",
54+
+ "Metadata-Version: 2.4\nName: test\nVersion: 1.0\n",
55+
+ )
56+
+ wf.writestr("../../system-file", b"malicious data")
57+
+
58+
+ extract_root_path = tmp_path_factory.mktemp("extract")
59+
+ system_file = extract_root_path / "system-file"
60+
+ extract_path = extract_root_path / "subdir"
61+
+ system_file.write_bytes(b"important data")
62+
+ system_file.chmod(0o755)
63+
+ unpack(str(wheel_path), str(extract_path))
64+
+
65+
+ assert system_file.read_bytes() == b"important data"
66+
+ assert stat.S_IMODE(system_file.stat().st_mode) == 0o755
67+
--
68+
2.45.4
69+

SPECS/python-wheel/python-wheel.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
Summary: Built-package format for Python
55
Name: python-%{pypi_name}
66
Version: 0.43.0
7-
Release: 1%{?dist}
7+
Release: 2%{?dist}
88
License: MIT
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
1111
URL: https://github.com/pypa/wheel
1212
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
13+
Patch0: CVE-2026-24049.patch
1314
%global pypi_name wheel
1415
%global python_wheel_name %{pypi_name}-%{version}-py3-none-any.whl
1516
%global python_wheeldir %{_datadir}/python-wheels
@@ -115,6 +116,9 @@ pip3 install iniconfig
115116
%endif
116117

117118
%changelog
119+
* Thu Apr 02 2026 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 0.43.0-2
120+
- Patch for CVE-2026-24049
121+
118122
* Fri May 10 2024 Betty Lakes <bettylakes@microsoft.com> - 0.43.0-1
119123
- Updated to 0.43.0
120124

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ procps-ng-lang-4.0.4-1.azl3.aarch64.rpm
530530
pyproject-rpm-macros-1.12.0-2.azl3.noarch.rpm
531531
pyproject-srpm-macros-1.12.0-2.azl3.noarch.rpm
532532
python-markupsafe-debuginfo-2.1.3-1.azl3.aarch64.rpm
533-
python-wheel-wheel-0.43.0-1.azl3.noarch.rpm
533+
python-wheel-wheel-0.43.0-2.azl3.noarch.rpm
534534
python3-3.12.9-10.azl3.aarch64.rpm
535535
python3-audit-3.1.2-1.azl3.aarch64.rpm
536536
python3-cracklib-2.9.11-1.azl3.aarch64.rpm
@@ -557,7 +557,7 @@ python3-rpm-generators-14-11.azl3.noarch.rpm
557557
python3-setuptools-69.0.3-5.azl3.noarch.rpm
558558
python3-test-3.12.9-10.azl3.aarch64.rpm
559559
python3-tools-3.12.9-10.azl3.aarch64.rpm
560-
python3-wheel-0.43.0-1.azl3.noarch.rpm
560+
python3-wheel-0.43.0-2.azl3.noarch.rpm
561561
readline-8.2-2.azl3.aarch64.rpm
562562
readline-debuginfo-8.2-2.azl3.aarch64.rpm
563563
readline-devel-8.2-2.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ procps-ng-lang-4.0.4-1.azl3.x86_64.rpm
538538
pyproject-rpm-macros-1.12.0-2.azl3.noarch.rpm
539539
pyproject-srpm-macros-1.12.0-2.azl3.noarch.rpm
540540
python-markupsafe-debuginfo-2.1.3-1.azl3.x86_64.rpm
541-
python-wheel-wheel-0.43.0-1.azl3.noarch.rpm
541+
python-wheel-wheel-0.43.0-2.azl3.noarch.rpm
542542
python3-3.12.9-10.azl3.x86_64.rpm
543543
python3-audit-3.1.2-1.azl3.x86_64.rpm
544544
python3-cracklib-2.9.11-1.azl3.x86_64.rpm
@@ -565,7 +565,7 @@ python3-rpm-generators-14-11.azl3.noarch.rpm
565565
python3-setuptools-69.0.3-5.azl3.noarch.rpm
566566
python3-test-3.12.9-10.azl3.x86_64.rpm
567567
python3-tools-3.12.9-10.azl3.x86_64.rpm
568-
python3-wheel-0.43.0-1.azl3.noarch.rpm
568+
python3-wheel-0.43.0-2.azl3.noarch.rpm
569569
readline-8.2-2.azl3.x86_64.rpm
570570
readline-debuginfo-8.2-2.azl3.x86_64.rpm
571571
readline-devel-8.2-2.azl3.x86_64.rpm

0 commit comments

Comments
 (0)