public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-virtualenv] f45: Security fix for CVE-2026-113776
@ 2026-11-24 17:56
0 siblings, 0 replies; only message in thread
From: @ 2026-11-24 17:56 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python-virtualenv
Branch : f45
Commit : 5a4135626e6693a67fd5c913b0a62302aafc8865
Author : Miro Hrončok <miro@hroncok.cz>
Date : 2026-11-24T15:56:22+01:00
Stats : +131/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python-virtualenv/c/5a4135626e6693a67fd5c913b0a62302aafc8865?branch=f45
Log:
Security fix for CVE-2026-113776
Assisted-By: Claude Sonnet 5.5
---
diff --git a/602b2662.patch b/602b2662.patch
new file mode 100644
index 0000000..44ea4b7
--- /dev/null
+++ b/602b2662.patch
@@ -0,0 +1,127 @@
+From 602b26623a724827ff171bf11fef4ad186d01f74 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 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().
+---
+ src/virtualenv/activation/cshell/__init__.py | 10 ++++++----
+ src/virtualenv/activation/via_template.py | 21 ++++++++++++++++----
+ tests/conftest.py | 3 ++-
+ tests/unit/activation/test_bash.py | 1 +
+ tests/unit/activation/test_csh.py | 3 ++-
+ 5 files changed, 28 insertions(+), 10 deletions(-)
+
+diff --git a/src/virtualenv/activation/cshell/__init__.py b/src/virtualenv/activation/cshell/__init__.py
+index 625ccb9c4..e8d38a7ba 100644
+--- a/src/virtualenv/activation/cshell/__init__.py
++++ b/src/virtualenv/activation/cshell/__init__.py
+@@ -31,13 +31,15 @@ class CShellActivator(ViaTemplateActivator):
+ # quotes and aborts the whole script with "Event not found"; only a backslash suppresses it
+ return shlex.quote(string).replace("!", "\\!")
+
+- def instantiate_template(self, replacements: dict[str, str], template: str, creator: Creator) -> str:
+- text = super().instantiate_template(replacements, template, creator)
++ def substitutions(self, replacements: dict[str, str], creator: Creator) -> dict[str, str]:
+ # carries its own quoting, so it cannot go through the shared quote() pass with the other replacements;
+ # tcsh and plain csh disagree on whether % needs escaping, so activate.csh picks one of these at runtime
+ display = creator.env_name if self.flag_prompt is None else self.flag_prompt
+- text = text.replace(_PROMPT_DISPLAY_TCSH, _prompt_literal(display, tcsh=True))
+- return text.replace(_PROMPT_DISPLAY_PLAIN, _prompt_literal(display, tcsh=False))
++ return {
++ **super().substitutions(replacements, creator),
++ _PROMPT_DISPLAY_TCSH: _prompt_literal(display, tcsh=True),
++ _PROMPT_DISPLAY_PLAIN: _prompt_literal(display, tcsh=False),
++ }
+
+
+ def _prompt_literal(value: str, *, tcsh: bool) -> str:
+diff --git a/src/virtualenv/activation/via_template.py b/src/virtualenv/activation/via_template.py
+index 58948bc26..66ca61f23 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: # ruff:ignore[unused-static-method-argument]
+diff --git a/tests/conftest.py b/tests/conftest.py
+index 766a62e62..f518f2675 100644
+--- a/tests/conftest.py
++++ b/tests/conftest.py
+@@ -281,7 +281,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:
+ # NTFS path components cannot contain any of these, regardless of where they sit in the string
+ for reserved in '<>:"/\\|?*;':
+diff --git a/tests/unit/activation/test_bash.py b/tests/unit/activation/test_bash.py
+index 4b42d5b36..e344d44c0 100644
+--- a/tests/unit/activation/test_bash.py
++++ b/tests/unit/activation/test_bash.py
+@@ -189,6 +189,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("x__VIRTUAL_NAME__'$(id > PWNED)'y", id="placeholder-in-path"),
+ ],
+ )
+ def test_bash_activate_relocation_does_not_run_path_commands(
+diff --git a/tests/unit/activation/test_csh.py b/tests/unit/activation/test_csh.py
+index f307360ab..25a01484a 100644
+--- a/tests/unit/activation/test_csh.py
++++ b/tests/unit/activation/test_csh.py
+@@ -149,9 +149,10 @@ def test_cshell_escapes_prompt_expansion(
+ pytest.param("has!bang", id="bang"),
+ pytest.param("has!!doublebang", id="double-bang"),
+ pytest.param("has'quote!bang", id="quote-and-bang"),
++ pytest.param("A__VIRTUAL_PROMPT_DISPLAY_TCSH__B", id="display-placeholder"),
+ ],
+ )
+-def test_cshell_activates_path_with_history_character(
++def test_cshell_activates_path_with_special_characters(
+ csh_venv: Callable[[str], tuple[Path, str]], tmp_path: Path, name: str
+ ) -> None:
+ dest, content = csh_venv(name)
diff --git a/python-virtualenv.spec b/python-virtualenv.spec
index c1fcdd8..5d9ad4c 100644
--- a/python-virtualenv.spec
+++ b/python-virtualenv.spec
@@ -21,6 +21,10 @@ Patch: python3.6.patch
# Backported from https://github.com/pypa/virtualenv/commit/cd5310be (only the JSON files)
Patch: discovery-fixtures.patch
+# CVE-2026-113776: Arbitrary command execution via sequential placeholder substitution in activation templates
+# https://github.com/pypa/virtualenv/commit/602b2662 rebased (changed in tests only)
+Patch: 602b2662.patch
+
BuildArch: noarch
BuildRequires: python3-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 17:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 17:56 [rpms/python-virtualenv] f45: Security fix for CVE-2026-113776
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox