diff mbox series

[meta-python,scarthgap,03/12] python3-virtualenv: fix CVE-2026-113732

Message ID 20261124050942.1795310-4-hthakar@cisco.com
State New
Headers show
Series python3-virtualenv: Security fixes | expand

Commit Message

From: Hetvi Thakar <hthakar@cisco.com>

This patch backports the upstream fix in [1], identified by the
upstream security advisory in [2], to virtualenv 20.25.3.

[1] https://github.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab
[2] https://github.com/pypa/virtualenv/security/advisories/GHSA-c947-3pg5-gm8q

Include the corrected Fish 3 multibyte and legacy-locale quoting
from upstream 685435d7fb53da12da99e195ee2753f5ca083249, with
activation-level path and prompt coverage.

Package each additional upstream prerequisite or correction in its own
embedded patch with its own upstream metadata.

Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
---
 .../python3-virtualenv/CVE-2026-113732.patch  |  66 +++++++
 .../fish3-multibyte-quoting.patch             | 165 ++++++++++++++++++
 .../python/python3-virtualenv_20.25.3.bb      |   2 +
 3 files changed, 233 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-virtualenv/fish3-multibyte-quoting.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732.patch b/meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732.patch
new file mode 100644
index 0000000000..452c69432a
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-virtualenv/CVE-2026-113732.patch
@@ -0,0 +1,66 @@ 
+From 3bddeaf8d02c3ee7f576503efb082f8f494cfcab Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= <gaborjbernat@gmail.com>
+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:
+ - Adapt the quoting method to the older untyped FishActivator interface.
+ - Replace the newer upstream fixtures with quote-value checks for this
+   test layout; the older source has no Tcl/Tk activation paths.
+
+Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
+---
+ src/virtualenv/activation/fish/__init__.py |  6 ++++++
+ tests/unit/activation/test_fish.py         | 12 ++++++++++++
+ 2 files changed, 18 insertions(+)
+
+diff --git a/src/virtualenv/activation/fish/__init__.py b/src/virtualenv/activation/fish/__init__.py
+index 57f790f47382be6c1ed5d10a9e627e71be562e42..a402ce1d4483f1ea329d736405136d22e41eb543 100644
+--- a/src/virtualenv/activation/fish/__init__.py
++++ b/src/virtualenv/activation/fish/__init__.py
+@@ -7,6 +7,12 @@ class FishActivator(ViaTemplateActivator):
+     def templates(self):
+         yield "activate.fish"
+ 
++    @staticmethod
++    def quote(string):
++        # 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("'", "\\'") + "'"
++
+ 
+ __all__ = [
+     "FishActivator",
+diff --git a/tests/unit/activation/test_fish.py b/tests/unit/activation/test_fish.py
+index 6a92a27909077d18eeb4674594dd878fe49899a5..8a9397ea5fb15d600082ed27f873f4264a908c18 100644
+--- a/tests/unit/activation/test_fish.py
++++ b/tests/unit/activation/test_fish.py
+@@ -6,6 +6,18 @@ from virtualenv.activation import FishActivator
+ from virtualenv.info import IS_WIN
+ 
+ 
++@pytest.mark.parametrize(
++    ("value", "expected"),
++    [
++        ("", "''"),
++        ("plain path", "'plain path'"),
++        ("a\\b'c", "'a\\\\b\\'c'"),
++    ],
++)
++def test_fish_quote(value, expected):
++    assert FishActivator.quote(value) == expected
++
++
+ @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):
+     monkeypatch.setenv("HOME", str(tmp_path))
diff --git a/meta-python/recipes-devtools/python/python3-virtualenv/fish3-multibyte-quoting.patch b/meta-python/recipes-devtools/python/python3-virtualenv/fish3-multibyte-quoting.patch
new file mode 100644
index 0000000000..20ed6cb465
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-virtualenv/fish3-multibyte-quoting.patch
@@ -0,0 +1,165 @@ 
+From 685435d7fb53da12da99e195ee2753f5ca083249 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <gaborjbernat@gmail.com>
+Date: Sat, 17 Oct 2026 02:08:22 -0700
+Subject: [PATCH]