Open
python-virtualenv: fix CVE-2026-113719 seed cleanup path escape #82
Lei-ChenAdd on 15 hours ago
python-virtualenv: fix CVE-2026-113719 seed cleanup path escape #82
Open
Total: 2 files changed+63-1
| @@ -0,0 +1,58 @@ | |||
| 1 | +From e3cea6fa10a50fa29cf1fdddd772458fba076d5f Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= <gaborjbernat@gmail.com> | ||
| 3 | +Date: Fri, 16 Oct 2026 03:19:37 -0700 | ||
| 4 | +Subject: [PATCH] fix(seed): contain metadata cleanup | ||
| 5 | + | ||
| 6 | +Limit seed-package cleanup to entries inside the environment. Ignore | ||
| 7 | +metadata entries that name the environment itself, a directory holding | ||
| 8 | +the metadata, or resolve outside it, with a warning. Launcher entries | ||
| 9 | +inside the environment remain supported. | ||
| 10 | + | ||
| 11 | +Backport of upstream PR #3428 (merged as e3cea6fa). | ||
| 12 | + | ||
| 13 | +(backported from commit e3cea6fa10a50fa29cf1fdddd772458fba076d5f) | ||
| 14 | + | ||
| 15 | +Conflict: 20.26.6 has untyped _uninstall_dist(dist); env_dir is passed from _creator.dest | ||
| 16 | +Reference: https://github.com/pypa/virtualenv/pull/3428 | ||
| 17 | + | ||
| 18 | +diff --git a/src/virtualenv/seed/embed/via_app_data/pip_install/base.py b/src/virtualenv/seed/embed/via_app_data/pip_install/base.py | ||
| 19 | +index 0ca8297..6b632f6 100644 | ||
| 20 | +--- a/src/virtualenv/seed/embed/via_app_data/pip_install/base.py | ||
| 21 | ++++ b/src/virtualenv/seed/embed/via_app_data/pip_install/base.py | ||
| 22 | +@@ -146,10 +146,10 @@ | ||
| 23 | + paths = (p for p in in_folders if p.stem.split("-")[0] == dist_name and p.suffix == ".dist-info" and p.is_dir()) | ||
| 24 | + existing_dist = next(paths, None) | ||
| 25 | + if existing_dist is not None: | ||
| 26 | +- self._uninstall_dist(existing_dist) | ||
| 27 | ++ self._uninstall_dist(existing_dist, self._creator.dest) | ||
| 28 | + | ||
| 29 | + @staticmethod | ||
| 30 | +- def _uninstall_dist(dist): | ||
| 31 | ++ def _uninstall_dist(dist, env_dir): | ||
| 32 | + dist_base = dist.parent | ||
| 33 | + logging.debug("uninstall existing distribution %s from %s", dist.stem, dist_base) | ||
| 34 | + | ||
| 35 | +@@ -169,9 +169,21 @@ | ||
| 36 | + if not any(p in base_dirs for p in path.parents): # only add if not already added as a base dir | ||
| 37 | + paths.add(path) | ||
| 38 | + | ||
| 39 | ++ root = env_dir.resolve() | ||
| 40 | ++ metadata_parents = set(dist.resolve().parents) | ||
| 41 | + for path in sorted(paths): # actually remove stuff in a stable order | ||
| 42 | +- if path.exists(): | ||
| 43 | +- if path.is_dir() and not path.is_symlink(): | ||
| 44 | ++ if path.exists() or path.is_symlink(): | ||
| 45 | ++ linked = path.is_symlink() | ||
| 46 | ++ # Unlinking the final link leaves its target intact; parent links still affect containment. | ||
| 47 | ++ resolved = path.parent.resolve() / path.name if linked else path.resolve() | ||
| 48 | ++ if root not in resolved.parents or resolved in metadata_parents: | ||
| 49 | ++ logging.warning( | ||
| 50 | ++ "skip removal of %s listed by %s: not inside environment %s or a parent of the metadata", | ||
| 51 | ++ path, | ||
| 52 | ++ dist.name, | ||
| 53 | ++ root, | ||
| 54 | ++ ) | ||
| 55 | ++ elif path.is_dir() and not linked: | ||
| 56 | + safe_delete(path) | ||
| 57 | + else: | ||
| 58 | + path.unlink() | ||
| @@ -1,7 +1,7 @@ | |||
| 1 | %global pypi_name virtualenv | 1 | %global pypi_name virtualenv |
| 2 | Name: python-%{pypi_name} | 2 | Name: python-%{pypi_name} |
| 3 | Version: 20.26.6 | 3 | Version: 20.26.6 |
| 4 | -Release: 3 | 4 | +Release: 4 |
| 5 | Summary: A tool to create isolated Python environments | 5 | Summary: A tool to create isolated Python environments |
| 6 | License: MIT | 6 | License: MIT |
| 7 | URL: http://pypi.python.org/pypi/virtualenv | 7 | URL: http://pypi.python.org/pypi/virtualenv |
| @@ -9,6 +9,7 @@ Source0: %{pypi_source %{pypi_name}} | |||
| 9 | Patch0: CVE-2026-22702.patch | 9 | Patch0: CVE-2026-22702.patch |
| 10 | Patch1: CVE-2026-113776.patch | 10 | Patch1: CVE-2026-113776.patch |
| 11 | Patch2: CVE-2026-113726.patch | 11 | Patch2: CVE-2026-113726.patch |
| 12 | +Patch3: backport-CVE-2026-113719.patch | ||
| 12 | 13 | ||
| 13 | BuildArch: noarch | 14 | BuildArch: noarch |
| 14 | BuildRequires: python3-distlib python3-filelock | 15 | BuildRequires: python3-distlib python3-filelock |
| @@ -63,6 +64,9 @@ sed -i "s/^version_tuple = /__version_tuple__ = version_tuple = /g" ${ver_pyfile | |||
| 63 | %{python3_sitelib}/%{pypi_name}*.dist-info/ | 64 | %{python3_sitelib}/%{pypi_name}*.dist-info/ |
| 64 | 65 | ||
| 65 | %changelog | 66 | %changelog |
| 67 | +* Thu Nov 19 2026 Lei Chen <dev03101@linx-info.com> - 20.26.6-4 | ||
| 68 | +- Fix CVE-2026-113719: limit seed-package cleanup to the environment | ||
| 69 | + | ||
| 66 | * Sat Oct 31 2026 infra_team <zhaiwenjie1@huawei.com> - 20.26.6-3 | 70 | * Sat Oct 31 2026 infra_team <zhaiwenjie1@huawei.com> - 20.26.6-3 |
| 67 | - Fix CVE-2026-113776: substitute activation template placeholders in one pass | 71 | - Fix CVE-2026-113776: substitute activation template placeholders in one pass |
| 68 | to keep placeholder names inside quoted values as data (upstream 602b2662, fixed in 21.14.2) | 72 | to keep placeholder names inside quoted values as data (upstream 602b2662, fixed in 21.14.2) |