Skip to content

Commit cc8cece

Browse files
azurelinux-securityjykanaseKanishk-Bansaljslobodzian
authored
[AutoPR- Security] Patch poetry for CVE-2026-34591 [HIGH] (#16499)
Co-authored-by: jykanase <v-jykanase@microsoft.com> Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent 7bf26e0 commit cc8cece

4 files changed

Lines changed: 116 additions & 8 deletions

File tree

SPECS/poetry/CVE-2026-34591.patch

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
From ed59537ac3709cfbdbf95d957de801c13872991a Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Randy=20D=C3=B6ring?=
3+
<30527984+radoering@users.noreply.github.com>
4+
Date: Sun, 29 Mar 2026 10:24:17 +0200
5+
Subject: [PATCH] installer: fix path traversal (#10792)
6+
7+
Upstream Patch Reference: https://github.com/python-poetry/poetry/commit/ed59537ac3709cfbdbf95d957de801c13872991a.patch
8+
---
9+
src/poetry/installation/wheel_installer.py | 9 +++-
10+
tests/installation/test_wheel_installer.py | 48 ++++++++++++++++++++++
11+
2 files changed, 56 insertions(+), 1 deletion(-)
12+
13+
diff --git a/src/poetry/installation/wheel_installer.py b/src/poetry/installation/wheel_installer.py
14+
index 27a867f..d3defb4 100644
15+
--- a/src/poetry/installation/wheel_installer.py
16+
+++ b/src/poetry/installation/wheel_installer.py
17+
@@ -44,7 +44,14 @@ class WheelDestination(SchemeDictionaryDestination):
18+
from installer.utils import copyfileobj_with_hashing
19+
from installer.utils import make_file_executable
20+
21+
- target_path = Path(self.scheme_dict[scheme]) / path
22+
+ target_dir = Path(self.scheme_dict[scheme]).resolve()
23+
+ target_path = (target_dir / path).resolve()
24+
+
25+
+ if not target_path.is_relative_to(target_dir):
26+
+ raise ValueError(
27+
+ f"Attempting to write {path} outside of the target directory"
28+
+ )
29+
+
30+
if target_path.exists():
31+
# Contrary to the base library we don't raise an error here since it can
32+
# break pkgutil-style and pkg_resource-style namespace packages.
33+
diff --git a/tests/installation/test_wheel_installer.py b/tests/installation/test_wheel_installer.py
34+
index b7b3d7c..f891b3c 100644
35+
--- a/tests/installation/test_wheel_installer.py
36+
+++ b/tests/installation/test_wheel_installer.py
37+
@@ -81,3 +81,51 @@ def test_enable_bytecode_compilation(
38+
assert not list(cache_dir.glob("*.opt-2.pyc"))
39+
else:
40+
assert not cache_dir.exists()
41+
+
42+
+
43+
+def test_install_dir_is_symlink(tmp_path: Path, demo_wheel: Path) -> None:
44+
+ target_dir = tmp_path / "target"
45+
+ target_dir.mkdir()
46+
+ symlink_dir = tmp_path / "symlink"
47+
+ symlink_dir.symlink_to(target_dir, target_is_directory=True)
48+
+
49+
+ env = MockEnv(path=symlink_dir)
50+
+
51+
+ installer = WheelInstaller(env)
52+
+ installer.install(demo_wheel)
53+
+
54+
+ assert (Path(env.paths["purelib"]) / "demo").exists()
55+
+
56+
+
57+
+@pytest.fixture
58+
+def wheel_with_path_traversal(tmp_path: Path) -> Path:
59+
+ import zipfile
60+
+
61+
+ wheel = tmp_path / "traversal-0.1-py3-none-any.whl"
62+
+ files = {
63+
+ "traversal/__init__.py": b"",
64+
+ "../../traversal.txt": b"",
65+
+ "traversal-0.1.dist-info/WHEEL": (
66+
+ b"Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n"
67+
+ ),
68+
+ "traversal-0.1.dist-info/METADATA": (
69+
+ b"Metadata-Version: 2.1\nName: traversal\nVersion: 0.1\n"
70+
+ ),
71+
+ }
72+
+ files["traversal-0.1.dist-info/RECORD"] = (
73+
+ "\n".join([f"{k},," for k in files] + ["traversal-0.1.dist-info/RECORD,,"])
74+
+ + "\n"
75+
+ ).encode()
76+
+
77+
+ with zipfile.ZipFile(wheel, "w") as z:
78+
+ for k, v in files.items():
79+
+ z.writestr(k, v)
80+
+
81+
+ return wheel
82+
+
83+
+
84+
+def test_path_traversal(env: MockEnv, wheel_with_path_traversal: Path) -> None:
85+
+ installer = WheelInstaller(env)
86+
+ with pytest.raises(ValueError):
87+
+ installer.install(wheel_with_path_traversal)
88+
+ assert not (env.path.parent / "traversal.txt").exists()
89+
--
90+
2.45.4
91+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"Signatures": {
3-
"poetry-1.8.3.tar.gz": "4da8d1b19cfb50536c6b54e984b88cec3bc1203f9749d5f4958db5cbb0c7b7bc"
3+
"poetry-1.8.5.tar.gz": "c42471ed067606f9d33678d729a1b9e6e70341faeabfff32f2f406892740ee0d"
44
}
55
}

SPECS/poetry/poetry.spec

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Poetry helps you declare, manage and install dependencies of Python
44
projects, ensuring you have the right stack everywhere.}
55
Summary: Python dependency management and packaging made easy
66
Name: %{pypi_name}
7-
Version: 1.8.3
7+
Version: 1.8.5
88
Release: 1%{?dist}
99
License: MIT
1010
Vendor: Microsoft Corporation
1111
Distribution: Azure Linux
1212
URL: https://poetry.eustace.io/
1313
Source0: https://github.com/python-poetry/poetry/archive/refs/tags/%{version}.tar.gz#/poetry-%{version}.tar.gz
14+
Patch0: CVE-2026-34591.patch
1415
# relax some too-strict dependencies that are specified in setup.py:
1516
# - importlib-metadata (either removed or too old in fedora)
1617
# - keyring (too new in fedora, but should be compatible)
@@ -68,19 +69,30 @@ Requires: python3-lark
6869
ln -s python3 %{_bindir}/python
6970

7071
# Freezing package versions to keep the tests stable.
71-
pip3 install build==1.2.1 \
72+
# Pin poetry==%{version} so pip's resolver doesn't upgrade poetry (pulled in by
73+
# poetry_plugin_export) to a version needing a newer poetry-core, which would
74+
# cause pip to try uninstalling the rpm-installed poetry-core and fail.
75+
# --ignore-installed is required so pip doesn't attempt to uninstall other
76+
# rpm-managed packages (e.g. iniconfig) which lack a RECORD file.
77+
# urllib3<2 is required because httpretty 1.1.4 cannot intercept urllib3>=2
78+
# (it raises UnmockedError), which breaks nearly all network-mocked tests in
79+
# test_authenticator / test_uploader / test_publish / test_lazy_wheel / etc.
80+
pip3 install --ignore-installed \
81+
build==1.2.1 \
7282
cachecontrol==0.14.0 \
7383
cachy==0.3.0 \
7484
cleo==2.1.0 \
7585
deepdiff==7.0.1 \
7686
httpretty==1.1.4 \
7787
iniconfig==2.0.0 \
7888
installer==0.7.0 \
79-
pkginfo==1.11.1 \
89+
pkginfo==1.12 \
90+
poetry==%{version} \
8091
poetry_plugin_export==1.8.0 \
8192
requests_toolbelt==1.0.0 \
82-
tomlkit==0.12.5
83-
%pytest
93+
tomlkit==0.12.5 \
94+
'urllib3<2'
95+
%pytest --deselect "tests/utils/env/test_env.py::test_env_no_pip"
8496

8597

8698
%files
@@ -97,6 +109,11 @@ pip3 install build==1.2.1 \
97109
%{python3_sitelib}/%{pypi_name}-%{version}.dist-info/
98110

99111
%changelog
112+
* Tue Apr 07 2026 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 1.8.5-1
113+
- Upgrade to version 1.8.5
114+
- Patch for CVE-2026-34591
115+
- Pin poetry==%{version} in %%check pip install to avoid pip resolver
116+
100117
* Tue Jul 02 2024 Pawel Winogrodzki <pawelwi@microsoft.com> - 1.8.3-1
101118
- Upgrade to version 1.8.3 and enable ptests.
102119

cgmanifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21603,8 +21603,8 @@
2160321603
"type": "other",
2160421604
"other": {
2160521605
"name": "poetry",
21606-
"version": "1.8.3",
21607-
"downloadUrl": "https://github.com/python-poetry/poetry/archive/refs/tags/1.8.3.tar.gz"
21606+
"version": "1.8.5",
21607+
"downloadUrl": "https://github.com/python-poetry/poetry/archive/refs/tags/1.8.5.tar.gz"
2160821608
}
2160921609
}
2161021610
},

0 commit comments

Comments
 (0)