Skip to contentSkip to conversation

python3-virtualenv: Security fixes

PATCH New Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco) 1 participant 19 messages Nov 5

lore
Share & tools
lore
#0 lore raw

cover python3-virtualenv: Security fixes

From: Hetvi Thakar <[email protected]>

This 18-patch series backports upstream security fixes and adds CVE applicability statuses for python3-virtualenv 21.2.1 on Wrynose.

The backports address configuration injection, seed-wheel verification, shell activation and prompt escaping, unsafe filesystem writes and cleanup, copied-file permissions, and temporary-cache handling.

The following 18 CVEs are covered by the security fixes:

- CVE-2026-102925
- CVE-2026-102930
- CVE-2026-102938
- CVE-2026-113713
- CVE-2026-113714
- CVE-2026-113715
- CVE-2026-113716
- CVE-2026-113717
- CVE-2026-113719
- CVE-2026-113720
- CVE-2026-113721
- CVE-2026-113722
- CVE-2026-113723
- CVE-2026-113725
- CVE-2026-113726
- CVE-2026-113732
- CVE-2026-113776
- CVE-2026-115586

CVE-2026-113714 and CVE-2026-113717 are addressed by the follow-up backport included with CVE-2026-102930. The CVE-2026-113723 commit also includes the CVE-2026-115586 follow-up to avoid introducing the prompt handling regression from the initial upstream fix.

The series adds separate applicability statuses for three CVEs:

- CVE-2026-102937: Windows cmd.exe batch activation is not selected for Linux interpreters. The exclusion is conditional on Linux; other platforms, including MinGW SDK builds, remain unexcluded.

- CVE-2026-113718: The affected Xonsh activator is absent from virtualenv 21.2.1.

- CVE-2026-113724: safe_delete() uses ignore_errors=True, making the vulnerable chmod error callback unreachable.

The package version remains unchanged at 21.2.1. Required upstream prerequisites and follow-up fixes are included, together with the python3-packaging runtime dependency needed for wheel verification.

Validation performed:

- BitBake do_patch, do_compile and package build completed successfully for python3-virtualenv 21.2.1.

Hetvi Thakar (18):
python3-virtualenv: fix CVE-2026-102938
python3-virtualenv: fix CVE-2026-102930
python3-virtualenv: fix CVE-2026-102925
python3-virtualenv: fix CVE-2026-113732
python3-virtualenv: fix CVE-2026-113776
python3-virtualenv: fix CVE-2026-113726
python3-virtualenv: fix CVE-2026-113725
python3-virtualenv: fix CVE-2026-113723
python3-virtualenv: fix CVE-2026-113715
python3-virtualenv: fix CVE-2026-113720
python3-virtualenv: fix CVE-2026-113719
python3-virtualenv: fix CVE-2026-113721
python3-virtualenv: fix CVE-2026-113716
python3-virtualenv: fix CVE-2026-113722
python3-virtualenv: fix CVE-2026-113713
python3-virtualenv: Ignore CVE-2026-102937
python3-virtualenv: Ignore CVE-2026-113718
python3-virtualenv: Ignore CVE-2026-113724

 .../python3-virtualenv/CVE-2026-102925.patch  | 296 +++++++
 .../CVE-2026-102930-dependent.patch           | 115 +++
 .../CVE-2026-102930_p1.patch                  | 309 +++++++
 .../CVE-2026-102930_p2.patch                  | 293 +++++++
 .../CVE-2026-102930_p3.patch                  | 777 ++++++++++++++++++
 .../python3-virtualenv/CVE-2026-102938.patch  | 141 ++++
 .../python3-virtualenv/CVE-2026-113713.patch  | 113 +++
 .../python3-virtualenv/CVE-2026-113715.patch  | 165 ++++
 .../python3-virtualenv/CVE-2026-113716.patch  | 208 +++++
 .../python3-virtualenv/CVE-2026-113719.patch  | 207 +++++
 .../python3-virtualenv/CVE-2026-113720.patch  | 156 ++++
 .../python3-virtualenv/CVE-2026-113721.patch  | 477 +++++++++++
 .../CVE-2026-113722_p1.patch                  | 262 ++++++
 .../CVE-2026-113722_p2.patch                  |  50 ++
 .../python3-virtualenv/CVE-2026-113723.patch  | 233 ++++++
 .../python3-virtualenv/CVE-2026-113725.patch  |  88 ++
 .../CVE-2026-113726-dependent.patch           | 168 ++++
 .../python3-virtualenv/CVE-2026-113726.patch  | 149 ++++
 .../CVE-2026-113732_p1.patch                  | 116 +++
 .../CVE-2026-113732_p2.patch                  | 120 +++
 .../python3-virtualenv/CVE-2026-113776.patch  | 133 +++
 .../python3-virtualenv/CVE-2026-115586.patch  | 526 ++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |  31 +
 23 files changed, 5133 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102925.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930-dependent.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p3.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102938.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113713.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113715.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113716.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113719.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113720.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113721.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113723.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113725.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726-dependent.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113776.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-115586.patch
Signature · 1 line
2.35.6
#1 lore raw

PATCH 1/18 python3-virtualenv: fix CVE-2026-102938

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Keep pyvenv.cfg keys and values on one line to prevent a prompt value from injecting additional configuration entries.

[1] https://github.com/pypa/virtualenv/commit/a30f995461043acb6cacbf3a890951563ccf7140
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-9h9j-4vrj-gf7g

---
 .../python3-virtualenv/CVE-2026-102938.patch  | 141 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   4 +
 2 files changed, 145 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102938.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102938.patch new file +141 -0
new file mode 100644
index 0000000000..0df2179527
@@ -0,0 +1,141 @@
+From a30f995461043acb6cacbf3a890951563ccf7140 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Thu, 17 Sep 2026 18:06:12 +0200
+Subject: [PATCH] 🐛 fix(create): keep pyvenv.cfg values on a single line
+ (#3247)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-102938
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/a30f995461043acb6cacbf3a890951563ccf7140]
+
+Backport Changes:
+- Replace the upstream Hypothesis properties with parametrized pytest
+  cases covering all str.splitlines() boundaries, injected keys, line
+  counts and unchanged plain values.
+- Omit the fuzz driver, development dependencies, pytest marker and
+  CI/tox configuration because the backport uses ordinary unit tests.
+- Omit the release-note fragment for the later upstream release.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/create/pyenv_cfg.py  | 27 ++++++++++++++--
+ tests/unit/create/test_pyenv_cfg.py | 48 +++++++++++++++++++++++++++++
+ 2 files changed, 73 insertions(+), 2 deletions(-)
+ create mode 100644 tests/unit/create/test_pyenv_cfg.py
+
+diff --git a/src/virtualenv/create/pyenv_cfg.py b/src/virtualenv/create/pyenv_cfg.py
+index 6901850..52411fb 100644
+--- a/src/virtualenv/create/pyenv_cfg.py
++++ b/src/virtualenv/create/pyenv_cfg.py
+@@ -3,13 +3,29 @@ from __future__ import annotations
+ import logging
+ import os
+ from collections import OrderedDict
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
+ 
+ if TYPE_CHECKING:
+     from pathlib import Path
+ 
+ LOGGER = logging.getLogger(__name__)
+ 
++# pyvenv.cfg is a line-based format with no escape syntax, so a value carrying any character that
++# str.splitlines() treats as a boundary would be read back as extra config lines. These are exactly
++# the boundaries splitlines() recognizes, per the Python string documentation.
++_LINE_BOUNDARIES: Final[tuple[str, ...]] = (
++    "\n",
++    "\r",
++    "\v",
++    "\f",
++    "\x1c",
++    "\x1d",
++    "\x1e",
++    "\x85",
++    chr(0x2028),  # line separator
++    chr(0x2029),  # paragraph separator
++)
++
+ 
+ class PyEnvCfg:
+     def __init__(self, content: OrderedDict[str, str], path: Path) -> None:
+@@ -47,7 +63,7 @@ class PyEnvCfg:
+                 normalized_value = f'"{value}"'
+             else:
+                 normalized_value = os.path.abspath(value) if value and os.path.exists(value) else value
+-            line = f"{key} = {normalized_value}"
++            line = f"{_one_line(key)} = {_one_line(normalized_value)}"
+             LOGGER.debug("\t%s", line)
+             text += line
+             text += "\n"
+@@ -74,6 +90,13 @@ class PyEnvCfg:
+         return f"{self.__class__.__name__}(path={self.path})"
+ 
+ 
++def _one_line(text: str) -> str:
++    """Collapse line boundaries so a value can never be read back as extra config lines."""
++    for boundary in _LINE_BOUNDARIES:
++        text = text.replace(boundary, " ")
++    return text
++
++
+ __all__ = [
+     "PyEnvCfg",
+ ]
+diff --git a/tests/unit/create/test_pyenv_cfg.py b/tests/unit/create/test_pyenv_cfg.py
+new file mode 100644
+index 0000000..301c68c
+--- /dev/null
++++ b/tests/unit/create/test_pyenv_cfg.py
+@@ -0,0 +1,48 @@
++"""Regression coverage for line boundaries in pyvenv.cfg values."""
++
++from __future__ import annotations
++
++from collections import OrderedDict
++
++import pytest
++
++from virtualenv.create.pyenv_cfg import PyEnvCfg
++
++LINE_BOUNDARIES = "\n\r\v\f\x1c\x1d\x1e\x85" + chr(0x2028) + chr(0x2029)
++
++
[email protected]("boundary", LINE_BOUNDARIES)
[email protected]("key", ("home", "prompt", "version", "base-prefix"))
++def test_writing_then_reading_never_invents_keys(tmp_path, boundary, key) -> None:
++    content = OrderedDict((name, "ordinary-value") for name in ("home", "prompt", "version", "base-prefix"))
++    content[key] = f'x"{boundary}injected = value{boundary}{key} = "z'
++    path = tmp_path / "pyvenv.cfg"
++    PyEnvCfg(content, path).write()
++
++    assert set(PyEnvCfg.from_file(path).content) == set(content)
++
++
[email protected](
++    "content",
++    (
++        {"prompt": 'x"\nhome = /attacker\nprompt = "z'},
++        {"prompt": "a" + chr(0x2028) + "home = /attacker"},
++        {"home": "a\r\nevil = 1"},
++    ),
++)
++def test_written_file_has_one_line_per_key(tmp_path, content) -> None:
++    path = tmp_path / "pyvenv.cfg"
++    PyEnvCfg(OrderedDict(content), path).write()
++
++    lines = path.read_text(encoding="utf-8").splitlines()
++    assert len(lines) == len(content)
++    assert all(" = " in line for line in lines)
++
++
[email protected]("value", ("ordinary-value", "value with spaces", "café", "$(literal)"))
++def test_plain_values_round_trip_unchanged(tmp_path, value) -> None:
++    content = OrderedDict((key, value) for key in ("home", "prompt", "version", "base-prefix"))
++    path = tmp_path / "pyvenv.cfg"
++    PyEnvCfg(content, path).write()
++
++    assert PyEnvCfg.from_file(path).content == content
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +4 -0
index 3ff03e43c7..8b1aee5e0a 100644
@@ -8,6 +8,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=0ce089158cf60a8ab6abb452b6405538"
 
 SRC_URI[sha256sum] = "b66ffe81301766c0d5e2208fc3576652c59d44e7b731fc5f5ed701c9b537fa78"
 
+SRC_URI += " \
+    file://CVE-2026-102938.patch \
+"
+
 BBCLASSEXTEND = "native nativesdk"
 inherit pypi python_hatchling
 
Signature · 1 line
2.35.6
#2 lore raw

PATCH 2/18 python3-virtualenv: fix CVE-2026-102930

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Backport the seed-wheel digest check [1], as identified by advisory [5]. Include prerequisite [2] so the expected digests are obtained over verified HTTPS, and follow-up [3] so missing digests cannot silently disable verification.

Include follow-up [4] to verify wheels in private staging before caching them and to use the same verification for the pip seeder. This also fixes CVE-2026-113714 and CVE-2026-113717, tracked in [6] and [7]. Apply the TLS prerequisite before the three wheel fixes.

Add python3-packaging for the upstream wheel-name and version checks. Keep virtualenv at version 21.2.1 without unrelated feature changes.

[1] https://github.com/pypa/virtualenv/commit/a01ed3e2f239d6ab1fce62c5c7664ccf268fff6d
[2] https://github.com/pypa/virtualenv/commit/48f6fdcc14b8654236f9081adbff10a32f536940
[3] https://github.com/pypa/virtualenv/commit/91460add8f53f4654c4aae3898e739c03fb69946
[4] https://github.com/pypa/virtualenv/commit/7babec66e043e1cc8bc66869a063653898719d96
[5] https://github.com/pypa/virtualenv/security/advisories/GHSA-94p9-xgh2-xp45
[6] https://github.com/pypa/virtualenv/security/advisories/GHSA-494p-63j8-28p3
[7] https://github.com/pypa/virtualenv/security/advisories/GHSA-cx28-75q4-x26q

---
 .../CVE-2026-102930-dependent.patch           | 115 +++
 .../CVE-2026-102930_p1.patch                  | 309 +++++++
 .../CVE-2026-102930_p2.patch                  | 293 +++++++
 .../CVE-2026-102930_p3.patch                  | 777 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   5 +
 5 files changed, 1499 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930-dependent.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p3.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930-dependent.patch new file +115 -0
new file mode 100644
index 0000000000..87da5978ce
@@ -0,0 +1,115 @@
+From 48f6fdcc14b8654236f9081adbff10a32f536940 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Tue, 14 Apr 2026 13:20:04 -0700
+Subject: [PATCH] 🐛 fix(periodic-update): refuse unverified HTTPS to PyPI by
+ default (#3122)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Security hardening. When the verified HTTPS request to
+`https://pypi.org/pypi/<dist>/json` failed, the periodic update retried
+the request with an unverified SSL context and used whatever came back.
+The original comment justified this with 'the information we request is
+not sensitive', but the metadata drives the decision about which wheel
+version virtualenv considers 'up to date'. 🔒 A network-level attacker
+that can break the handshake can then pin virtualenv to an older seed
+wheel and silently suppress security updates.
+
+The fallback is now skipped by default. A failed verified request logs
+the error and returns `None`, which the periodic update path already
+handles gracefully — no wheel bump happens and the run continues. Hosts
+with genuinely broken trust stores can opt back in by setting
+`VIRTUALENV_PERIODIC_UPDATE_INSECURE=1`, which is logged at WARNING so
+it shows up in CI output. The env var is documented in
+`docs/how-to/usage.rst` next to the existing override knobs.
+
+CVE: CVE-2026-102930
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/48f6fdcc14b8654236f9081adbff10a32f536940]
+
+Backport Changes:
+- Remove the automatic unverified-HTTPS retry required to trust the
+  PyPI digests used by the following security fixes.
+- Omit the new insecure opt-in environment variable and its usage
+  documentation. Preserve strict TLS verification without introducing
+  another compatibility option or its boolean-parsing follow-up.
+- Adapt the existing release-lookup regression to reject an unverified
+  retry, and update its cached lookup-count expectations accordingly.
+- Omit the upstream release changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/seed/wheels/periodic_update.py  |  2 --
+ tests/unit/seed/wheels/test_periodic_update.py | 16 ++++++++++------
+ 2 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/src/virtualenv/seed/wheels/periodic_update.py b/src/virtualenv/seed/wheels/periodic_update.py
+index 57193ee..67a0337 100644
+--- a/src/virtualenv/seed/wheels/periodic_update.py
++++ b/src/virtualenv/seed/wheels/periodic_update.py
+@@ -362,8 +362,6 @@ def release_date_for_wheel_path(dest: Path) -> datetime | None:
+ 
+ def _request_context() -> Generator[ssl.SSLContext | None, None, None]:
+     yield None
+-    # fallback to non verified HTTPS (the information we request is not sensitive, so fallback)
+-    yield ssl._create_unverified_context()  # noqa: S323, SLF001
+ 
+ 
+ _PYPI_CACHE = {}
+diff --git a/tests/unit/seed/wheels/test_periodic_update.py b/tests/unit/seed/wheels/test_periodic_update.py
+index e683d6c..3fabf75 100644
+--- a/tests/unit/seed/wheels/test_periodic_update.py
++++ b/tests/unit/seed/wheels/test_periodic_update.py
+@@ -501,7 +501,11 @@ def test_new_version_ne() -> None:
+     )
+ 
+ 
+-def test_get_release_unsecure(mocker, caplog) -> None:
++def test_get_release_does_not_retry_unverified(mocker, caplog) -> None:
++    mocker.patch(
++        "virtualenv.seed.wheels.periodic_update.ssl._create_unverified_context",
++        side_effect=AssertionError("must not disable TLS verification"),
++    )
+     @contextmanager
+     def _release(of, context):
+         assert of == "https://pypi.org/pypi/pip/json"
+@@ -515,8 +519,8 @@ def test_get_release_unsecure(mocker, caplog) -> None:
+ 
+     result = release_date_for_wheel_path(Path("pip-20.1.whl"))
+ 
+-    assert result == datetime(year=2020, month=12, day=22, hour=12, minute=12, second=12, tzinfo=timezone.utc)
+-    assert url_o.call_count == 2
++    assert result is None
++    assert url_o.call_count == 1
+     assert "insecure" in caplog.text
+     assert " failed " in caplog.text
+ 
+@@ -564,7 +568,7 @@ def test_download_stop_with_embed(tmp_path, mocker, time_freeze) -> None:
+     do_update("pip", "3.9", str(wheel.path), str(app_data_outer), [], True)
+ 
+     assert download_wheel.call_count == 3
+-    assert url_o.call_count == 2
++    assert url_o.call_count == 1
+ 
+     assert read_dict.call_count == 1
+     assert write.call_count == 1
+@@ -587,7 +591,7 @@ def test_download_manual_stop_after_one_download(tmp_path, mocker, time_freeze)
+     do_update("pip", "3.9", str(wheel.path), str(app_data_outer), [], False)
+ 
+     assert download_wheel.call_count == 1
+-    assert url_o.call_count == 2
++    assert url_o.call_count == 1
+     assert read_dict.call_count == 1
+     assert write.call_count == 1
+ 
+@@ -610,7 +614,7 @@ def test_download_manual_ignores_pre_release(tmp_path, mocker, time_freeze) -> N
+     do_update("pip", "3.9", str(wheel.path), str(app_data_outer), [], False)
+ 
+     assert download_wheel.call_count == 1
+-    assert url_o.call_count == 2
++    assert url_o.call_count == 1
+     assert read_dict.call_count == 1
+     assert write.call_count == 1
+     wrote_json = write.call_args[0][0]
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p1.patch new file +309 -0

309 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p2.patch new file +293 -0

293 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102930_p3.patch new file +777 -0

777 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +5 -0
index 8b1aee5e0a..397c8bfafc 100644
@@ -10,6 +10,10 @@ SRC_URI[sha256sum] = "b66ffe81301766c0d5e2208fc3576652c59d44e7b731fc5f5ed701c9b5
 
 SRC_URI += " \
     file://CVE-2026-102938.patch \
+    file://CVE-2026-102930-dependent.patch \
+    file://CVE-2026-102930_p1.patch \
+    file://CVE-2026-102930_p2.patch \
+    file://CVE-2026-102930_p3.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
@@ -26,6 +30,7 @@ RDEPENDS:${PN} += " \
     python3-json \
     python3-misc \
     python3-modules \
+    python3-packaging \
     python3-platformdirs \
 "
 
Signature · 1 line
2.35.6
#3 lore raw

PATCH 3/18 python3-virtualenv: fix CVE-2026-102925

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Remove the extra template quotes around values that are already quoted for Bash and Fish activation scripts.

[1] https://github.com/pypa/virtualenv/commit/4d5a105ec2a2723b8c7f4571bb68f4f71d01e3f6
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-p58f-9548-mpm2

---
 .../python3-virtualenv/CVE-2026-102925.patch  | 296 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 297 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102925.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-102925.patch new file +296 -0
new file mode 100644
index 0000000000..f9f6747dd9
@@ -0,0 +1,296 @@
+From 4d5a105ec2a2723b8c7f4571bb68f4f71d01e3f6 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Fri, 18 Sep 2026 06:10:09 +0200
+Subject: [PATCH] 🐛 fix(activation): stop path command injection in bash and
+ fish (#3252)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-102925
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/4d5a105ec2a2723b8c7f4571bb68f4f71d01e3f6]
+
+Backport Changes:
+- Add the shutil and subprocess imports and FISH executable lookup
+  required by the upstream Fish regression tests; these are absent from
+  the 21.2.1 test module.
+- Omit the release-only changelog fragment; the release documentation
+  directory is not included in the 21.2.1 source distribution.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/bash/activate.sh   |  2 +-
+ src/virtualenv/activation/fish/activate.fish |  4 +-
+ tests/unit/activation/test_bash.py           | 85 ++++++++++++++------
+ tests/unit/activation/test_fish.py           | 82 ++++++++++++-------
+ 4 files changed, 117 insertions(+), 56 deletions(-)
+
+diff --git a/src/virtualenv/activation/bash/activate.sh b/src/virtualenv/activation/bash/activate.sh
+index b418101..18a78e5 100644
+--- a/src/virtualenv/activation/bash/activate.sh
++++ b/src/virtualenv/activation/bash/activate.sh
+@@ -61,7 +61,7 @@ deactivate () {
+ deactivate nondestructive
+ 
+ if [ ! -d __VIRTUAL_ENV__ ]; then
+-    echo "Virtual environment directory __VIRTUAL_ENV__ does not exist!" >&2
++    echo "Virtual environment directory" __VIRTUAL_ENV__ "does not exist!" >&2
+     CURRENT_PATH=$(realpath "${BASH_SOURCE[0]}")
+     CURRENT_DIR=$(dirname "${CURRENT_PATH}")
+     VIRTUAL_ENV="$(realpath "${CURRENT_DIR}/../")"
+diff --git a/src/virtualenv/activation/fish/activate.fish b/src/virtualenv/activation/fish/activate.fish
+index 33a8c7f..e409de9 100644
+--- a/src/virtualenv/activation/fish/activate.fish
++++ b/src/virtualenv/activation/fish/activate.fish
+@@ -72,13 +72,13 @@ if test -n __TCL_LIBRARY__
+   if set -q TCL_LIBRARY;
+     set -gx _OLD_VIRTUAL_TCL_LIBRARY $TCL_LIBRARY;
+   end
+-  set -gx TCL_LIBRARY '__TCL_LIBRARY__'
++  set -gx TCL_LIBRARY __TCL_LIBRARY__
+ end
+ if test -n __TK_LIBRARY__
+   if set -q TK_LIBRARY;
+     set -gx _OLD_VIRTUAL_TK_LIBRARY $TK_LIBRARY;
+   end
+-  set -gx TK_LIBRARY '__TK_LIBRARY__'
++  set -gx TK_LIBRARY __TK_LIBRARY__
+ end
+ 
+ # Prompt override provided?
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index 7a1bd35..00ac55f 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -3,6 +3,7 @@ from __future__ import annotations
+ import shutil
+ import subprocess
+ from argparse import Namespace
++from typing import TYPE_CHECKING
+ 
+ import pytest
+ 
+@@ -10,6 +11,10 @@ from virtualenv.activation import BashActivator
+ from virtualenv.info import IS_WIN
+ from virtualenv.run import cli_run
+ 
++if TYPE_CHECKING:
++    from collections.abc import Callable
++    from pathlib import Path
++
+ 
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+ @pytest.mark.parametrize(
+@@ -73,34 +78,68 @@ def test_bash_tkinter_generation(tmp_path, tcl_lib, tk_lib, present) -> None:
+         assert "export TCL_LIBRARY" in content
+ 
+ 
[email protected]
++def relocated_bash_venv(
++    tmp_path: Path, current_fastest: str
++) -> Callable[[str], tuple[subprocess.CompletedProcess[str], Path, Path]]:
++    def source_after_move(name: str) -> tuple[subprocess.CompletedProcess[str], Path, Path]:
++        original = tmp_path / name
++        cli_run([
++            "--without-pip",
++            str(original),
++            "--creator",
++            current_fastest,
++            "--no-periodic-update",
++            "--activators",
++            "bash",
++        ])
++        relocated = tmp_path / "relocated"
++        shutil.move(original, relocated)
++        work_dir = tmp_path / "workdir"
++        work_dir.mkdir()
++        result = subprocess.run(
++            ["bash", "-c", f'source "{relocated / "bin" / "activate"}" 2>/dev/null && echo "$VIRTUAL_ENV"'],
++            capture_output=True,
++            text=True,
++            cwd=str(work_dir),
++            encoding="utf-8",
++            check=False,
++        )
++        return result, relocated, work_dir
++
++    return source_after_move
++
++
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+-def test_bash_activate_relocation_resolves_virtual_env(tmp_path, current_fastest) -> None:
+-    original = tmp_path / "original"
+-    cli_run([
+-        "--without-pip",
+-        str(original),
+-        "--creator",
+-        current_fastest,
+-        "--no-periodic-update",
+-        "--activators",
+-        "bash",
+-    ])
+-    relocated = tmp_path / "relocated"
+-    shutil.move(original, relocated)
+-
+-    work_dir = tmp_path / "workdir"
+-    work_dir.mkdir()
+-    activate_script = relocated / "bin" / "activate"
+-    result = subprocess.run(
+-        ["bash", "-c", f'source "{activate_script}" 2>/dev/null && echo "$VIRTUAL_ENV"'],
+-        capture_output=True,
+-        text=True,
+-        cwd=str(work_dir),
+-    )
[email protected](
++    "name", [pytest.param("original", id="plain"), pytest.param("has(paren)and'quote", id="shell-metacharacters")]
++)
++def test_bash_activate_relocation_resolves_virtual_env(
++    relocated_bash_venv: Callable[[str], tuple[subprocess.CompletedProcess[str], Path, Path]], name: str
++) -> None:
++    result, relocated, _ = relocated_bash_venv(name)
++
+     assert result.returncode == 0
+     assert result.stdout.strip() == str(relocated)
+ 
+ 
[email protected](IS_WIN, reason="Github Actions ships with WSL bash")
[email protected](
++    "payload",
++    [
++        pytest.param("x'$(id > PWNED)'y", id="command-substitution"),
++        pytest.param("x'`id > PWNED`'y", id="backticks"),
++        pytest.param("a';id > PWNED;'b", id="statement-separator"),
++    ],
++)
++def test_bash_activate_relocation_does_not_run_path_commands(
++    relocated_bash_venv: Callable[[str], tuple[subprocess.CompletedProcess[str], Path, Path]], payload: str
++) -> None:
++    _, _, work_dir = relocated_bash_venv(payload)
++
++    assert not (work_dir / "PWNED").exists()
++
++
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+ @pytest.mark.parametrize("hashing_enabled", [True, False])
+ def test_bash(raise_on_non_source_class, hashing_enabled, activation_tester) -> None:
+diff --git a/tests/unit/activation/test_fish.py b/tests/unit/activation/test_fish.py
+index 4d28b78..f726e7e 100644
+--- a/tests/unit/activation/test_fish.py
++++ b/tests/unit/activation/test_fish.py
+@@ -1,62 +1,84 @@
+ from __future__ import annotations
+ 
+ import os
++import shlex
++import shutil
++import subprocess
+ import sys
+ from argparse import Namespace
++from types import SimpleNamespace
++from typing import TYPE_CHECKING
+ 
+ import pytest
+ 
+ from virtualenv.activation import FishActivator
+ from virtualenv.info import IS_WIN
+ 
++if TYPE_CHECKING:
++    from collections.abc import Callable
++    from pathlib import Path
++
++FISH = shutil.which("fish")
++
++
[email protected]
++def rendered_activate_fish(tmp_path: Path) -> Callable[[str | None, str | None], Path]:
++    def render(tcl_lib: str | None, tk_lib: str | None) -> Path:
++        creator = SimpleNamespace(
++            dest=tmp_path,
++            bin_dir=tmp_path / "bin",
++            interpreter=SimpleNamespace(tcl_lib=tcl_lib, tk_lib=tk_lib),
++            pyenv_cfg={},
++            env_name="my-env",
++        )
++        creator.bin_dir.mkdir()
++        FishActivator(Namespace(prompt=None)).generate(creator)
++        return creator.bin_dir / "activate.fish"
++
++    return render
++
+ 
+ @pytest.mark.parametrize(
+     ("tcl_lib", "tk_lib", "present"),
+     [
+         ("/path/to/tcl", "/path/to/tk", True),
++        ("/Program Files/tcl", "/Program Files/tk", True),
+         (None, None, False),
+     ],
+ )
+-def test_fish_tkinter_generation(tmp_path, tcl_lib, tk_lib, present) -> None:
+-    # GIVEN
+-    class MockInterpreter:
+-        pass
+-
+-    interpreter = MockInterpreter()
+-    interpreter.tcl_lib = tcl_lib
+-    interpreter.tk_lib = tk_lib
+-
+-    class MockCreator:
+-        def __init__(self, dest) -> None:
+-            self.dest = dest
+-            self.bin_dir = dest / "bin"
+-            self.bin_dir.mkdir()
+-            self.interpreter = interpreter
+-            self.pyenv_cfg = {}
+-            self.env_name = "my-env"
+-
+-    creator = MockCreator(tmp_path)
+-    options = Namespace(prompt=None)
+-    activator = FishActivator(options)
+-
+-    # WHEN
+-    activator.generate(creator)
+-    content = (creator.bin_dir / "activate.fish").read_text(encoding="utf-8")
+-
+-    # THEN
+-    # PKG_CONFIG_PATH is always set
++def test_fish_tkinter_generation(
++    rendered_activate_fish: Callable[[str | None, str | None], Path],
++    tcl_lib: str | None,
++    tk_lib: str | None,
++    present: bool,
++) -> None:
++    content = rendered_activate_fish(tcl_lib, tk_lib).read_text(encoding="utf-8")
++
+     assert 'set -gx _OLD_PKG_CONFIG_PATH "$PKG_CONFIG_PATH"' in content
+     assert 'set -gx PKG_CONFIG_PATH "$VIRTUAL_ENV/lib/pkgconfig:$PKG_CONFIG_PATH"' in content
+     assert "set -e _OLD_PKG_CONFIG_PATH" in content
+ 
+     if present:
+-        assert "set -gx TCL_LIBRARY '/path/to/tcl'" in content
+-        assert "set -gx TK_LIBRARY '/path/to/tk'" in content
++        assert f"set -gx TCL_LIBRARY {shlex.quote(tcl_lib)}\n" in content
++        assert f"set -gx TK_LIBRARY {shlex.quote(tk_lib)}\n" in content
+     else:
+         assert "if test -n ''\n  if set -q TCL_LIBRARY;" in content
+         assert "if test -n ''\n  if set -q TK_LIBRARY;" in content
+ 
+ 
[email protected](IS_WIN, reason="fish is not available on Windows")
[email protected](FISH is None, reason="fish is not installed")
++def test_fish_tkinter_path_does_not_run_commands(
++    rendered_activate_fish: Callable[[str | None, str | None], Path], tmp_path: Path
++) -> None:
++    marker = tmp_path / "PWNED"
++    script = rendered_activate_fish(f"/tcl/(touch {marker})/lib", "/tk/lib")
++
++    subprocess.run([FISH, "-c", f"source '{script}'"], capture_output=True, text=True, timeout=60, check=False)
++
++    assert not marker.exists()
++
++
+ @pytest.mark.skipif(IS_WIN, reason="we have not setup fish in CI yet")
+ def test_fish(activation_tester_class, activation_tester, monkeypatch, tmp_path) -> None:
+     monkeypatch.setenv("HOME", str(tmp_path))
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index 397c8bfafc..756a7842b8 100644
@@ -14,6 +14,7 @@ SRC_URI += " \
     file://CVE-2026-102930_p1.patch \
     file://CVE-2026-102930_p2.patch \
     file://CVE-2026-102930_p3.patch \
+    file://CVE-2026-102925.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#4 lore raw

PATCH 4/18 python3-virtualenv: fix CVE-2026-113732

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Use Fish-specific quoting so backslashes and quotes in an environment path or prompt remain literal data.

Include follow-up [3], released in [4], to preserve apostrophes and backslashes after multibyte text in Fish 3 legacy locales. Keep the upstream GBK and UTF-8 regression tests.

[1] https://github.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-c947-3pg5-gm8q
[3] https://github.com/pypa/virtualenv/commit/685435d7fb53da12da99e195ee2753f5ca083249
[4] https://github.com/pypa/virtualenv/releases/tag/21.14.9

---
 .../CVE-2026-113732_p1.patch                  | 116 +++++++++++++++++
 .../CVE-2026-113732_p2.patch                  | 120 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   2 +
 3 files changed, 238 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p2.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p1.patch new file +116 -0
new file mode 100644
index 0000000000..1afedad035
@@ -0,0 +1,116 @@
+From 3bddeaf8d02c3ee7f576503efb082f8f494cfcab Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Wed, 30 Sep 2026 22:59:45 -0700
+Subject: [PATCH] Merge commit from fork
+
+FishActivator inherited shlex.quote, whose POSIX rules leave a backslash
+literal inside single quotes. fish reads \' there as an escaped quote, so a
+path or --prompt with a backslash before a quote ended the literal early and
+ran the rest as commands, without any error from fish.
+
+Give FishActivator its own quote() that escapes backslashes and quotes.
+
+CVE: CVE-2026-113732
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab]
+
+Backport Changes:
+- Add the cli_run import required by the upstream regression test;
+  it is absent from the 21.2.1 test module.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/fish/__init__.py |  6 ++++
+ tests/unit/activation/test_fish.py         | 40 ++++++++++++++++++++--
+ 2 files changed, 43 insertions(+), 3 deletions(-)
+
+diff --git a/src/virtualenv/activation/fish/__init__.py b/src/virtualenv/activation/fish/__init__.py
+index 74300db..81d6d92 100644
+--- a/src/virtualenv/activation/fish/__init__.py
++++ b/src/virtualenv/activation/fish/__init__.py
+@@ -15,6 +15,12 @@ class FishActivator(ViaTemplateActivator):
+     def templates(self) -> Iterator[str]:
+         yield "activate.fish"
+ 
++    @staticmethod
++    def quote(string: str) -> str:
++        # fish reads \\ and \' as escapes inside single quotes, unlike POSIX sh, so shlex.quote's output lets a
++        # backslash before a quote end the literal early
++        return "'" + string.replace("\\", "\\\\").replace("'", "\\'") + "'"
++
+     def replacements(self, creator: Creator, dest_folder: Path) -> dict[str, str]:
+         data = super().replacements(creator, dest_folder)
+         data.update({
+diff --git a/tests/unit/activation/test_fish.py b/tests/unit/activation/test_fish.py
+index f726e7e..fc1b8a6 100644
+--- a/tests/unit/activation/test_fish.py
++++ b/tests/unit/activation/test_fish.py
+@@ -1,7 +1,6 @@
+ from __future__ import annotations
+ 
+ import os
+-import shlex
+ import shutil
+ import subprocess
+ import sys
+@@ -13,6 +12,7 @@ import pytest
+ 
+ from virtualenv.activation import FishActivator
+ from virtualenv.info import IS_WIN
++from virtualenv.run import cli_run
+ 
+ if TYPE_CHECKING:
+     from collections.abc import Callable
+@@ -59,8 +59,8 @@ def test_fish_tkinter_generation(
+     assert "set -e _OLD_PKG_CONFIG_PATH" in content
+ 
+     if present:
+-        assert f"set -gx TCL_LIBRARY {shlex.quote(tcl_lib)}\n" in content
+-        assert f"set -gx TK_LIBRARY {shlex.quote(tk_lib)}\n" in content
++        assert f"set -gx TCL_LIBRARY {FishActivator.quote(tcl_lib)}\n" in content
++        assert f"set -gx TK_LIBRARY {FishActivator.quote(tk_lib)}\n" in content
+     else:
+         assert "if test -n ''\n  if set -q TCL_LIBRARY;" in content
+         assert "if test -n ''\n  if set -q TK_LIBRARY;" in content
+@@ -79,6 +79,40 @@ def test_fish_tkinter_path_does_not_run_commands(
+     assert not marker.exists()
+ 
+ 
[email protected](IS_WIN, reason="fish is not available on Windows")
[email protected](FISH is None, reason="fish is not installed")
[email protected](
++    ("prompt", "env_name"),
++    [
++        pytest.param(r"x\'$(touch PWNED)'\'", "env", id="prompt-backslash-quote"),
++        pytest.param(None, r"x\'$(touch PWNED)'\'", id="dirname-backslash-quote"),
++    ],
++)
++def test_fish_activate_does_not_run_commands(
++    tmp_path: Path, current_fastest: str, prompt: str | None, env_name: str
++) -> None:
++    dest = tmp_path / env_name
++    args = ["--without-pip", str(dest), "--creator", current_fastest, "--no-periodic-update", "--activators", "fish"]
++    if prompt is not None:
++        args += ["--prompt", prompt]
++    cli_run(args)
++    (work_dir := tmp_path / "workdir").mkdir()
++
++    # the path is passed as an argument so the driver cannot expand a payload dir name while locating the script
++    result = subprocess.run(
++        [FISH, "--no-config", "-c", 'source $argv[1]; printf "%s" "$VIRTUAL_ENV"', str(dest / "bin" / "activate.fish")],
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        cwd=str(work_dir),
++        timeout=60,
++        check=False,
++    )
++
++    assert not (work_dir / "PWNED").exists()
++    assert result.stdout == str(dest), result.stderr
++
++
+ @pytest.mark.skipif(IS_WIN, reason="we have not setup fish in CI yet")
+ def test_fish(activation_tester_class, activation_tester, monkeypatch, tmp_path) -> None:
+     monkeypatch.setenv("HOME", str(tmp_path))
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732_p2.patch new file +120 -0

120 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +2 -0
index 756a7842b8..66354956b9 100644
@@ -15,6 +15,8 @@ SRC_URI += " \
     file://CVE-2026-102930_p2.patch \
     file://CVE-2026-102930_p3.patch \
     file://CVE-2026-102925.patch \
+    file://CVE-2026-113732_p1.patch \
+    file://CVE-2026-113732_p2.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#5 lore raw

PATCH 5/18 python3-virtualenv: fix CVE-2026-113776

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Replace activation-template placeholders in a single pass so placeholder names inside substituted paths or prompts cannot be expanded again as script content.

[1] https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-8rjx-v5ww-45pp

---
 .../python3-virtualenv/CVE-2026-113776.patch  | 133 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 134 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113776.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113776.patch new file +133 -0
new file mode 100644
index 0000000000..c1e034edb5
@@ -0,0 +1,133 @@
+From 602b26623a724827ff171bf11fef4ad186d01f74 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Wed, 30 Sep 2026 23:01:05 -0700
+Subject: [PATCH] Merge commit from fork
+
+instantiate_template replaced one placeholder at a time across the whole
+template, so a placeholder name inside an already quoted value, such as a
+parent directory named __VIRTUAL_NAME__, was rewritten from inside the
+finished literal. The second value's quotes closed the first, and the rest
+of the path ran as code in bash, fish, xonsh and activate_this.py; in csh
+the prompt display tokens broke activate.csh the same way.
+
+Build every token's final text first and substitute them in one regex pass,
+with the csh display tokens joining that pass through substitutions().
+
+CVE: CVE-2026-113776
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74]
+
+Backport Changes:
+- Omit the Csh display-token override and its specific test: 21.2.1 has
+  no separate display-token substitution or prompt-literal helpers.
+  Its Csh activator uses the corrected shared template substitution.
+- Exercise upstream's placeholder-in-parent-directory regression through
+  the existing Bash relocation fixture, since 21.2.1 lacks the later
+  prompt-test fixture. Add direct one-pass substitution checks for the
+  existing Bash, Csh, Fish and Python activators, and retain the 21.2.1
+  special-character fixture's other characters.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/via_template.py | 21 +++++++++++++++++----
+ tests/conftest.py                         |  3 ++-
+ tests/unit/activation/test_activator.py   | 16 ++++++++++++++++
+ tests/unit/activation/test_bash.py        |  1 +
+ 4 files changed, 36 insertions(+), 5 deletions(-)
+
+diff --git a/src/virtualenv/activation/via_template.py b/src/virtualenv/activation/via_template.py
+index 926c2b0..3af9dc5 100644
+--- a/src/virtualenv/activation/via_template.py
++++ b/src/virtualenv/activation/via_template.py
+@@ -1,6 +1,7 @@
+ from __future__ import annotations
+ 
+ import os
++import re
+ import shlex
+ import sys
+ from abc import ABC, abstractmethod
+@@ -84,10 +85,22 @@ class ViaTemplateActivator(Activator, ABC):
+         # read content as binary to avoid platform specific line normalization (\n -> \r\n)
+         binary = read_binary(self.__module__, template)
+         text = binary.decode("utf-8", errors="strict")
+-        for key, value in replacements.items():
+-            value_uni = self._repr_unicode(creator, value)
+-            text = text.replace(key, self.quote(value_uni))
+-        return text
++        substitutions = self.substitutions(replacements, creator)
++        # one pass over the template, so a placeholder name inside an already quoted value (a path component named
++        # __VIRTUAL_NAME__) stays data instead of being rewritten by a later key from inside the finished literal
++        pattern = re.compile("|".join(re.escape(key) for key in sorted(substitutions, key=len, reverse=True)))
++        return pattern.sub(lambda match: substitutions[match.group()], text)
++
++    def substitutions(self, replacements: dict[str, str], creator: Creator) -> dict[str, str]:
++        """Map each placeholder to the final text that replaces it in the template.
++
++        :param replacements: the raw placeholder values
++        :param creator: the creator of the environment
++
++        :returns: the placeholder to substituted text mapping
++
++        """
++        return {key: self.quote(self._repr_unicode(creator, value)) for key, value in replacements.items()}
+ 
+     @staticmethod
+     def _repr_unicode(creator: Creator, value: str) -> str:  # noqa: ARG004
+diff --git a/tests/conftest.py b/tests/conftest.py
+index 3ec4147..f27c450 100644
+--- a/tests/conftest.py
++++ b/tests/conftest.py
+@@ -279,7 +279,8 @@ def is_inside_ci():
+ 
+ @pytest.fixture(scope="session")
+ def special_char_name():
+-    base = "'\";&&e-$ èрт🚒♞中片-j"
++    # __VIRTUAL_NAME__ is a template placeholder, and must stay data when the path embeds it
++    base = "'\";&&e-$ __VIRTUAL_NAME__èрт🚒♞中片-j"
+     if IS_WIN:
+         # get rid of invalid characters on Windows
+         base = base.replace('"', "")
+diff --git a/tests/unit/activation/test_activator.py b/tests/unit/activation/test_activator.py
+index 21be96d..03481c2 100644
+--- a/tests/unit/activation/test_activator.py
++++ b/tests/unit/activation/test_activator.py
+@@ -4,9 +4,25 @@ from argparse import Namespace
+ 
+ import pytest
+ 
++from virtualenv.activation import BashActivator, CShellActivator, FishActivator, PythonActivator
+ from virtualenv.activation.activator import Activator
+ 
+ 
[email protected]("activator_class", [BashActivator, CShellActivator, FishActivator, PythonActivator])
++def test_template_substitution_does_not_expand_replacement_values(monkeypatch, activator_class) -> None:
++    template = b"__VIRTUAL_ENV__ __VIRTUAL_NAME__"
++    monkeypatch.setattr("virtualenv.activation.via_template.read_binary", lambda *_: template)
++    activator = activator_class(Namespace(prompt=None))
++    replacements = {
++        "__VIRTUAL_ENV__": "A__VIRTUAL_NAME__B/x'$(touch PWNED)'y",
++        "__VIRTUAL_NAME__": "x'$(touch PWNED)'y",
++    }
++
++    actual = activator.instantiate_template(replacements, "unused", None)
++
++    assert actual == " ".join(activator.quote(value) for value in replacements.values())
++
++
+ @pytest.mark.graalpy
+ def test_activator_prompt_cwd(monkeypatch, tmp_path) -> None:
+     class FakeActivator(Activator):
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index 00ac55f..df3aaf3 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -130,6 +130,7 @@ def test_bash_activate_relocation_resolves_virtual_env(
+         pytest.param("x'$(id > PWNED)'y", id="command-substitution"),
+         pytest.param("x'`id > PWNED`'y", id="backticks"),
+         pytest.param("a';id > PWNED;'b", id="statement-separator"),
++        pytest.param("A__VIRTUAL_NAME__B/x'$(touch PWNED)'y", id="placeholder-in-parent-dir"),
+     ],
+ )
+ def test_bash_activate_relocation_does_not_run_path_commands(
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index 66354956b9..65e50d3f88 100644
@@ -17,6 +17,7 @@ SRC_URI += " \
     file://CVE-2026-102925.patch \
     file://CVE-2026-113732_p1.patch \
     file://CVE-2026-113732_p2.patch \
+    file://CVE-2026-113776.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#6 lore raw

PATCH 6/18 python3-virtualenv: fix CVE-2026-113726

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Backport the upstream Zsh prompt fix [1] identified by advisory [3]. Include prerequisite [2] to provide the prompt-escaping block and regression-test fixture that the fix uses but 21.2.1 does not contain.

Escape prompt values before Zsh expands PS1, including when PROMPT_SUBST is enabled after activation, and preserve literal percent signs in the displayed environment name.

[1] https://github.com/pypa/virtualenv/commit/5b915367da82bd024b2a0d28d2f98007034b4aa2
[2] https://github.com/pypa/virtualenv/commit/a70c1dac43e2ee7e618132b572072395af5d8a9b
[3] https://github.com/pypa/virtualenv/security/advisories/GHSA-5vjq-rrrf-7h2q

---
 .../CVE-2026-113726-dependent.patch           | 168 ++++++++++++++++++
 .../python3-virtualenv/CVE-2026-113726.patch  | 149 ++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   2 +
 3 files changed, 319 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726-dependent.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726-dependent.patch new file +168 -0
new file mode 100644
index 0000000000..3c43b70fe8
@@ -0,0 +1,168 @@
+From a70c1dac43e2ee7e618132b572072395af5d8a9b Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 26 Sep 2026 09:35:09 -0700
+Subject: [PATCH] 🐛 fix(activation): stop bash re-expanding the prompt in PS1
+ (#3326)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113726
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/a70c1dac43e2ee7e618132b572072395af5d8a9b]
+
+Backport Changes:
+- Update the 21.2.1 activation tester's print_os_env_var("PS1") call
+  to use upstream's rendered-prompt check instead of its later raw-printf
+  implementation.
+- Omit the release-only changelog fragment; the release documentation
+  directory is absent from the 21.2.1 source distribution.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/bash/activate.sh |  11 ++-
+ tests/unit/activation/test_bash.py         | 102 ++++++++++++++++++++-
+ 2 files changed, 111 insertions(+), 2 deletions(-)
+
+diff --git a/src/virtualenv/activation/bash/activate.sh b/src/virtualenv/activation/bash/activate.sh
+index 18a78e5..76b9c39 100644
+--- a/src/virtualenv/activation/bash/activate.sh
++++ b/src/virtualenv/activation/bash/activate.sh
+@@ -115,7 +115,16 @@ fi
+ 
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
+     _OLD_VIRTUAL_PS1="${PS1-}"
+-    PS1="(${VIRTUAL_ENV_PROMPT}) ${PS1-}"
++    _VIRTUAL_PROMPT="${VIRTUAL_ENV_PROMPT}"
++    # bash re-expands backslashes, dollar signs and backticks in PS1 on every redraw; the guard keeps the
++    # bash-only substitution away from POSIX shells such as dash, which reject it with "Bad substitution"
++    if [ -n "${BASH_VERSION-}" ]; then
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\}"
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\$}"
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\`}"
++    fi
++    PS1="(${_VIRTUAL_PROMPT}) ${PS1-}"
++    unset _VIRTUAL_PROMPT
+     export PS1
+ fi
+ 
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index df3aaf3..e3608f1 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -141,6 +141,101 @@ def test_bash_activate_relocation_does_not_run_path_commands(
+     assert not (work_dir / "PWNED").exists()
+ 
+ 
[email protected]
++def bash_prompt_after_activate(tmp_path: Path, current_fastest: str) -> Callable[[str | None, str], tuple[Path, str]]:
++    version = subprocess.run(
++        ["bash", "-c", 'printf "%s" "$((BASH_VERSINFO[0] * 100 + BASH_VERSINFO[1]))"'],
++        capture_output=True,
++        text=True,
++        check=True,
++    ).stdout
++    if int(version) < 404:
++        pytest.skip("${PS1@P} needs bash 4.4 or later")
++
++    def build(prompt: str | None, env_name: str) -> tuple[Path, str]:
++        dest = tmp_path / env_name
++        args = [
++            "--without-pip",
++            str(dest),
++            "--creator",
++            current_fastest,
++            "--no-periodic-update",
++            "--activators",
++            "bash",
++        ]
++        if prompt is not None:
++            args += ["--prompt", prompt]
++        cli_run(args)
++        activate = dest / "bin" / "activate"
++        work_dir = tmp_path / "workdir"
++        work_dir.mkdir(exist_ok=True)
++        # the path is passed as $1 so the outer shell cannot expand a payload dir name while locating the script;
++        # ${PS1@P} then forces bash to render the prompt exactly as it does before each interactive command
++        result = subprocess.run(
++            ["bash", "--norc", "--noprofile", "-c", 'source "$1"; printf "%s" "${PS1@P}"', "bash", str(activate)],
++            capture_output=True,
++            text=True,
++            cwd=str(work_dir),
++            encoding="utf-8",
++            check=False,
++        )
++        return work_dir, result.stdout
++
++    return build
++
++
[email protected](IS_WIN, reason="Github Actions ships with WSL bash")
[email protected](
++    ("prompt", "env_name"),
++    [
++        pytest.param("x$(touch PWNED)y", "env", id="prompt-command-substitution"),
++        pytest.param("x`touch PWNED`y", "env", id="prompt-backticks"),
++        pytest.param(None, "x$(touch PWNED)y", id="dirname-command-substitution"),
++    ],
++)
++def test_bash_prompt_does_not_run_commands(
++    bash_prompt_after_activate: Callable[[str | None, str], tuple[Path, str]], prompt: str | None, env_name: str
++) -> None:
++    work_dir, _ = bash_prompt_after_activate(prompt, env_name)
++
++    assert not (work_dir / "PWNED").exists()
++
++
[email protected](IS_WIN, reason="Github Actions ships with WSL bash")
++def test_bash_prompt_keeps_plain_name_visible(
++    bash_prompt_after_activate: Callable[[str | None, str], tuple[Path, str]],
++) -> None:
++    _, rendered = bash_prompt_after_activate("myenv", "env")
++
++    assert rendered.startswith("(myenv) ")
++
++
[email protected](IS_WIN or shutil.which("dash") is None, reason="needs dash as a POSIX shell")
++def test_bash_activate_sources_under_dash(tmp_path: Path, current_fastest: str) -> None:
++    dest = tmp_path / "env"
++    cli_run([
++        "--without-pip",
++        str(dest),
++        "--creator",
++        current_fastest,
++        "--no-periodic-update",
++        "--activators",
++        "bash",
++        "--prompt",
++        "x$y",
++    ])
++
++    result = subprocess.run(
++        ["dash", "-c", '. "$1" && printf "%s" "$VIRTUAL_ENV"', "dash", str(dest / "bin" / "activate")],
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        check=False,
++    )
++
++    assert (result.returncode, result.stdout) == (0, str(dest))
++
++
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+ @pytest.mark.parametrize("hashing_enabled", [True, False])
+ def test_bash(raise_on_non_source_class, hashing_enabled, activation_tester) -> None:
+@@ -161,6 +256,11 @@ def test_bash(raise_on_non_source_class, hashing_enabled, activation_tester) ->
+             return super().activate_call(script) + " || exit 1"
+ 
+         def print_prompt(self):
+-            return self.print_os_env_var("PS1")
++            # render PS1 the way bash draws it, since the activator escapes the prompt for that expansion; bash before
++            # 4.4 lacks ${PS1@P}, so undo the escapes the way its prompt expansion would
++            return (
++                'if ((BASH_VERSINFO[0] * 100 + BASH_VERSINFO[1] >= 404)); then printf "%s\\n" "${PS1@P}"; '
++                "else printf '%s\\n' \"$PS1\" | sed 's/\\\\\\([$`\\\\]\\)/\\1/g'; fi"
++            )
+ 
+     activation_tester(Bash)
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113726.patch new file +149 -0

149 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +2 -0
index 65e50d3f88..cfb220fe41 100644
@@ -18,6 +18,8 @@ SRC_URI += " \
     file://CVE-2026-113732_p1.patch \
     file://CVE-2026-113732_p2.patch \
     file://CVE-2026-113776.patch \
+    file://CVE-2026-113726-dependent.patch \
+    file://CVE-2026-113726.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#7 lore raw

PATCH 7/18 python3-virtualenv: fix CVE-2026-113725

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Escape the Bash prompt for both its backslash decoding and expansion passes so backslashes cannot undo quoting.

[1] https://github.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-vxj4-q4g9-crj7

---
 .../python3-virtualenv/CVE-2026-113725.patch  | 88 +++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |  1 +
 2 files changed, 89 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113725.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113725.patch new file +88 -0
new file mode 100644
index 0000000000..56bc9a41eb
@@ -0,0 +1,88 @@
+From c3104e02474b652832a9bbaae79f6e1696296932 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sun, 11 Oct 2026 17:36:53 -0700
+Subject: [PATCH] 🐛 fix(activation): escape the bash prompt for both PS1
+ passes (#3390)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+bash handles `PS1` in two passes each time it draws the prompt: it first
+decodes backslash prompt escapes, turning `\\` into `\` and `\$` into
+`$` (or `#` for root), and then expands the result. The bash `activate`
+script escaped the environment name for the expansion pass only (#3326),
+so a backslash in the name undoes that escaping. 🔐 A name such as
+`a\$(touch PWNED)`, from the directory, `--prompt` or
+`VIRTUALENV_PROMPT`, runs the command each time bash draws the prompt.
+For root, `\$` decodes to `#`, so the same name renders wrong but runs
+nothing.
+
+Under bash, `activate` now escapes backslashes, dollar signs and
+backticks a second time, so both passes leave the name literal. zsh does
+no decode pass, so it keeps the single escaping added in 5b915367. The
+prompt tests gain cases for a backslash before `$(...)` and before
+backticks, and for names with a backslash before `$`, before a backtick,
+doubled, and trailing; they render through bash 5.2 and zsh 5.9 and pass
+as root and as an unprivileged user.
+
+Every release up to 21.14.6 is affected, and earlier releases before
+21.13.0 do not escape the name at all.
+
+CVE: CVE-2026-113725
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932]
+
+Backport Changes:
+- Omit the release-only changelog fragment; the release documentation
+  directory is absent from the 21.2.1 source distribution.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/bash/activate.sh | 8 +++++++-
+ tests/unit/activation/test_bash.py         | 6 ++++++
+ 2 files changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/src/virtualenv/activation/bash/activate.sh b/src/virtualenv/activation/bash/activate.sh
+index 0a372ff..1551d85 100644
+--- a/src/virtualenv/activation/bash/activate.sh
++++ b/src/virtualenv/activation/bash/activate.sh
+@@ -119,7 +119,13 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
+     # bash, and zsh under PROMPT_SUBST, re-expand backslashes, dollar signs and backticks in PS1 on every redraw;
+     # zsh gets the escaping even without the option, since a user can set it after activation. The guards keep
+     # the substitution away from POSIX shells such as dash, which reject it with "Bad substitution"
+-    if [ -n "${BASH_VERSION-}${ZSH_VERSION-}" ]; then
++    if [ -n "${BASH_VERSION-}" ]; then
++        # bash first decodes its backslash prompt escapes, turning \\ into \ and \$ into $ (or # for root), and only
++        # then expands the result, so each character needs escaping for both passes
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\\\\\}"
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\\\$}"
++        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\\\`}"
++    elif [ -n "${ZSH_VERSION-}" ]; then
+         _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\}"
+         _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\$}"
+         _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\`}"
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index defd2ed..4512932 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -200,6 +200,8 @@ def prompt_after_activate(
+         pytest.param("x$(touch PWNED)y", "env", id="prompt-command-substitution"),
+         pytest.param("x`touch PWNED`y", "env", id="prompt-backticks"),
+         pytest.param("x${$(touch PWNED)}y", "env", id="prompt-parameter-expansion"),
++        pytest.param("x\\$(touch PWNED)y", "env", id="prompt-backslash-command-substitution"),
++        pytest.param("x\\`touch PWNED`y", "env", id="prompt-backslash-backticks"),
+         pytest.param(None, "x$(touch PWNED)y", id="dirname-command-substitution"),
+     ],
+ )
+@@ -217,6 +219,10 @@ def test_prompt_does_not_run_commands(
+     [
+         pytest.param("myenv", id="plain"),
+         pytest.param("a%n$HOME\\b`c`", id="special-characters"),
++        pytest.param("a\\$HOME", id="backslash-before-dollar"),
++        pytest.param("a\\`c`", id="backslash-before-backtick"),
++        pytest.param("x\\\\y", id="doubled-backslash"),
++        pytest.param("e\\", id="trailing-backslash"),
+     ],
+ )
+ def test_prompt_renders_name_literally(
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index cfb220fe41..9cf1ea3b6b 100644
@@ -20,6 +20,7 @@ SRC_URI += " \
     file://CVE-2026-113776.patch \
     file://CVE-2026-113726-dependent.patch \
     file://CVE-2026-113726.patch \
+    file://CVE-2026-113725.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#8 lore raw

PATCH 8/18 python3-virtualenv: fix CVE-2026-113723

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Backport the upstream prompt-handling fix [1] identified by advisory [3]. Preserve literal prompts across Bash compatibility modes and leave PS1 unchanged in unsupported POSIX shells.

Include follow-up [2], identified by advisory [4], so later prompt option changes and child shells cannot execute the stored prompt. This also fixes CVE-2026-115586, a regression in the initial fix. Keep only the required Bash/Zsh security changes and regression tests.

[1] https://github.com/pypa/virtualenv/commit/5f48d711731311428aebfae61d46957762155b22
[2] https://github.com/pypa/virtualenv/commit/3598e201f6f044e389136b2347a8a919ac03c5f4
[3] https://github.com/pypa/virtualenv/security/advisories/GHSA-6w3r-xr62-4xcp
[4] https://github.com/pypa/virtualenv/security/advisories/GHSA-cx6f-vjhg-g3cc

---
 .../python3-virtualenv/CVE-2026-113723.patch  | 233 ++++++++
 .../python3-virtualenv/CVE-2026-115586.patch  | 526 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   2 +
 3 files changed, 761 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113723.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-115586.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113723.patch new file +233 -0
new file mode 100644
index 0000000000..d38b22a29a
@@ -0,0 +1,233 @@
+From 5f48d711731311428aebfae61d46957762155b22 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 02:35:17 -0700
+Subject: [PATCH] 🐛 fix(bash): preserve literal prompts in supported shells
+ (#3418)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113723
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/5f48d711731311428aebfae61d46957762155b22]
+
+Backport Changes:
+- Apply the prompt changes to 21.2.1's top-level activation block,
+  without importing the newer relocation wrapper; retain its PS1 export.
+- Add the missing Final import and replace the older print_prompt()
+  test helper with the upstream updated renderer.
+- Omit the upstream release changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/bash/activate.sh |  39 ++++----
+ tests/unit/activation/test_bash.py         | 105 +++++++++++++++++++--
+ 2 files changed, 115 insertions(+), 29 deletions(-)
+
+diff --git a/src/virtualenv/activation/bash/activate.sh b/src/virtualenv/activation/bash/activate.sh
+index 1551d85..992ad94 100644
+--- a/src/virtualenv/activation/bash/activate.sh
++++ b/src/virtualenv/activation/bash/activate.sh
+@@ -113,29 +113,26 @@ if [ __TK_LIBRARY__ != "" ]; then
+     export TK_LIBRARY
+ fi
+ 
+-if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
++if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] &&
++    { [ -n "${BASH_VERSION-}" ] || [ -n "${ZSH_VERSION-}" ]; }; then
+     _OLD_VIRTUAL_PS1="${PS1-}"
+-    _VIRTUAL_PROMPT="${VIRTUAL_ENV_PROMPT}"
+-    # bash, and zsh under PROMPT_SUBST, re-expand backslashes, dollar signs and backticks in PS1 on every redraw;
+-    # zsh gets the escaping even without the option, since a user can set it after activation. The guards keep
+-    # the substitution away from POSIX shells such as dash, which reject it with "Bad substitution"
+-    if [ -n "${BASH_VERSION-}" ]; then
+-        # bash first decodes its backslash prompt escapes, turning \\ into \ and \$ into $ (or # for root), and only
+-        # then expands the result, so each character needs escaping for both passes
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\\\\\}"
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\\\$}"
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\\\`}"
+-    elif [ -n "${ZSH_VERSION-}" ]; then
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\}"
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\$}"
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\`}"
++    # bash expands PS1 after decoding its prompt escapes when promptvars is on or in posix mode, so the prompt holds a
++    # reference to the variable and its value never reaches that expansion; otherwise only the decode runs and
++    # backslashes need doubling. zsh re-expands backslashes, dollar signs and backticks under PROMPT_SUBST, which a
++    # user can set after activation, and reads % as a prompt escape. The guards keep the substitutions away from
++    # POSIX shells such as dash, which reject them with "Bad substitution"
++    if [ -n "${BASH_VERSION-}" ] && { shopt -q promptvars || shopt -qo posix; }; then
++        PS1='(${VIRTUAL_ENV_PROMPT-}) '"${PS1-}"
++    else
++        _VIRTUAL_PROMPT="${VIRTUAL_ENV_PROMPT//\\/\\\\}"
++        if [ -n "${ZSH_VERSION-}" ]; then
++            _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\$}"
++            _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\`}"
++            _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\%/%%}"
++        fi
++        PS1="(${_VIRTUAL_PROMPT}) ${PS1-}"
++        unset _VIRTUAL_PROMPT
+     fi
+-    # zsh expands % sequences in PS1 as prompt escapes
+-    if [ -n "${ZSH_VERSION-}" ]; then
+-        _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\%/%%}"
+-    fi
+-    PS1="(${_VIRTUAL_PROMPT}) ${PS1-}"
+-    unset _VIRTUAL_PROMPT
+     export PS1
+ fi
+ 
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index 4512932..8c84544 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -3,7 +3,7 @@ from __future__ import annotations
+ import shutil
+ import subprocess
+ from argparse import Namespace
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
+ 
+ import pytest
+ 
+@@ -16,6 +16,48 @@ if TYPE_CHECKING:
+     from pathlib import Path
+ 
+ 
++_BASH: Final = shutil.which("bash")
++
++
[email protected](_BASH is None or (IS_WIN and "\\git\\" not in _BASH.lower()), reason="requires native bash")
[email protected](
++    ("setup", "expected"),
++    [
++        pytest.param("", "(${VIRTUAL_ENV_PROMPT-}) base ", id="bash"),
++        pytest.param("unset BASH_VERSION ZSH_VERSION;", "base ", id="unrecognized-shell"),
++    ],
++)
++def test_prompt_requires_known_shell(tmp_path: Path, current_fastest: str, setup: str, expected: str) -> None:
++    session: Final = cli_run([
++        str(tmp_path / "env"),
++        "--creator",
++        current_fastest,
++        "--without-pip",
++        "--no-periodic-update",
++        "--activators",
++        "bash",
++        "--prompt",
++        "example",
++    ])
++    result: Final = subprocess.run(
++        [
++            _BASH,
++            "--norc",
++            "--noprofile",
++            "-c",
++            f'{setup} PS1="base "; . "$1"; printf "%s|%s" "$PS1" "$VIRTUAL_ENV_PROMPT"',
++            "test",
++            str(session.creator.bin_dir / "activate"),
++        ],
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        timeout=30,
++        check=True,
++    )
++    assert result.stdout == f"{expected}|example"
++
++
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+ @pytest.mark.parametrize(
+     ("tcl_lib", "tk_lib", "present"),
+@@ -225,9 +267,14 @@ def test_prompt_does_not_run_commands(
+         pytest.param("e\\", id="trailing-backslash"),
+     ],
+ )
[email protected]("compatibility", [pytest.param("42", id="bash42"), pytest.param("51", id="bash51")])
+ def test_prompt_renders_name_literally(
+-    prompt_after_activate: Callable[[str | None, str], tuple[Path, str]], prompt: str
++    prompt_after_activate: Callable[[str | None, str], tuple[Path, str]],
++    prompt: str,
++    compatibility: str,
++    monkeypatch: pytest.MonkeyPatch,
+ ) -> None:
++    monkeypatch.setenv("BASH_COMPAT", compatibility)
+     _, rendered = prompt_after_activate(prompt, "env")
+ 
+     assert rendered.startswith(f"({prompt}) ")
+@@ -249,14 +296,20 @@ def test_bash_activate_sources_under_dash(tmp_path: Path, current_fastest: str)
+     ])
+ 
+     result = subprocess.run(
+-        ["dash", "-c", '. "$1" && printf "%s" "$VIRTUAL_ENV"', "dash", str(dest / "bin" / "activate")],
++        [
++            "dash",
++            "-c",
++            'PS1="base "; . "$1" && printf "%s|%s" "$VIRTUAL_ENV" "$PS1"',
++            "dash",
++            str(dest / "bin" / "activate"),
++        ],
+         capture_output=True,
+         text=True,
+         encoding="utf-8",
+         check=False,
+     )
+ 
+-    assert (result.returncode, result.stdout) == (0, str(dest))
++    assert (result.returncode, result.stdout) == (0, f"{dest}|base ")
+ 
+ 
+ @pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
+@@ -278,12 +331,48 @@ def test_bash(raise_on_non_source_class, hashing_enabled, activation_tester) ->
+         def activate_call(self, script):
+             return super().activate_call(script) + " || exit 1"
+ 
+-        def print_prompt(self):
+-            # render PS1 the way bash draws it, since the activator escapes the prompt for that expansion; bash before
+-            # 4.4 lacks ${PS1@P}, so undo the escapes the way its prompt expansion would
++        def print_prompt(self) -> str:
+             return (
+                 'if ((BASH_VERSINFO[0] * 100 + BASH_VERSINFO[1] >= 404)); then printf "%s\\n" "${PS1@P}"; '
+-                "else printf '%s\\n' \"$PS1\" | sed 's/\\\\\\([$`\\\\]\\)/\\1/g'; fi"
++                "else case \"$PS1\" in '(${VIRTUAL_ENV_PROMPT-}) '*) "
++                "printf '(%s) %s\\n' \"$VIRTUAL_ENV_PROMPT\" \"${PS1#'(${VIRTUAL_ENV_PROMPT-}) '}\";; "
++                "*) printf '%s\\n' \"$PS1\";; esac; fi"
+             )
+ 
+     activation_tester(Bash)
++
++
[email protected](IS_WIN, reason="requires POSIX bash")
[email protected](
++    ("before", "after", "expected"),
++    [
++        pytest.param("shopt -u promptvars", "", "(x$(touch PWNED)y) __END__", id="promptvars-disabled"),
++        pytest.param(
++            "shopt -u promptvars; set -o posix", "", "(x$(touch PWNED)y) __END__", id="promptvars-disabled-posix"
++        ),
++        pytest.param("", "set -u; unset VIRTUAL_ENV_PROMPT", "() __END__", id="unset-with-nounset"),
++    ],
++)
++def test_bash_prompt_options(tmp_path: Path, current_fastest: str, before: str, after: str, expected: str) -> None:
++    session: Final = cli_run([
++        "--without-pip",
++        str(tmp_path / "env"),
++        "--creator",
++        current_fastest,
++        "--no-periodic-update",
++        "--activators",
++        "bash",
++        "--prompt",
++        "x$(touch PWNED)y",
++    ])
++    result: Final = subprocess.run(
++        ["bash", "--noprofile", "--norc", "-i"],
++        input=f"{before}\nPS1=__END__\n. {BashActivator.quote(str(session.creator.bin_dir / 'activate'))}\n{after}\nexit\n",
++        cwd=tmp_path,
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        check=True,
++    )
++    assert expected in result.stderr
++    assert "unbound variable" not in result.stderr
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-115586.patch new file +526 -0

526 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +2 -0
index 9cf1ea3b6b..2c584361ab 100644
@@ -21,6 +21,8 @@ SRC_URI += " \
     file://CVE-2026-113726-dependent.patch \
     file://CVE-2026-113726.patch \
     file://CVE-2026-113725.patch \
+    file://CVE-2026-113723.patch \
+    file://CVE-2026-115586.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#9 lore raw

PATCH 9/18 python3-virtualenv: fix CVE-2026-113715

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Reject line boundaries in stdlib venv paths and regenerate pyvenv.cfg from the selected interpreter and options, instead of merging potentially injected configuration read back from the intermediate file.

[1] https://github.com/pypa/virtualenv/commit/b0008a58885ded9227faf8f910c6c402712c750a
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-qmx5-4p3x-wvqf

---
 .../python3-virtualenv/CVE-2026-113715.patch  | 165 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 166 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113715.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113715.patch new file +165 -0
new file mode 100644
index 0000000000..8ab16b5d93
@@ -0,0 +1,165 @@
+From b0008a58885ded9227faf8f910c6c402712c750a Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 02:56:02 -0700
+Subject: [PATCH] 🐛 fix(create): reject ambiguous venv paths (#3426)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113715
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/b0008a58885ded9227faf8f910c6c402712c750a]
+
+Backport Changes:
+- Reuse the identical _one_line helper already backported for
+  CVE-2026-102938 because 21.2.1 lacks the later
+  virtualenv.util.text.collapse_line_boundaries helper.
+- Use the 21.2.1 system_executable API and GraalVM implementation name
+  in the launcher settings and regression test instead of the later
+  system_exe API and GraalPy name.
+- Import Final in the older test module for the upstream annotations.
+- Omit the upstream release changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/create/via_global_ref/venv.py | 26 +++++++--
+ tests/unit/create/test_creator.py            | 56 ++++++++++++++++++++
+ 2 files changed, 77 insertions(+), 5 deletions(-)
+
+diff --git a/src/virtualenv/create/via_global_ref/venv.py b/src/virtualenv/create/via_global_ref/venv.py
+index 9c95d12..2bfd1b4 100644
+--- a/src/virtualenv/create/via_global_ref/venv.py
++++ b/src/virtualenv/create/via_global_ref/venv.py
+@@ -1,11 +1,12 @@
+ from __future__ import annotations
+ 
+ import logging
+-from copy import copy
+-from typing import TYPE_CHECKING
++from argparse import ArgumentTypeError
++from typing import TYPE_CHECKING, Final
+ 
+ from python_discovery import PythonInfo
+ 
++from virtualenv.create.pyenv_cfg import _one_line as collapse_line_boundaries
+ from virtualenv.create.via_global_ref.store import handle_store_python
+ from virtualenv.util.error import ProcessCallFailedError
+ from virtualenv.util.path import ensure_dir
+@@ -67,6 +68,20 @@ class Venv(ViaGlobalRefApi):
+             for exe in creator.executables(self.interpreter):
+                 exe.run(creator, self.symlinks)
+ 
++    @classmethod
++    def validate_dest(cls, raw_value: str) -> str:
++        return cls._check_line_boundaries(super().validate_dest(cls._check_line_boundaries(raw_value)))
++
++    @staticmethod
++    def _check_line_boundaries(value: str) -> str:
++        # stdlib venv writes the destination into pyvenv.cfg without escaping line boundaries.
++        if collapse_line_boundaries(value) != value:
++            msg: Final = (
++                f"destination {value!r} must not contain a line boundary as venv cannot record it in pyvenv.cfg"
++            )
++            raise ArgumentTypeError(msg)
++        return value
++
+     def create_inline(self) -> None:
+         from venv import EnvBuilder  # noqa: PLC0415
+ 
+@@ -95,10 +110,11 @@ class Venv(ViaGlobalRefApi):
+         return cmd  # ty: ignore[invalid-return-type]
+ 
+     def set_pyenv_cfg(self) -> None:
+-        # prefer venv options over ours, but keep our extra
+-        venv_content = copy(self.pyenv_cfg.refresh())
+         super().set_pyenv_cfg()
+-        self.pyenv_cfg.update(venv_content)
++        if self.interpreter.implementation == "GraalVM":
++            # GraalPy launchers need these settings on Windows and macOS.
++            self.pyenv_cfg["venvlauncher_command"] = self.interpreter.system_executable
++            self.pyenv_cfg["base-executable"] = self.interpreter.system_executable
+ 
+     def __getattribute__(self, item: str) -> object:
+         describe = object.__getattribute__(self, "describe")
+diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
+index 3a8ad25..bd0f071 100644
+--- a/tests/unit/create/test_creator.py
++++ b/tests/unit/create/test_creator.py
+@@ -19,6 +19,7 @@ from pathlib import Path
+ from stat import S_IREAD, S_IRGRP, S_IROTH
+ from textwrap import dedent
+ from threading import Thread
++from typing import Final
+ 
+ import pytest
+ from python_discovery import PythonInfo
+@@ -95,6 +96,42 @@ def system(session_app_data):
+ 
+ 
+ CURRENT_CREATORS = [i for i in CreatorSelector.for_interpreter(CURRENT).key_to_class if i != "builtin"]
++
++
[email protected]("venv" not in CURRENT_CREATORS, reason="stdlib venv is unavailable")
[email protected](
++    "boundary",
++    [
++        pytest.param(char, id=name)
++        for name, char in (
++            ("newline", "\n"),
++            ("return", "\r"),
++            ("vertical-tab", "\v"),
++            ("form-feed", "\f"),
++            ("file-separator", "\x1c"),
++            ("group-separator", "\x1d"),
++            ("record-separator", "\x1e"),
++            ("next-line", "\x85"),
++            ("line-separator", "\u2028"),
++            ("paragraph-separator", "\u2029"),
++        )
++    ],
++)
++def test_venv_creator_rejects_line_boundary(tmp_path: Path, capsys: pytest.CaptureFixture[str], boundary: str) -> None:
++    destination: Final = tmp_path / f"project{boundary}name"
++    with pytest.raises(SystemExit) as context:
++        cli_run([str(destination), "--creator", "venv", "--no-seed"])
++    assert context.value.code == 2
++    assert "must not contain a line boundary" in capsys.readouterr().err
++    assert not list(tmp_path.iterdir())
++
++
[email protected]("venv" not in CURRENT_CREATORS, reason="stdlib venv is unavailable")
++def test_venv_creator_accepts_plain_destination(tmp_path: Path) -> None:
++    session: Final = cli_run([str(tmp_path / "environment"), "--creator", "venv", "--no-seed"])
++    assert (session.creator.dest / "pyvenv.cfg").is_file()
++
++
+ CREATE_METHODS = []
+ for k, v in CreatorSelector.for_interpreter(CURRENT).key_to_meta.items():
+     if k in CURRENT_CREATORS:
+@@ -270,6 +307,25 @@ def test_create_vcs_ignore_exists_override(tmp_path) -> None:
+     assert git_ignore.read_text(encoding="utf-8") == "magic"
+ 
+ 
[email protected](not CURRENT.has_venv, reason="requires venv")
[email protected]("global_packages", [pytest.param(False, id="isolated"), pytest.param(True, id="global")])
++def test_venv_configuration_uses_selected_options(tmp_path: Path, global_packages: bool) -> None:
++    args: Final = [str(tmp_path / "env"), "--creator", "venv", "--no-seed"]
++    if global_packages:
++        args.append("--system-site-packages")
++    session: Final = cli_run(args)
++    session.creator.pyenv_cfg.path.write_text("vendor-marker = unused\n", encoding="utf-8")
++    session.creator.set_pyenv_cfg()
++    executable: Final = session.creator.interpreter.system_executable if CURRENT.implementation == "GraalVM" else None
++    expected: Final = {
++        "vendor-marker": None,
++        "include-system-site-packages": str(global_packages).lower(),
++        "venvlauncher_command": executable,
++        "base-executable": executable,
++    }
++    assert {key: session.creator.pyenv_cfg.content.get(key) for key in expected} == expected
++
++
+ @pytest.mark.skipif(not CURRENT.has_venv, reason="requires interpreter with venv")
+ def test_venv_fails_not_inline(tmp_path, capsys, mocker) -> None:
+     if hasattr(os, "geteuid") and os.geteuid() == 0:
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index 2c584361ab..d514e79358 100644
@@ -23,6 +23,7 @@ SRC_URI += " \
     file://CVE-2026-113725.patch \
     file://CVE-2026-113723.patch \
     file://CVE-2026-115586.patch \
+    file://CVE-2026-113715.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#10 lore raw

PATCH 10/18 python3-virtualenv: fix CVE-2026-113720

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Apply the current umask when copying interpreter and seed-package files instead of inheriting cached permission bits. Do not grant group or world write access to copied files.

[1] https://github.com/pypa/virtualenv/commit/35f0b33562790176dd186d0a3c517af3acc7a0e1
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-fc2g-4w5p-6whm

---
 .../python3-virtualenv/CVE-2026-113720.patch  | 156 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 157 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113720.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113720.patch new file +156 -0
new file mode 100644
index 0000000000..dad52942aa
@@ -0,0 +1,156 @@
+From 35f0b33562790176dd186d0a3c517af3acc7a0e1 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 02:57:36 -0700
+Subject: [PATCH] 🐛 fix(path): apply current permissions to copied files
+ (#3425)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113720
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/35f0b33562790176dd186d0a3c517af3acc7a0e1]
+
+Backport Changes:
+- Import Final without TYPE_CHECKING and remove the now-empty type-only
+  import block: moving Path to runtime leaves no type-only imports in
+  21.2.1's copy helper.
+- Add the copy and Final imports needed by the unchanged upstream
+  regression tests; these imports are absent from 21.2.1's test file.
+- Omit the upstream release changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/util/path/_sync.py | 35 +++++++++++++----------
+ tests/unit/test_util.py           | 47 ++++++++++++++++++++++++++++++-
+ 2 files changed, 66 insertions(+), 16 deletions(-)
+
+diff --git a/src/virtualenv/util/path/_sync.py b/src/virtualenv/util/path/_sync.py
+index 6d701b9..a94466f 100644
+--- a/src/virtualenv/util/path/_sync.py
++++ b/src/virtualenv/util/path/_sync.py
+@@ -4,11 +4,9 @@ import logging
+ import os
+ import shutil
+ import sys
+-from stat import S_IWUSR
+-from typing import TYPE_CHECKING
+-
+-if TYPE_CHECKING:
+-    from pathlib import Path
++from pathlib import Path
++from stat import S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR
++from typing import Final
+ 
+ LOGGER = logging.getLogger(__name__)
+ 
+@@ -40,22 +38,29 @@ def symlink(src: Path, dest: Path) -> None:
+ 
+ 
+ def copy(src: Path, dest: Path) -> None:
+-    ensure_safe_to_do(src, dest)
+-    is_dir = src.is_dir()
+-    method = copytree if is_dir else shutil.copy
+     LOGGER.debug("copy %s", _Debug(src, dest))
+-    method(str(src), str(dest))
++    if src.is_dir():
++        ensure_safe_to_do(src, dest)
++        copytree(str(src), str(dest))
++    else:
++        _copy_file(src, dest)
+ 
+ 
+ def copytree(src: str, dest: str) -> None:
+     for root, _, files in os.walk(src):
+-        dest_dir = os.path.join(dest, os.path.relpath(root, src))
+-        if not os.path.isdir(dest_dir):
+-            os.makedirs(dest_dir)
++        dest_dir: Final = Path(dest) / os.path.relpath(root, src)
++        dest_dir.mkdir(parents=True, exist_ok=True)
+         for name in files:
+-            src_f = os.path.join(root, name)
+-            dest_f = os.path.join(dest_dir, name)
+-            shutil.copy(src_f, dest_f)
++            _copy_file(Path(root) / name, dest_dir / name)
++
++
++def _copy_file(src: Path, dest: Path) -> None:
++    ensure_safe_to_do(src, dest)
++    mode: Final = 0o755 if src.stat().st_mode & (S_IXUSR | S_IXGRP | S_IXOTH) else 0o644
++    flags: Final = os.O_WRONLY | os.O_CREAT | os.O_EXCL | (os.O_BINARY if os.name == "nt" else 0)
++    # Creation applies the current umask without changing the process-wide setting.
++    with src.open("rb") as source, os.fdopen(os.open(str(dest), flags, mode), "wb") as target:
++        shutil.copyfileobj(source, target, length=1024 * 1024)
+ 
+ 
+ def safe_delete(dest: Path) -> None:
+diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
+index 2cdc038..ea7030b 100644
+--- a/tests/unit/test_util.py
++++ b/tests/unit/test_util.py
+@@ -3,18 +3,63 @@ from __future__ import annotations
+ import concurrent.futures
+ import os
+ import traceback
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
+ 
+ import pytest
+ 
+ from virtualenv.app_data import _cache_dir_with_migration, _default_app_data_dir
+ from virtualenv.util.lock import ReentrantFileLock
++from virtualenv.util.path import copy
+ from virtualenv.util.subprocess import run_cmd
+ 
+ if TYPE_CHECKING:
+     from pathlib import Path
+ 
+ 
[email protected](os.name != "posix", reason="POSIX permission bits")
[email protected]("directory", [pytest.param(False, id="file"), pytest.param(True, id="tree")])
[email protected](
++    ("source_mode", "mask", "expected"),
++    [
++        pytest.param(0o666, 0o022, 0o644, id="normal"),
++        pytest.param(0o666, 0o077, 0o600, id="private"),
++        pytest.param(0o444, 0o022, 0o644, id="read-only-source"),
++        pytest.param(0o600, 0o022, 0o644, id="private-source"),
++        pytest.param(0o777, 0o022, 0o755, id="executable"),
++        pytest.param(0o777, 0o077, 0o700, id="private-executable"),
++        pytest.param(0o666, 0o000, 0o644, id="permissive-umask"),
++        pytest.param(0o777, 0o000, 0o755, id="permissive-executable"),
++        pytest.param(0o666, 0o002, 0o644, id="group-umask"),
++        pytest.param(0o777, 0o002, 0o755, id="group-executable"),
++    ],
++)
++def test_copy_uses_current_umask(tmp_path: Path, directory: bool, source_mode: int, mask: int, expected: int) -> None:
++    source: Final = tmp_path / "source"
++    source.mkdir()
++    payload: Final = source / "entry"
++    payload.write_bytes(b"copied bytes")
++    payload.chmod(source_mode)
++    destination: Final = tmp_path / "destination"
++    previous: Final = os.umask(mask)
++    try:
++        copy(source if directory else payload, destination)
++    finally:
++        os.umask(previous)
++    result: Final = destination / "entry" if directory else destination
++    assert (result.read_bytes(), result.stat().st_mode & 0o777) == (b"copied bytes", expected)
++
++
[email protected]("directory", [pytest.param(False, id="file"), pytest.param(True, id="tree")])
++def test_copy_replaces_contents(tmp_path: Path, directory: bool) -> None:
++    source: Final = tmp_path / "source"
++    source.mkdir()
++    (source / "entry").write_bytes(b"new")
++    destination: Final = tmp_path / "destination"
++    destination.write_bytes(b"old")
++    copy(source if directory else source / "entry", destination)
++    assert (destination / "entry" if directory else destination).read_bytes() == b"new"
++
++
+ def test_run_fail(tmp_path) -> None:
+     code, out, err = run_cmd([str(tmp_path)])
+     assert err
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index d514e79358..bd92f92555 100644
@@ -24,6 +24,7 @@ SRC_URI += " \
     file://CVE-2026-113723.patch \
     file://CVE-2026-115586.patch \
     file://CVE-2026-113715.patch \
+    file://CVE-2026-113720.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#11 lore raw

PATCH 11/18 python3-virtualenv: fix CVE-2026-113719

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Restrict seed-package metadata cleanup to entries inside the environment, without deleting the environment itself or directories containing the metadata. Unlink final symlinks without following their targets.

[1] https://github.com/pypa/virtualenv/commit/e3cea6fa10a50fa29cf1fdddd772458fba076d5f
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-113719

---
 .../python3-virtualenv/CVE-2026-113719.patch  | 207 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 208 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113719.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113719.patch new file +207 -0
new file mode 100644
index 0000000000..078ae3974f
@@ -0,0 +1,207 @@
+From e3cea6fa10a50fa29cf1fdddd772458fba076d5f Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 03:19:58 -0700
+Subject: [PATCH] 🐛 fix(seed): contain metadata cleanup (#3428)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113719
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/e3cea6fa10a50fa29cf1fdddd772458fba076d5f]
+
+Backport Changes:
+- Add the Final import required by the unchanged upstream regression
+  tests; the older test module does not already import it.
+- Omit the upstream release changelog fragment, which is not shipped
+  in the 21.2.1 source archive.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ .../embed/via_app_data/pip_install/base.py    | 43 +++++----
+ .../embed/test_bootstrap_link_via_app_data.py | 88 ++++++++++++++++++-
+ 2 files changed, 115 insertions(+), 16 deletions(-)
+
+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
+index 89348aa..7697e73 100644
+--- a/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
++++ b/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
+@@ -9,7 +9,7 @@ from configparser import ConfigParser
+ from itertools import chain
+ from pathlib import Path
+ from tempfile import mkdtemp
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
+ 
+ from distlib.scripts import ScriptMaker, enquote_executable
+ 
+@@ -154,35 +154,48 @@ class PipInstall(ABC):
+         paths = (p for p in in_folders if p.stem.split("-")[0] == dist_name and p.suffix == ".dist-info" and p.is_dir())
+         existing_dist = next(paths, None)
+         if existing_dist is not None:
+-            self._uninstall_dist(existing_dist)
++            self._uninstall_dist(existing_dist, self._creator.dest)
+ 
+     @staticmethod
+-    def _uninstall_dist(dist: Path) -> None:
+-        dist_base = dist.parent
++    def _uninstall_dist(dist: Path, env_dir: Path) -> None:
++        dist_base: Final = dist.parent
+         LOGGER.debug("uninstall existing distribution %s from %s", dist.stem, dist_base)
+ 
+-        top_txt = dist / "top_level.txt"  # add top level packages at folder level
+-        paths = (
++        top_txt: Final = dist / "top_level.txt"
++        paths: Final = (
+             {dist.parent / i.strip() for i in top_txt.read_text(encoding="utf-8").splitlines()}
+             if top_txt.exists()
+             else set()
+         )
+-        paths.add(dist)  # add the dist-info folder itself
++        paths.add(dist)
+ 
+-        base_dirs, record = paths.copy(), dist / "RECORD"  # collect entries in record that we did not register yet
++        base_dirs: Final = paths.copy()
++        record: Final = dist / "RECORD"
+         for name in (
+             (i.split(",")[0] for i in record.read_text(encoding="utf-8").splitlines()) if record.exists() else ()
+         ):
+-            path = dist_base / name
+-            if not any(p in base_dirs for p in path.parents):  # only add if not already added as a base dir
++            path: Final = dist_base / name
++            if not any(p in base_dirs for p in path.parents):
+                 paths.add(path)
+ 
+-        for path in sorted(paths):  # actually remove stuff in a stable order
+-            if path.exists():
+-                if path.is_dir() and not path.is_symlink():
+-                    safe_delete(path)
++        root: Final = env_dir.resolve()
++        metadata_parents: Final = set(dist.resolve().parents)
++        for entry in sorted(paths):
++            if entry.exists() or entry.is_symlink():
++                linked: Final = entry.is_symlink()
++                # Unlinking the final link leaves its target intact; parent links still affect containment.
++                resolved: Final = entry.parent.resolve() / entry.name if linked else entry.resolve()
++                if root not in resolved.parents or resolved in metadata_parents:
++                    LOGGER.warning(
++                        "skip removal of %s listed by %s: not inside environment %s or a parent of the metadata",
++                        entry,
++                        dist.name,
++                        root,
++                    )
++                elif entry.is_dir() and not linked:
++                    safe_delete(entry)
+                 else:
+-                    path.unlink()
++                    entry.unlink()
+ 
+     def clear(self) -> None:
+         if self._image_dir.exists():
+diff --git a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+index 502f32a..278a48e 100644
+--- a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
++++ b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+@@ -6,7 +6,7 @@ import sys
+ from stat import S_IWGRP, S_IWOTH, S_IWUSR
+ from subprocess import Popen, check_call
+ from threading import Thread
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
+ 
+ import pytest
+ from python_discovery import PythonInfo
+@@ -23,6 +23,92 @@ if TYPE_CHECKING:
+     from pytest_mock import MockerFixture
+ 
+ 
[email protected](
++    ("metadata_file", "content"),
++    [
++        pytest.param("top_level.txt", "pip\n{dest}\n", id="top-level-env-root"),
++        pytest.param("top_level.txt", "pip\n\n", id="top-level-blank"),
++        pytest.param("RECORD", "{record}\n{outside},,", id="record-traversal"),
++    ],
++)
++def test_seed_metadata_cleanup_stays_inside_package(
++    tmp_path: Path, caplog: pytest.LogCaptureFixture, metadata_file: str, content: str
++) -> None:
++    args: Final = [str(tmp_path / "env"), "--pip", "embed", "--no-periodic-update"]
++    session: Final = cli_run(args, setup_logging=False)
++    purelib: Final = session.creator.purelib
++    markers: Final = [tmp_path / "keep.txt", session.creator.dest / "keep.txt", purelib / "keep.txt"]
++    for marker in markers:
++        marker.write_text("keep", encoding="utf-8")
++    dist_info: Final = next(purelib.glob("pip-*.dist-info"))
++    (dist_info / metadata_file).write_text(
++        content.format(
++            dest=session.creator.dest,
++            outside=os.path.relpath(markers[0], purelib),
++            record=(dist_info / "RECORD").read_text(encoding="utf-8"),
++        ),
++        encoding="utf-8",
++    )
++    cli_run(args, setup_logging=False)
++    assert (
++        [i.exists() for i in markers],
++        (purelib / "pip" / "__init__.py").is_file(),
++        "skip removal of" in caplog.text,
++    ) == (
++        [True, True, True],
++        True,
++        True,
++    )
++
++
[email protected](not fs_supports_symlink(), reason="symlinks are unavailable")
++def test_seed_metadata_unlinks_symlink_without_following(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None:
++    args: Final = [str(tmp_path / "env"), "--pip", "embed", "--no-periodic-update"]
++    session: Final = cli_run(args, setup_logging=False)
++    outside: Final = tmp_path / "outside"
++    outside.mkdir()
++    (outside / "keep.txt").write_text("keep", encoding="utf-8")
++    link: Final = session.creator.purelib / "linked"
++    link.symlink_to(outside, target_is_directory=True)
++    record: Final = next(session.creator.purelib.glob("pip-*.dist-info")) / "RECORD"
++    record.write_text(f"{record.read_text(encoding='utf-8')}\nlinked,,", encoding="utf-8")
++    cli_run(args, setup_logging=False)
++    assert (link.is_symlink(), (outside / "keep.txt").exists(), "skip removal of" in caplog.text) == (
++        False,
++        True,
++        False,
++    )
++
++
[email protected](
++    "linked",
++    [
++        pytest.param(False, id="copy"),
++        pytest.param(
++            True, id="symlink", marks=pytest.mark.skipif(not fs_supports_symlink(), reason="symlinks are unavailable")
++        ),
++    ],
++)
++def test_seed_metadata_keeps_reseeding_supported(
++    tmp_path: Path, linked: bool, caplog: pytest.LogCaptureFixture
++) -> None:
++    args: Final = [
++        str(tmp_path / "env"),
++        "--pip",
++        "embed",
++        "--no-periodic-update",
++        *(["--symlink-app-data"] if linked else []),
++    ]
++    cli_run(args, setup_logging=False)
++    session: Final = cli_run(args, setup_logging=False)
++    package: Final = session.creator.purelib / "pip"
++    assert ((package / "__init__.py").is_file(), package.is_symlink(), "skip removal of" in caplog.text) == (
++        True,
++        linked,
++        False,
++    )
++
++
+ @pytest.mark.slow
+ @pytest.mark.parametrize("copies", [False, True] if fs_supports_symlink() else [True])
+ def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies, for_py_version) -> None:  # noqa: PLR0915
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index bd92f92555..01b2125df7 100644
@@ -25,6 +25,7 @@ SRC_URI += " \
     file://CVE-2026-115586.patch \
     file://CVE-2026-113715.patch \
     file://CVE-2026-113720.patch \
+    file://CVE-2026-113719.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#12 lore raw

PATCH 12/18 python3-virtualenv: fix CVE-2026-113721

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Replace existing symbolic and hard links before writing generated files, and create the replacement files exclusively. Prepare the stdlib venv executable directory before it writes files.

[1] https://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-113721

---
 .../python3-virtualenv/CVE-2026-113721.patch  | 477 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 478 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113721.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113721.patch new file +477 -0
new file mode 100644
index 0000000000..a2c6b7257b
@@ -0,0 +1,477 @@
+From d25f28699eefb1fc34a251e5adf2b5de844c36cd Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 03:25:09 -0700
+Subject: [PATCH] 🐛 fix(create): replace generated file links (#3431)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
+
+CVE: CVE-2026-113721
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd]
+
+Backport Changes:
+- Replace PyEnvCfg's older write_text() call instead of write_bytes();
+  retain _one_line() serialization and separate the new helper import
+  from the type-only imports, without the later util.text refactor.
+- Add the Windows junction-constant guard absent from 21.2.1's helper
+  module and retain S_IWUSR for its existing deletion callback; do not
+  import the later read-only deletion refactor.
+- Add the missing fs_supports_symlink test import and extend the older
+  test_util path-import list with write_file.
+- Omit the release-only changelog fragment; the release documentation
+  directory is absent from the 21.2.1 source distribution.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/activation/via_template.py     |  21 ++-
+ src/virtualenv/create/creator.py              |   6 +-
+ src/virtualenv/create/pyenv_cfg.py            |   4 +-
+ src/virtualenv/create/via_global_ref/api.py   |   5 +-
+ src/virtualenv/create/via_global_ref/venv.py  |   8 +-
+ .../embed/via_app_data/pip_install/base.py    |   4 +
+ src/virtualenv/util/path/__init__.py          |   4 +-
+ src/virtualenv/util/path/_sync.py             |  46 ++++++-
+ tests/unit/create/test_creator.py             | 127 +++++++++++++++++-
+ tests/unit/test_util.py                       |  11 +-
+ 10 files changed, 213 insertions(+), 23 deletions(-)
+
+diff --git a/src/virtualenv/activation/via_template.py b/src/virtualenv/activation/via_template.py
+index 3af9dc5..3fba6ad 100644
+--- a/src/virtualenv/activation/via_template.py
++++ b/src/virtualenv/activation/via_template.py
+@@ -5,7 +5,9 @@ import re
+ import shlex
+ import sys
+ from abc import ABC, abstractmethod
+-from typing import TYPE_CHECKING
++from typing import TYPE_CHECKING, Final
++
++from virtualenv.util.path import write_file
+ 
+ from .activator import Activator
+ 
+@@ -63,18 +65,13 @@ class ViaTemplateActivator(Activator, ABC):
+     def _generate(
+         self, replacements: dict[str, str], templates: Iterable[str], to_folder: Path, creator: Creator
+     ) -> list[Path]:
+-        generated = []
++        generated: Final[list[Path]] = []
+         for template in templates:
+-            text = self.instantiate_template(replacements, template, creator)
+-            dest = to_folder / self.as_name(template)
+-            # remove the file if it already exists - this prevents permission
+-            # errors when the dest is not writable
+-            if dest.exists():
+-                dest.unlink()
+-            # Powershell assumes Windows 1252 encoding when reading files without BOM
+-            encoding = "utf-8-sig" if str(template).endswith(".ps1") else "utf-8"
+-            # use write_bytes to avoid platform specific line normalization (\n -> \r\n)
+-            dest.write_bytes(text.encode(encoding))
++            text: Final = self.instantiate_template(replacements, template, creator)
++            dest: Final = to_folder / self.as_name(template)
++            # PowerShell assumes Windows 1252 when the UTF-8 BOM is absent.
++            encoding: Final = "utf-8-sig" if str(template).endswith(".ps1") else "utf-8"
++            write_file(dest, text.encode(encoding))
+             generated.append(dest)
+         return generated
+ 
+diff --git a/src/virtualenv/create/creator.py b/src/virtualenv/create/creator.py
+index 9fa60d3..855d5a1 100644
+--- a/src/virtualenv/create/creator.py
++++ b/src/virtualenv/create/creator.py
+@@ -23,7 +23,7 @@ if TYPE_CHECKING:
+ 
+ from os.path import commonpath
+ 
+-from virtualenv.util.path import safe_delete
++from virtualenv.util.path import safe_delete, write_file
+ from virtualenv.util.subprocess import LogCmd, run_cmd
+ from virtualenv.version import __version__
+ 
+@@ -215,7 +215,7 @@ class Creator(ABC):
+                 # For information about cache directory tags, see:
+                 #   https://bford.info/cachedir/
+             """).strip()
+-            cachedir_tag_file.write_text(cachedir_tag_text, encoding="utf-8")
++            write_file(cachedir_tag_file, cachedir_tag_text.encode("utf-8"))
+ 
+     def set_pyenv_cfg(self) -> None:
+         self.pyenv_cfg.content = OrderedDict()
+@@ -237,7 +237,7 @@ class Creator(ABC):
+         # mark this folder to be ignored by VCS, handle https://www.python.org/dev/peps/pep-0610/#registered-vcs
+         git_ignore = self.dest / ".gitignore"
+         if not git_ignore.exists():
+-            git_ignore.write_text("# created by virtualenv automatically\n*\n", encoding="utf-8")
++            write_file(git_ignore, b"# created by virtualenv automatically\n*\n")
+         # Mercurial - does not support the .hgignore file inside a subdirectory directly, but only if included via the
+         # subinclude directive from root, at which point on might as well ignore the directory itself, see
+         # https://www.selenic.com/mercurial/hgignore.5.html for more details
+diff --git a/src/virtualenv/create/pyenv_cfg.py b/src/virtualenv/create/pyenv_cfg.py
+index 52411fb..c0fb345 100644
+--- a/src/virtualenv/create/pyenv_cfg.py
++++ b/src/virtualenv/create/pyenv_cfg.py
+@@ -5,6 +5,8 @@ import os
+ from collections import OrderedDict
+ from typing import TYPE_CHECKING, Final
+ 
++from virtualenv.util.path import write_file
++
+ if TYPE_CHECKING:
+     from pathlib import Path
+ 
+@@ -67,7 +69,7 @@ class PyEnvCfg:
+             LOGGER.debug("\t%s", line)
+             text += line
+             text += "\n"
+-        self.path.write_text(text, encoding="utf-8")
++        write_file(self.path, text.encode("utf-8"))
+ 
+     def refresh(self) -> OrderedDict[str, str]:
+         self.content = self._read_values(self.path)
+diff --git a/src/virtualenv/create/via_global_ref/api.py b/src/virtualenv/create/via_global_ref/api.py
+index 5cb8e12..5382419 100644
+--- a/src/virtualenv/create/via_global_ref/api.py
++++ b/src/virtualenv/create/via_global_ref/api.py
+@@ -8,6 +8,7 @@ from typing import TYPE_CHECKING
+ 
+ from virtualenv.create.creator import Creator, CreatorMeta
+ from virtualenv.info import fs_supports_symlink
++from virtualenv.util.path import write_file
+ 
+ if TYPE_CHECKING:
+     from argparse import ArgumentParser
+@@ -116,10 +117,10 @@ class ViaGlobalRefApi(Creator, ABC):
+         if text:
+             pth = self.purelib / "_virtualenv.pth"
+             LOGGER.debug("create virtualenv import hook file %s", pth)
+-            pth.write_text("import _virtualenv", encoding="utf-8")
++            write_file(pth, b"import _virtualenv")
+             dest_path = self.purelib / "_virtualenv.py"
+             LOGGER.debug("create %s", dest_path)
+-            dest_path.write_text(text, encoding="utf-8")
++            write_file(dest_path, text.encode("utf-8"))
+ 
+     def env_patch_text(self) -> str:
+         """Patch the distutils package to not be derailed by its configuration files."""
+diff --git a/src/virtualenv/create/via_global_ref/venv.py b/src/virtualenv/create/via_global_ref/venv.py
+index 2bfd1b4..8b704eb 100644
+--- a/src/virtualenv/create/via_global_ref/venv.py
++++ b/src/virtualenv/create/via_global_ref/venv.py
+@@ -9,7 +9,7 @@ from python_discovery import PythonInfo
+ from virtualenv.create.pyenv_cfg import _one_line as collapse_line_boundaries
+ from virtualenv.create.via_global_ref.store import handle_store_python
+ from virtualenv.util.error import ProcessCallFailedError
+-from virtualenv.util.path import ensure_dir
++from virtualenv.util.path import ensure_dir, ensure_within
+ from virtualenv.util.subprocess import run_cmd
+ 
+ from .api import ViaGlobalRefApi, ViaGlobalRefMeta
+@@ -50,6 +50,12 @@ class Venv(ViaGlobalRefApi):
+         return None
+ 
+     def create(self) -> None:
++        # stdlib venv writes interpreter files, configuration and activation scripts in place, so a planted symlink or
++        # hard link would receive them outside the environment
++        ensure_within(self.dest, self.bin_dir)
++        for path in (self.dest / "pyvenv.cfg", self.dest / ".gitignore", *self.bin_dir.iterdir()):
++            if path.is_symlink() or (path.is_file() and path.stat().st_nlink > 1):
++                path.unlink()
+         if self.can_be_inline:
+             self.create_inline()
+         else:
+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
+index 7697e73..086ae0c 100644
+--- a/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
++++ b/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
+@@ -219,6 +219,10 @@ class ScriptMakerCustom(ScriptMaker):
+         self, names: set[str], shebang: bytes, script_bytes: bytes, filenames: list[str], ext: str
+     ) -> None:
+         names.add(f"{self._name}{self.version_info[0]}.{self.version_info[1]}")
++        for name in names:
++            path: Final = Path(self.target_dir) / (f"{name}.exe" if os.name == "nt" else name)
++            if path.is_symlink():
++                path.unlink()
+         super()._write_script(names, shebang, script_bytes, filenames, ext)
+ 
+ 
+diff --git a/src/virtualenv/util/path/__init__.py b/src/virtualenv/util/path/__init__.py
+index c144d8d..451630f 100644
+--- a/src/virtualenv/util/path/__init__.py
++++ b/src/virtualenv/util/path/__init__.py
+@@ -1,16 +1,18 @@
+ from __future__ import annotations
+ 
+ from ._permission import make_exe, set_tree
+-from ._sync import copy, copytree, ensure_dir, safe_delete, symlink
++from ._sync import copy, copytree, ensure_dir, ensure_within, safe_delete, symlink, write_file
+ from ._win import get_short_path_name
+ 
+ __all__ = [
+     "copy",
+     "copytree",
+     "ensure_dir",
++    "ensure_within",
+     "get_short_path_name",
+     "make_exe",
+     "safe_delete",
+     "set_tree",
+     "symlink",
++    "write_file",
+ ]
+diff --git a/src/virtualenv/util/path/_sync.py b/src/virtualenv/util/path/_sync.py
+index a94466f..fae3859 100644
+--- a/src/virtualenv/util/path/_sync.py
++++ b/src/virtualenv/util/path/_sync.py
+@@ -5,9 +5,12 @@ import os
+ import shutil
+ import sys
+ from pathlib import Path
+-from stat import S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR
++from stat import S_ISDIR, S_ISLNK, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR
+ from typing import Final
+ 
++if os.name == "nt":
++    from stat import IO_REPARSE_TAG_MOUNT_POINT
++
+ LOGGER = logging.getLogger(__name__)
+ 
+ 
+@@ -17,6 +20,45 @@ def ensure_dir(path: Path) -> None:
+         os.makedirs(str(path))
+ 
+ 
++def ensure_within(root: Path, path: Path) -> None:
++    parts: Final = path.relative_to(root).parts
++    if ".." in parts:
++        msg: Final = f"environment directory {path} must remain inside {root}"
++        raise ValueError(msg)
++    ensure_dir(root)
++    folder = root
++    for part in parts:
++        folder /= part
++        try:
++            metadata: Final = folder.lstat()
++        except FileNotFoundError:
++            pass
++        else:
++            if S_ISLNK(metadata.st_mode):
++                LOGGER.warning("replace environment directory link %s", folder)
++                folder.unlink()
++            elif os.name == "nt" and metadata.st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT:
++                LOGGER.warning("replace environment directory junction %s", folder)
++                folder.rmdir()
++        try:
++            folder.mkdir()
++        except FileExistsError:
++            created: Final = folder.lstat()
++            if not S_ISDIR(created.st_mode) or (
++                os.name == "nt" and created.st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT
++            ):
++                msg: Final = f"environment directory is not a real directory: {folder}"
++                raise NotADirectoryError(msg) from None
++
++
++def write_file(path: Path, data: bytes) -> None:
++    if path.is_symlink() or path.exists():
++        path.unlink()
++    # Exclusive creation rejects links introduced after the old entry was removed.
++    with path.open("xb") as stream:
++        stream.write(data)
++
++
+ def ensure_safe_to_do(src: Path, dest: Path) -> None:
+     if src == dest:
+         msg = f"source and destination is the same {src}"
+@@ -90,6 +132,8 @@ __all__ = [
+     "copy",
+     "copytree",
+     "ensure_dir",
++    "ensure_within",
+     "safe_delete",
+     "symlink",
++    "write_file",
+ ]
+diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
+index bd0f071..bc02679 100644
+--- a/tests/unit/create/test_creator.py
++++ b/tests/unit/create/test_creator.py
+@@ -30,13 +30,101 @@ from virtualenv.create.pyenv_cfg import PyEnvCfg
+ from virtualenv.create.via_global_ref import api
+ from virtualenv.create.via_global_ref.builtin.cpython.common import is_mac_os_framework, is_macos_brew
+ from virtualenv.create.via_global_ref.builtin.cpython.cpython3 import CPython3Posix
+-from virtualenv.info import IS_PYPY, IS_WIN, fs_is_case_sensitive
++from virtualenv.info import IS_GRAALPY, IS_PYPY, IS_WIN, fs_is_case_sensitive, fs_supports_symlink
+ from virtualenv.run import cli_run, session_via_cli
+ from virtualenv.run.plugin.creators import CreatorSelector
+ 
+ CURRENT = PythonInfo.current_system()
+ 
+ 
[email protected]("creator_name", [pytest.param("builtin", id="builtin"), pytest.param("venv", id="venv")])
[email protected]("existing", [pytest.param(False, id="dangling"), pytest.param(True, id="existing")])
[email protected](
++    "generated",
++    [
++        pytest.param(name, id=name)
++        for name in ("pyvenv.cfg", "activate", "pip", "CACHEDIR.TAG", ".gitignore", "_virtualenv.py", "_virtualenv.pth")
++    ],
++)
++def test_creator_replaces_generated_file_links(
++    tmp_path: Path,
++    creator_name: str,
++    existing: bool,
++    generated: str,
++) -> None:
++    command: Final = [
++        str(tmp_path / "env"),
++        "--creator",
++        creator_name,
++        "--pip",
++        "embed",
++        "--no-periodic-update",
++    ]
++    if generated.startswith("_virtualenv"):
++        if (python39 := shutil.which("python3.9")) is None:
++            pytest.skip("Python 3.9 is unavailable")
++        command.extend(["--python", python39])
++    session: Final = session_via_cli(command)
++    session.creator.bin_dir.mkdir(parents=True)
++    target: Final = session.creator.dest / "original"
++    if existing:
++        target.write_bytes(b"original")
++    path = (
++        session.creator.bin_dir / ("pip.exe" if generated == "pip" and os.name == "nt" else generated)
++        if generated in {"activate", "pip"}
++        else session.creator.dest / generated
++    )
++    if generated.startswith("_virtualenv"):
++        path = session.creator.purelib / generated
++    path.parent.mkdir(parents=True, exist_ok=True)
++    path.symlink_to(target)
++    with session:
++        session.run()
++    if existing and (generated == "CACHEDIR.TAG" or (generated == ".gitignore" and creator_name == "builtin")):
++        assert path.is_symlink()
++    else:
++        assert not path.is_symlink()
++    assert (target.read_bytes() if existing else target.exists()) == (b"original" if existing else False)
++
++
[email protected](
++    "kind",
++    [
++        pytest.param("file", id="file"),
++        pytest.param("symlink", id="symlink"),
++        pytest.param("dangling", id="dangling"),
++        pytest.param("junction", id="junction"),
++    ],
++)
++def test_venv_prepares_real_executable_directory(tmp_path: Path, kind: str) -> None:
++    session: Final = session_via_cli([str(tmp_path / "env"), "--creator", "venv", "--no-seed", "--activators="])
++    session.creator.dest.mkdir()
++    if kind == "file":
++        session.creator.bin_dir.write_bytes(b"file")
++    else:
++        target: Final = session.creator.dest / "empty"
++        if kind != "dangling":
++            target.mkdir()
++        if kind == "junction":
++            if not IS_WIN:
++                pytest.skip("requires Windows junctions")
++            subprocess.run(
++                ["cmd", "/c", "mklink", "/J", str(session.creator.bin_dir), str(target)],
++                capture_output=True,
++                check=True,
++            )
++        else:
++            if not fs_supports_symlink():
++                pytest.skip("requires directory symlinks")
++            session.creator.bin_dir.symlink_to(target, target_is_directory=True)
++    if kind == "file":
++        with pytest.raises(NotADirectoryError, match="environment directory is not a real directory"):
++            session.run()
++    else:
++        session.run()
++        assert session.creator.bin_dir.resolve() == session.creator.bin_dir
++
++
+ def test_os_path_sep_not_allowed(tmp_path, capsys) -> None:
+     target = str(tmp_path / f"a{os.pathsep}b")
+     err = _non_success_exit_code(capsys, target)
+@@ -326,6 +414,43 @@ def test_venv_configuration_uses_selected_options(tmp_path: Path, global_package
+     assert {key: session.creator.pyenv_cfg.content.get(key) for key in expected} == expected
+ 
+ 
[email protected](not CURRENT.has_venv or not fs_supports_symlink(), reason="requires venv and symlinks")
[email protected](
++    is_mac_os_framework(CURRENT) or is_macos_brew(CURRENT) or (IS_GRAALPY and not IS_WIN),
++    reason="stdlib creator requires symlinks on this runtime",
++)
++def test_venv_recreate_with_copied_interpreter(tmp_path: Path) -> None:
++    args: Final = [str(tmp_path / "env"), "--creator", "venv", "--no-seed"]
++    cli_run([*args, "--symlinks"])
++    session: Final = cli_run([*args, "--copies"])
++    assert (session.creator.exe.is_file(), session.creator.exe.resolve().parent) == (
++        True,
++        session.creator.bin_dir.resolve(),
++    )
++
++
[email protected](not CURRENT.has_venv, reason="requires interpreter with venv")
[email protected]("mode", [pytest.param("--copies", id="copies"), pytest.param("--symlinks", id="symlinks")])
++def test_venv_replaces_hard_linked_files(tmp_path: Path, mode: str) -> None:
++    if mode == "--symlinks" and not fs_supports_symlink():
++        pytest.skip("requires symlinks")
++    if mode == "--copies" and (is_mac_os_framework(CURRENT) or is_macos_brew(CURRENT) or (IS_GRAALPY and not IS_WIN)):
++        pytest.skip("stdlib creator requires symlinks on this runtime")
++    session: Final = session_via_cli([str(tmp_path / "env"), "--creator", "venv", "--no-seed", "--activators=", mode])
++    session.creator.bin_dir.mkdir(parents=True)
++    names: Final = (
++        ("python.exe", "pythonw.exe") if IS_WIN else ("python", "python3", f"python3.{CURRENT.version_info.minor}")
++    )
++    planted: Final = [session.creator.dest / "pyvenv.cfg", *(session.creator.bin_dir / name for name in names)]
++    for path in planted:
++        (tmp_path / f"{path.name}.original").write_bytes(b"original")
++        os.link(tmp_path / f"{path.name}.original", path)
++    session.run()
++    assert [((tmp_path / f"{path.name}.original").read_bytes(), path.lstat().st_nlink) for path in planted] == [
++        (b"original", 1)
++    ] * len(planted)
++
++
+ @pytest.mark.skipif(not CURRENT.has_venv, reason="requires interpreter with venv")
+ def test_venv_fails_not_inline(tmp_path, capsys, mocker) -> None:
+     if hasattr(os, "geteuid") and os.geteuid() == 0:
+diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
+index ea7030b..c4c448a 100644
+--- a/tests/unit/test_util.py
++++ b/tests/unit/test_util.py
+@@ -9,7 +9,7 @@ import pytest
+ 
+ from virtualenv.app_data import _cache_dir_with_migration, _default_app_data_dir
+ from virtualenv.util.lock import ReentrantFileLock
+-from virtualenv.util.path import copy
++from virtualenv.util.path import copy, write_file
+ from virtualenv.util.subprocess import run_cmd
+ 
+ if TYPE_CHECKING:
+@@ -60,6 +60,15 @@ def test_copy_replaces_contents(tmp_path: Path, directory: bool) -> None:
+     assert (destination / "entry" if directory else destination).read_bytes() == b"new"
+ 
+ 
[email protected]("existing", [pytest.param(False, id="new"), pytest.param(True, id="replace")])
++def test_write_file_replaces_content(tmp_path: Path, existing: bool) -> None:
++    path: Final = tmp_path / "generated"
++    if existing:
++        path.write_bytes(b"previous")
++    write_file(path, b"generated")
++    assert path.read_bytes() == b"generated"
++
++
+ def test_run_fail(tmp_path) -> None:
+     code, out, err = run_cmd([str(tmp_path)])
+     assert err
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index 01b2125df7..bc31885a02 100644
@@ -26,6 +26,7 @@ SRC_URI += " \
     file://CVE-2026-113715.patch \
     file://CVE-2026-113720.patch \
     file://CVE-2026-113719.patch \
+    file://CVE-2026-113721.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#13 lore raw

PATCH 13/18 python3-virtualenv: fix CVE-2026-113716

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Replace linked output-directory components before creating interpreter, library and activation files. Reuse ensure_within from the preceding CVE-2026-113721 backport [3].

[1] https://github.com/pypa/virtualenv/commit/554d9f9d4f7758f5cf53f993031e29787f1f74c5
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-113716
[3] https://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd

---
 .../python3-virtualenv/CVE-2026-113716.patch  | 208 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 209 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113716.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113716.patch new file +208 -0
new file mode 100644
index 0000000000..e952796dd5
@@ -0,0 +1,208 @@
+From 554d9f9d4f7758f5cf53f993031e29787f1f74c5 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 03:36:11 -0700
+Subject: [PATCH] 🐛 fix(create): replace linked output directories (#3429)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113716
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/554d9f9d4f7758f5cf53f993031e29787f1f74c5]
+
+Backport Changes:
+- Add the fs_supports_symlink import required by the upstream utility
+  tests; it is absent from the 21.2.1 test module.
+- Extend the older test_util path import with ensure_within; the later
+  upstream module's safe_delete and symlink imports are unused here.
+- Omit the release-only changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ .../builtin/via_global_self_do.py             |  4 +-
+ src/virtualenv/create/via_global_ref/venv.py  |  7 ++-
+ tests/unit/create/test_creator.py             | 36 +++++++++++++
+ tests/unit/test_util.py                       | 54 ++++++++++++++++++-
+ 4 files changed, 94 insertions(+), 7 deletions(-)
+
+diff --git a/src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py b/src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py
+index f86861e..9ada4c1 100644
+--- a/src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py
++++ b/src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py
+@@ -9,7 +9,7 @@ from virtualenv.create.via_global_ref.builtin.ref import (
+     RefMust,
+     RefWhen,
+ )
+-from virtualenv.util.path import ensure_dir
++from virtualenv.util.path import ensure_within
+ 
+ from .builtin_way import VirtualenvBuiltin
+ 
+@@ -92,7 +92,7 @@ class ViaGlobalRefVirtualenvBuiltin(ViaGlobalRefApi, VirtualenvBuiltin, ABC):
+             if any(i for i in dirs if i is not directory and directory.parts == i.parts[: len(directory.parts)]):
+                 dirs.remove(directory)
+         for directory in sorted(dirs):
+-            ensure_dir(directory)
++            ensure_within(self.dest, directory)
+ 
+         self.set_pyenv_cfg()
+         self.pyenv_cfg.write()
+diff --git a/src/virtualenv/create/via_global_ref/venv.py b/src/virtualenv/create/via_global_ref/venv.py
+index 8b704eb..4e4fc77 100644
+--- a/src/virtualenv/create/via_global_ref/venv.py
++++ b/src/virtualenv/create/via_global_ref/venv.py
+@@ -9,7 +9,7 @@ from python_discovery import PythonInfo
+ from virtualenv.create.pyenv_cfg import _one_line as collapse_line_boundaries
+ from virtualenv.create.via_global_ref.store import handle_store_python
+ from virtualenv.util.error import ProcessCallFailedError
+-from virtualenv.util.path import ensure_dir, ensure_within
++from virtualenv.util.path import ensure_within
+ from virtualenv.util.subprocess import run_cmd
+ 
+ from .api import ViaGlobalRefApi, ViaGlobalRefMeta
+@@ -52,7 +52,8 @@ class Venv(ViaGlobalRefApi):
+     def create(self) -> None:
+         # stdlib venv writes interpreter files, configuration and activation scripts in place, so a planted symlink or
+         # hard link would receive them outside the environment
+-        ensure_within(self.dest, self.bin_dir)
++        for directory in (self.bin_dir, self.purelib, self.platlib):
++            ensure_within(self.dest, directory)
+         for path in (self.dest / "pyvenv.cfg", self.dest / ".gitignore", *self.bin_dir.iterdir()):
+             if path.is_symlink() or (path.is_file() and path.stat().st_nlink > 1):
+                 path.unlink()
+@@ -60,8 +61,6 @@ class Venv(ViaGlobalRefApi):
+             self.create_inline()
+         else:
+             self.create_via_sub_process()
+-        for lib in self.libs:  # ty: ignore[not-iterable]
+-            ensure_dir(lib)
+         if self.describe is not None:
+             self.describe.install_venv_shared_libs(self)
+         super().create()
+diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
+index bc02679..733a073 100644
+--- a/tests/unit/create/test_creator.py
++++ b/tests/unit/create/test_creator.py
+@@ -220,6 +220,42 @@ def test_venv_creator_accepts_plain_destination(tmp_path: Path) -> None:
+     assert (session.creator.dest / "pyvenv.cfg").is_file()
+ 
+ 
[email protected](
++    "junction",
++    [
++        pytest.param(
++            False, id="symlink", marks=pytest.mark.skipif(not fs_supports_symlink(), reason="symlinks are unavailable")
++        ),
++        pytest.param(True, id="junction", marks=pytest.mark.skipif(os.name != "nt", reason="Windows junctions")),
++    ],
++)
[email protected](
++    "creator_name",
++    [
++        pytest.param("builtin", id="builtin"),
++        pytest.param(
++            "venv",
++            id="venv",
++            marks=pytest.mark.skipif("venv" not in CURRENT_CREATORS, reason="stdlib venv is unavailable"),
++        ),
++    ],
++)
[email protected]("folder", [pytest.param("bin_dir", id="executables"), pytest.param("purelib", id="packages")])
++def test_creator_replaces_directory_links(tmp_path: Path, creator_name: str, folder: str, junction: bool) -> None:
++    session: Final = session_via_cli([str(tmp_path / "env"), "--creator", creator_name, "--no-seed"])
++    session.creator.dest.mkdir()
++    stored: Final = session.creator.dest / "stored"
++    stored.mkdir()
++    link: Final = session.creator.dest / getattr(session.creator, folder).relative_to(session.creator.dest).parts[0]
++    if junction:
++        subprocess.run(["cmd", "/c", "mklink", "/J", str(link), str(stored)], capture_output=True, check=True)
++    else:
++        link.symlink_to(stored, target_is_directory=True)
++    with session:
++        session.run()
++    assert (link.resolve(), session.creator.exe.is_file(), list(stored.iterdir())) == (link, True, [])
++
++
+ CREATE_METHODS = []
+ for k, v in CreatorSelector.for_interpreter(CURRENT).key_to_meta.items():
+     if k in CURRENT_CREATORS:
+diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
+index c4c448a..099798a 100644
+--- a/tests/unit/test_util.py
++++ b/tests/unit/test_util.py
+@@ -2,14 +2,16 @@ from __future__ import annotations
+ 
+ import concurrent.futures
+ import os
++import subprocess
+ import traceback
+ from typing import TYPE_CHECKING, Final
+ 
+ import pytest
+ 
+ from virtualenv.app_data import _cache_dir_with_migration, _default_app_data_dir
++from virtualenv.info import fs_supports_symlink
+ from virtualenv.util.lock import ReentrantFileLock
+-from virtualenv.util.path import copy, write_file
++from virtualenv.util.path import copy, ensure_within, write_file
+ from virtualenv.util.subprocess import run_cmd
+ 
+ if TYPE_CHECKING:
+@@ -69,6 +71,56 @@ def test_write_file_replaces_content(tmp_path: Path, existing: bool) -> None:
+     assert path.read_bytes() == b"generated"
+ 
+ 
[email protected]("existing", [pytest.param(False, id="new"), pytest.param(True, id="existing")])
++def test_environment_directories_create_nested_path(tmp_path: Path, existing: bool) -> None:
++    folder: Final = tmp_path / "env" / "lib" / "python"
++    if existing:
++        folder.mkdir(parents=True)
++    ensure_within(tmp_path / "env", folder)
++    assert folder.is_dir()
++
++
++def test_environment_directories_reject_regular_file(tmp_path: Path) -> None:
++    folder: Final = tmp_path / "file"
++    folder.touch()
++    with pytest.raises(NotADirectoryError, match="not a real directory"):
++        ensure_within(tmp_path, folder)
++
++
++def test_environment_directories_reject_parent_components(tmp_path: Path) -> None:
++    with pytest.raises(ValueError, match="must remain inside"):
++        ensure_within(tmp_path, tmp_path / ".." / "folder")
++
++
[email protected](not fs_supports_symlink(), reason="symlinks are unavailable")
[email protected](
++    "existing", [pytest.param(False, id="missing-target"), pytest.param(True, id="existing-target")]
++)
++def test_environment_directories_remove_links(tmp_path: Path, caplog: pytest.LogCaptureFixture, existing: bool) -> None:
++    target: Final = tmp_path / "stored"
++    if existing:
++        target.mkdir()
++    link: Final = tmp_path / "link"
++    link.symlink_to(target, target_is_directory=True)
++    ensure_within(tmp_path, link / "nested")
++    assert (
++        link.is_symlink(),
++        link.exists(),
++        target.exists(),
++        f"replace environment directory link {link}" in caplog.text,
++    ) == (False, True, existing, True)
++
++
[email protected](os.name != "nt", reason="Windows junctions")
++def test_environment_directories_report_replaced_junction(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None:
++    target: Final = tmp_path / "stored"
++    target.mkdir()
++    link: Final = tmp_path / "link"
++    subprocess.run(["cmd", "/c", "mklink", "/J", str(link), str(target)], check=True, capture_output=True)
++    ensure_within(tmp_path, link)
++    assert (link.resolve(), f"replace environment directory junction {link}" in caplog.text) == (link, True)
++
++
+ def test_run_fail(tmp_path) -> None:
+     code, out, err = run_cmd([str(tmp_path)])
+     assert err
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index bc31885a02..1a60c04c44 100644
@@ -27,6 +27,7 @@ SRC_URI += " \
     file://CVE-2026-113720.patch \
     file://CVE-2026-113719.patch \
     file://CVE-2026-113721.patch \
+    file://CVE-2026-113716.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#14 lore raw

PATCH 14/18 python3-virtualenv: fix CVE-2026-113722

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Preserve interpreter paths as literal data in POSIX console launchers for both the app-data and pip seeders, and update the pip launchers' RECORD hashes after rewriting them.

Include the RECORD-writing follow-up from [3] so the new rewrite path replaces existing links and uses exclusive creation. The required write_file helper comes from the preceding CVE-2026-113721 fix [4].

Regenerate existing environments to repair their launchers. A later independent pip install or upgrade can replace the corrected launchers; this backport does not modify pip's vendored distlib.

[1] https://github.com/pypa/virtualenv/commit/2519941bed33ee0d3ac99277f67913e439e476a9
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-113722
[3] https://github.com/pypa/virtualenv/commit/3598e201f6f044e389136b2347a8a919ac03c5f4
[4] https://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd

---
 .../CVE-2026-113722_p1.patch                  | 262 ++++++++++++++++++
 .../CVE-2026-113722_p2.patch                  |  50 ++++
 .../python/python3-virtualenv_21.2.1.bb       |   2 +
 3 files changed, 314 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p2.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p1.patch new file +262 -0
new file mode 100644
index 0000000000..26a6917c9a
@@ -0,0 +1,262 @@
+From 2519941bed33ee0d3ac99277f67913e439e476a9 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 03:41:16 -0700
+Subject: [PATCH] 🐛 fix(seed): preserve interpreter paths in console scripts
+ (#3417)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113722
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/2519941bed33ee0d3ac99277f67913e439e476a9]
+
+Backport Changes:
+- Add the os import absent from the older pip seeder and import only
+  shell_shebang, without the later EntryPointConfig helper. The older
+  module has no existing EntryPointConfig import to replace.
+- Omit the release-only changelog fragment; the release documentation
+  directory is absent from the 21.2.1 source distribution.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ src/virtualenv/seed/embed/pip_invoke.py       | 44 +++++++++
+ .../embed/via_app_data/pip_install/base.py    | 15 +++
+ .../embed/test_bootstrap_link_via_app_data.py | 92 ++++++++++++++++++-
+ 3 files changed, 150 insertions(+), 1 deletion(-)
+
+diff --git a/src/virtualenv/seed/embed/pip_invoke.py b/src/virtualenv/seed/embed/pip_invoke.py
+index 1f333d3..6a16605 100644
+--- a/src/virtualenv/seed/embed/pip_invoke.py
++++ b/src/virtualenv/seed/embed/pip_invoke.py
+@@ -1,14 +1,22 @@
+ from __future__ import annotations
+ 
++import csv
++import hashlib
++import io
+ import logging
++import os
++from base64 import urlsafe_b64encode
+ from contextlib import contextmanager
++from importlib.metadata import distributions
+ from pathlib import Path
+ from shutil import copyfile
++from stat import S_IMODE
+ from subprocess import Popen
+ from tempfile import TemporaryDirectory
+ from typing import TYPE_CHECKING, Final
+ 
+ from virtualenv.seed.embed.base_embed import BaseEmbed
++from virtualenv.seed.embed.via_app_data.pip_install.base import shell_shebang
+ from virtualenv.seed.wheels import get_wheel, pip_wheel_env_run
+ from virtualenv.seed.wheels.util import Version
+ from virtualenv.util.subprocess import LogCmd
+@@ -33,6 +41,42 @@ class PipInvoke(BaseEmbed):
+         with self.get_pip_install_cmd(creator.exe, for_py_version) as cmd:
+             env = pip_wheel_env_run(self.extra_search_dir, self.app_data, self.env)
+             self._execute(cmd, env)
++        if os.name == "posix":
++            self._rewrite_launchers(creator)
++
++    def _rewrite_launchers(self, creator: Creator) -> None:
++        selected: Final = self.distribution_to_versions()
++        exe: Final = str(creator.exe).encode("utf-8")
++        for distribution in distributions(path=sorted({str(creator.purelib), str(creator.platlib)})):
++            if distribution.metadata["Name"].lower().replace("-", "_") not in selected:
++                continue
++            rows: Final = list(csv.reader(io.StringIO(distribution.read_text("RECORD") or "")))
++            changed = False
++            for row in rows:
++                path: Final = Path(os.path.abspath(str(distribution.locate_file(row[0]))))
++                if path.parent != creator.script_dir or not path.is_file():
++                    continue
++                content = path.read_bytes()
++                if content.startswith(b"#!/bin/sh\n'''exec' "):
++                    body = content.split(b"\n", 3)[3]
++                elif content.startswith(b"#!" + exe + b"\n") and len(exe.split()) > 1:
++                    body = content.split(b"\n", 1)[1]
++                else:
++                    continue
++                content = shell_shebang(str(creator.exe)) + body
++                mode: Final = S_IMODE(path.stat().st_mode) & 0o755
++                path.unlink()
++                with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, mode), "wb") as stream:
++                    stream.write(content)
++                row[1:] = [
++                    "sha256=" + urlsafe_b64encode(hashlib.sha256(content).digest()).rstrip(b"=").decode("ascii"),
++                    str(len(content)),
++                ]
++                changed = True
++            if changed:
++                record: Final = next(row[0] for row in rows if row[0].endswith(".dist-info/RECORD"))
++                with Path(str(distribution.locate_file(record))).open("w", encoding="utf-8", newline="") as stream:
++                    csv.writer(stream).writerows(rows)
+ 
+     @staticmethod
+     def _execute(cmd: list[str], env: dict[str, str]) -> Popen[bytes]:
+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
+index 086ae0c..c741bd3 100644
+--- a/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
++++ b/src/virtualenv/seed/embed/via_app_data/pip_install/base.py
+@@ -3,6 +3,7 @@ from __future__ import annotations
+ import logging
+ import os
+ import re
++import shlex
+ import zipfile
+ from abc import ABC, abstractmethod
+ from configparser import ConfigParser
+@@ -214,6 +215,13 @@ class ScriptMakerCustom(ScriptMaker):
+         self.version_info = version_info.major, version_info.minor  # ty: ignore[unresolved-attribute]
+         self.variants = {"", "X", "X.Y"}
+         self._name = name
++        self._raw_executable = str(executable)
++
++    def _build_shebang(self, executable: bytes, post_interp: bytes) -> bytes:
++        shebang: Final = super()._build_shebang(executable, post_interp)
++        if os.name != "posix" or len(shebang.split()) == 1:
++            return shebang
++        return shell_shebang(self._raw_executable, post_interp)
+ 
+     def _write_script(
+         self, names: set[str], shebang: bytes, script_bytes: bytes, filenames: list[str], ext: str
+@@ -226,6 +234,13 @@ class ScriptMakerCustom(ScriptMaker):
+         super()._write_script(names, shebang, script_bytes, filenames, ext)
+ 
+ 
++def shell_shebang(executable: str, post_interp: bytes = b"") -> bytes:
++    # The exec line is read by both sh and Python; double-quoted backslashes survive both readers.
++    quoted: Final = shlex.quote(executable).replace("\\", "'\"\\\\\"'")
++    return b"#!/bin/sh\n'''exec' " + quoted.encode("utf-8") + post_interp + b' "$0" "$@"\n' + b"' '''\n"
++
++
+ __all__ = [
+     "PipInstall",
++    "shell_shebang",
+ ]
+diff --git a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+index 278a48e..a9917c4 100644
+--- a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
++++ b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+@@ -1,10 +1,13 @@
+ from __future__ import annotations
+ 
+ import contextlib
++import csv
++import hashlib
+ import os
+ import sys
++from base64 import urlsafe_b64encode
+ from stat import S_IWGRP, S_IWOTH, S_IWUSR
+-from subprocess import Popen, check_call
++from subprocess import Popen, check_call, run
+ from threading import Thread
+ from typing import TYPE_CHECKING, Final
+ 
+@@ -23,6 +26,7 @@ if TYPE_CHECKING:
+     from pytest_mock import MockerFixture
+ 
+ 
[email protected]("_no_coverage")
+ @pytest.mark.parametrize(
+     ("metadata_file", "content"),
+     [
+@@ -109,6 +113,70 @@ def test_seed_metadata_keeps_reseeding_supported(
+     )
+ 
+ 
[email protected](
++    "name",
++    [
++        pytest.param("plain", id="plain"),
++        pytest.param("two words", id="space"),
++        pytest.param("owner's env", id="apostrophe"),
++        pytest.param("$(echo a) `echo b`", id="command-substitution"),
++        pytest.param("a" * 120, id="long", marks=pytest.mark.skipif(os.name == "nt", reason="POSIX shebang limit")),
++        pytest.param("env \\path", id="backslash", marks=pytest.mark.skipif(os.name == "nt", reason="POSIX filename")),
++        pytest.param("env\tname", id="tab", marks=pytest.mark.skipif(os.name == "nt", reason="POSIX filename")),
++    ],
++)
[email protected](
++    "via_python",
++    [
++        pytest.param(False, id="launcher"),
++        pytest.param(
++            True, id="python", marks=pytest.mark.skipif(os.name == "nt", reason="Windows launcher is an executable")
++        ),
++    ],
++)
[email protected]("seeder", [pytest.param("app-data", id="app-data"), pytest.param("pip", id="pip")])
++def test_console_script_preserves_interpreter_path(
++    tmp_path: Path, current_fastest: str, name: str, via_python: bool, seeder: str
++) -> None:
++    destination: Final = os.path.join(str(tmp_path), name, "env")
++    run(
++        [
++            sys.executable,
++            "-m",
++            "virtualenv",
++            destination,
++            "--seeder",
++            seeder,
++            "--creator",
++            current_fastest,
++            "--activators",
++            "",
++            "--no-periodic-update",
++            "--pip",
++            "embed",
++        ],
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        timeout=60,
++        check=True,
++    )
++    scripts: Final = os.path.join(destination, "Scripts" if os.name == "nt" else "bin")
++    result: Final = run(
++        [
++            *([os.path.join(scripts, "python")] if via_python else []),
++            os.path.join(scripts, "pip.exe" if os.name == "nt" else "pip"),
++            "--version",
++        ],
++        capture_output=True,
++        text=True,
++        encoding="utf-8",
++        timeout=30,
++        check=True,
++    )
++    assert os.path.normcase(destination) in os.path.normcase(result.stdout)
++
++
+ @pytest.mark.slow
+ @pytest.mark.parametrize("copies", [False, True] if fs_supports_symlink() else [True])
+ def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies, for_py_version) -> None:  # noqa: PLR0915
+@@ -348,3 +416,25 @@ def _run_parallel_threads(tmp_path):
+     for thread in threads:
+         thread.join()
+     return exceptions
++
++
[email protected](os.name != "posix", reason="POSIX shell launchers")
[email protected](
++    ("name", "via_shell"),
++    [
++        pytest.param("plain", False, id="plain"),
++        pytest.param("two words", True, id="space"),
++        pytest.param("env\tname", True, id="tab"),
++    ],
++)
++def test_pip_launcher_record_matches_contents(tmp_path: Path, name: str, via_shell: bool) -> None:
++    session: Final = cli_run([str(tmp_path / name), "--seeder", "pip", "--pip", "embed", "--no-periodic-update"])
++    record: Final = next(session.creator.purelib.glob("pip-*.dist-info/RECORD"))
++    with record.open(encoding="utf-8", newline="") as stream:
++        row: Final = next(row for row in csv.reader(stream) if row[0].endswith("/bin/pip"))
++    content: Final = (session.creator.script_dir / "pip").read_bytes()
++    assert content.startswith(b"#!/bin/sh\n") is via_shell
++    assert row[1:] == [
++        "sha256=" + urlsafe_b64encode(hashlib.sha256(content).digest()).rstrip(b"=").decode("ascii"),
++        str(len(content)),
++    ]
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113722_p2.patch new file +50 -0

50 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +2 -0
index 1a60c04c44..b13b7d4fdd 100644
@@ -28,6 +28,8 @@ SRC_URI += " \
     file://CVE-2026-113719.patch \
     file://CVE-2026-113721.patch \
     file://CVE-2026-113716.patch \
+    file://CVE-2026-113722_p1.patch \
+    file://CVE-2026-113722_p2.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#15 lore raw

PATCH 15/18 python3-virtualenv: fix CVE-2026-113713

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. Always copy seed packages from temporary app-data, including when environment or configuration values enable symlinks. This keeps the environment usable after the temporary cache is removed.

Although NVD lists releases from 21.14.8, the project advisory [3] traces the incomplete guard to 20.0.6. The same unguarded constructor is present in 21.2.1, where the upstream regression tests reproduce dangling pip links after temporary-cache cleanup.

[1] https://github.com/pypa/virtualenv/commit/b81995c3feab9e1edb453c75ffc6616e1a77335e
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-113713
[3] https://github.com/pypa/virtualenv/security/advisories/GHSA-4f8h-vr72-p32c

---
 .../python3-virtualenv/CVE-2026-113713.patch  | 113 ++++++++++++++++++
 .../python/python3-virtualenv_21.2.1.bb       |   1 +
 2 files changed, 114 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113713.patch
meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113713.patch new file +113 -0
new file mode 100644
index 0000000000..8c56a5c228
@@ -0,0 +1,113 @@
+From b81995c3feab9e1edb453c75ffc6616e1a77335e Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <[email protected]>
+Date: Sat, 17 Oct 2026 10:09:55 -0700
+Subject: [PATCH] 🐛 fix(seed): copy from temporary app-data (#3437)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+CVE: CVE-2026-113713
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/b81995c3feab9e1edb453c75ffc6616e1a77335e]
+
+Backport Changes:
+- Omit the upstream release changelog fragment.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ .../seed/embed/via_app_data/via_app_data.py   |  4 +-
+ .../embed/test_bootstrap_link_via_app_data.py | 52 ++++++++++++++++++-
+ 2 files changed, 53 insertions(+), 3 deletions(-)
+
+diff --git a/src/virtualenv/seed/embed/via_app_data/via_app_data.py b/src/virtualenv/seed/embed/via_app_data/via_app_data.py
+index 092ef74..44ba70d 100644
+--- a/src/virtualenv/seed/embed/via_app_data/via_app_data.py
++++ b/src/virtualenv/seed/embed/via_app_data/via_app_data.py
+@@ -37,7 +37,9 @@ LOGGER = logging.getLogger(__name__)
+ class FromAppData(BaseEmbed):
+     def __init__(self, options: VirtualEnvOptions) -> None:
+         super().__init__(options)
+-        self.symlinks = options.symlink_app_data
++        self.symlinks = options.symlink_app_data and not self.app_data.transient
++        if options.symlink_app_data and self.app_data.transient:
++            LOGGER.debug("copy seed packages because temporary app-data is removed after creation")
+ 
+     @classmethod
+     def add_parser_arguments(cls, parser: ArgumentParser, interpreter: PythonInfo, app_data: AppData) -> None:
+diff --git a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+index a9917c4..fe07df7 100644
+--- a/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
++++ b/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py
+@@ -3,9 +3,11 @@ from __future__ import annotations
+ import contextlib
+ import csv
+ import hashlib
++import logging
+ import os
+ import sys
+ from base64 import urlsafe_b64encode
++from pathlib import Path
+ from stat import S_IWGRP, S_IWOTH, S_IWUSR
+ from subprocess import Popen, check_call, run
+ from threading import Thread
+@@ -21,11 +23,57 @@ from virtualenv.seed.wheels.embed import BUNDLE_FOLDER, BUNDLE_SUPPORT
+ from virtualenv.util.path import safe_delete
+ 
+ if TYPE_CHECKING:
+-    from pathlib import Path
+-
+     from pytest_mock import MockerFixture
+ 
+ 
[email protected](
++    "source",
++    [
++        pytest.param("environment", id="environment"),
++        pytest.param("configuration", id="configuration"),
++        pytest.param("command-line", id="command-line"),
++    ],
++)
++def test_transient_seed_survives_cache_cleanup(tmp_path: Path, source: str, unusable_cache: Path) -> None:
++    config: Final = tmp_path / "virtualenv.ini"
++    config.write_text("[virtualenv]\nsymlink_app_data = true\n" if source == "configuration" else "", encoding="utf-8")
++    env: Final = {
++        **os.environ,
++        "VIRTUALENV_CONFIG_FILE": str(config),
++        "VIRTUALENV_OVERRIDE_APP_DATA": str(unusable_cache),
++    }
++    if source == "environment":
++        env["VIRTUALENV_SYMLINK_APP_DATA"] = "true"
++    args: Final = [str(tmp_path / "env"), "--no-periodic-update", "--no-setuptools"]
++    if source == "command-line":
++        args.append("--symlink-app-data")
++    session: Final = cli_run(args, env=env)
++    assert (
++        session.creator.app_data.transient,
++        Path(str(session.creator.app_data)).exists(),
++        (session.creator.purelib / "pip" / "__init__.py").is_file(),
++    ) == (True, False, True)
++
++
++def test_transient_seed_reports_copy_fallback(
++    tmp_path: Path, caplog: pytest.LogCaptureFixture, unusable_cache: Path
++) -> None:
++    caplog.set_level(logging.DEBUG)
++    cli_run(
++        [str(tmp_path / "env"), "--no-periodic-update", "--no-setuptools"],
++        env={**os.environ, "VIRTUALENV_OVERRIDE_APP_DATA": str(unusable_cache), "VIRTUALENV_SYMLINK_APP_DATA": "true"},
++        setup_logging=False,
++    )
++    assert "copy seed packages because temporary app-data is removed after creation" in caplog.text
++
++
[email protected]
++def unusable_cache(tmp_path: Path) -> Path:
++    blocked: Final = tmp_path / "blocked"
++    blocked.touch()
++    return blocked / "cache"
++
++
+ @pytest.mark.usefixtures("_no_coverage")
+ @pytest.mark.parametrize(
+     ("metadata_file", "content"),
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index b13b7d4fdd..adeff3939a 100644
@@ -30,6 +30,7 @@ SRC_URI += " \
     file://CVE-2026-113716.patch \
     file://CVE-2026-113722_p1.patch \
     file://CVE-2026-113722_p2.patch \
+    file://CVE-2026-113713.patch \
 "
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.35.6
#16 lore raw

PATCH 16/18 python3-virtualenv: Ignore CVE-2026-102937

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Analysis:
- The advisory [1] describes command injection when Windows cmd.exe executes a generated activate.bat file.
- BatchActivator.supports() rejects Linux interpreters, so the Linux CLI does not select this activator.
- Limit the status to Linux TARGET_OS values. Leave other platforms, including MinGW SDK builds, unexcluded.
- The upstream fix is [2]; no backport is needed for Linux activation.

Reference:
[1] https://github.com/pypa/virtualenv/security/advisories/GHSA-x78j-v8h9-3j2q
[2] https://github.com/pypa/virtualenv/commit/d721ff140ce4afdc2a9b76751e4584e25d9fbea6

---
 .../recipes-devtools/python/python3-virtualenv_21.2.1.bb       | 3 +++
 1 file changed, 3 insertions(+)
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +3 -0
index adeff3939a..1a8091adcc 100644
@@ -52,3 +52,6 @@ RDEPENDS:${PN} += " \
 "
 
 CVE_PRODUCT = "virtualenv"
+
+# The batch activator only supports Windows interpreters.
+CVE_STATUS[CVE-2026-102937] = "${@'not-applicable-platform: Windows cmd.exe batch activation is not selected for Linux interpreters' if (d.getVar('TARGET_OS') or '').startswith('linux') else ''}"
Signature · 1 line
2.35.6
#17 lore raw

PATCH 17/18 python3-virtualenv: Ignore CVE-2026-113718

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Analysis:
- The advisory [1] limits this issue to Xonsh activation in versions 21.3.0 through 21.14.8.
- Version 21.2.1 has no Xonsh activator, activate.xsh template or registered entry point. None of the existing backports adds them.
- The upstream fix [2] changes the absent Xonsh quoting code, so it is not applicable to this recipe.

Reference:
[1] https://github.com/pypa/virtualenv/security/advisories/GHSA-394h-qwmc-48pf
[2] https://github.com/pypa/virtualenv/commit/e5fc2e6e189a877ff559af288919e3525d13e5e0

---
 meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb | 1 +
 1 file changed, 1 insertion(+)
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index 1a8091adcc..b554c3a4f8 100644
@@ -55,3 +55,4 @@ CVE_PRODUCT = "virtualenv"
 
 # The batch activator only supports Windows interpreters.
 CVE_STATUS[CVE-2026-102937] = "${@'not-applicable-platform: Windows cmd.exe batch activation is not selected for Linux interpreters' if (d.getVar('TARGET_OS') or '').startswith('linux') else ''}"
+CVE_STATUS[CVE-2026-113718] = "not-applicable-config: Xonsh activation was introduced in virtualenv 21.3.0 and is absent from 21.2.1"
Signature · 1 line
2.35.6
#18 lore raw

PATCH 18/18 python3-virtualenv: Ignore CVE-2026-113724

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Analysis:
- The advisory [1] describes a deletion-error callback changing the permissions of a symlink target.
- In 21.2.1, safe_delete() always passes ignore_errors=True to shutil.rmtree(), which disables the supplied error callback. This remains true after the existing security backports.
- Upstream enabled that callback later in [2]. The chmod recovery path fixed by [3] is therefore unreachable in this recipe.

Reference:
[1] https://github.com/pypa/virtualenv/security/advisories/GHSA-43mp-35q3-x3fq
[2] https://github.com/pypa/virtualenv/pull/3222
[3] https://github.com/pypa/virtualenv/commit/2bfdc0230d1b2685fedfcfe66c835b9a2ec7c440

---
 meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb | 1 +
 1 file changed, 1 insertion(+)
meta-python/recipes-devtools/python/python3-virtualenv_21.2.1.bb +1 -0
index b554c3a4f8..d5f598e576 100644
@@ -56,3 +56,4 @@ CVE_PRODUCT = "virtualenv"
 # The batch activator only supports Windows interpreters.
 CVE_STATUS[CVE-2026-102937] = "${@'not-applicable-platform: Windows cmd.exe batch activation is not selected for Linux interpreters' if (d.getVar('TARGET_OS') or '').startswith('linux') else ''}"
 CVE_STATUS[CVE-2026-113718] = "not-applicable-config: Xonsh activation was introduced in virtualenv 21.3.0 and is absent from 21.2.1"
+CVE_STATUS[CVE-2026-113724] = "not-applicable-config: safe_delete() uses ignore_errors=True, so its chmod error callback is unreachable"
Signature · 1 line
2.35.6