new file mode 100644
@@ -0,0 +1,148 @@
+From 602b26623a724827ff171bf11fef4ad186d01f74 Mon Sep 17 00:00:00 2001
+From: Bernát Gábor <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().
+
+CVE: CVE-2026-113776
+Upstream-Status: Backport [https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74]
+
+Backport Changes:
+ - Retain the untyped 20.25.3 method signatures. Omit the newer C shell
+ display-token override, whose tokens and helpers are absent here.
+ - Exercise literal placeholder names through unittest renderer and actual
+ Bash/Python activation checks for the older test layout.
+
+Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
+---
+ src/virtualenv/activation/via_template.py | 21 ++++++--
+ tests/unit/activation/test_cve_2026_113776.py | 73 +++++++++++++++++++++++++++
+ 2 files changed, 90 insertions(+), 4 deletions(-)
+
+diff --git a/src/virtualenv/activation/via_template.py b/src/virtualenv/activation/via_template.py
+index 1f532213c3a915a113b780cc0ee1a0cdb0f841a2..a1c7b5b62a0062a1ffc8591bf05ba2254dcccc7e 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
+@@ -72,10 +73,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, creator):
++ """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, value): # noqa: ARG004
+diff --git a/tests/unit/activation/test_cve_2026_113776.py b/tests/unit/activation/test_cve_2026_113776.py
+new file mode 100644
+index 0000000000000000000000000000000000000000..3a767dd44a92882b9705d7ff847928dc1e7a2b78
+--- /dev/null
++++ b/tests/unit/activation/test_cve_2026_113776.py
+@@ -0,0 +1,73 @@
++"""Keep placeholder names in activation values as literal data."""
++from __future__ import annotations
++
++import json
++import os
++from pathlib import Path
++import shutil
++import subprocess
++import sys
++import tempfile
++from types import SimpleNamespace
++import unittest
++from unittest.mock import patch
++
++from virtualenv.activation import BashActivator, PythonActivator
++from virtualenv.run import cli_run
++
++
++class TemplateSubstitutionTests(unittest.TestCase):
++ def test_replacement_values_are_not_rescanned(self):
++ values = {
++ "__VIRTUAL_ENV__": "/parent__VIRTUAL_NAME__/owner's env",
++ "__VIRTUAL_NAME__": "plain",
++ "__VIRTUAL_PROMPT__": "show __VIRTUAL_ENV__ literally",
++ }
++ template = "\n".join(values).encode()
++ for activator_type in (BashActivator, PythonActivator):
++ activator = activator_type(SimpleNamespace(prompt=None))
++ expected = "\n".join(activator.quote(value) for value in values.values())
++ for order in (list(values), list(reversed(values))):
++ with self.subTest(activator=activator_type.__name__, order=order), patch(
++ "virtualenv.activation.via_template.read_binary", return_value=template
++ ):
++ result = activator.instantiate_template({key: values[key] for key in order}, "template", None)
++ self.assertEqual(result, expected)
++
++ def test_longest_token_is_matched_first(self):
++ activator = BashActivator(SimpleNamespace(prompt=None))
++ with patch("virtualenv.activation.via_template.read_binary", return_value=b"__TOKEN__LONG __UNKNOWN__"):
++ result = activator.instantiate_template({"__TOKEN__": "short", "__TOKEN__LONG": "long"}, "template", None)
++ self.assertEqual(result, "long __UNKNOWN__")
++
++ def test_activation_preserves_placeholder_names_in_path_and_prompt(self):
++ bash = shutil.which("bash")
++ if bash is None:
++ self.skipTest("bash is not installed")
++ with tempfile.TemporaryDirectory() as directory:
++ dest = Path(directory) / "parent__VIRTUAL_NAME__" / "owner's env"
++ prompt = "plain __VIRTUAL_ENV__ and __VIRTUAL_NAME__"
++ cli_run([
++ "--without-pip", "--no-periodic-update", "--activators", "bash,python",
++ "--prompt", prompt, str(dest),
++ ])
++ result = subprocess.run(
++ [bash, "--noprofile", "--norc", "-c",
++ '. "$1"; printf "%s\\n%s\\n" "$VIRTUAL_ENV" "$VIRTUAL_ENV_PROMPT"',
++ "activation-check", str(dest / "bin/activate")],
++ check=True, capture_output=True, text=True,
++ )
++ self.assertEqual(result.stdout.splitlines(), [str(dest), prompt])
++ code = (
++ "import json, os, runpy, sys; runpy.run_path(sys.argv[1]); "
++ "print(json.dumps([os.environ['VIRTUAL_ENV'], os.environ['VIRTUAL_ENV_PROMPT']]))"
++ )
++ result = subprocess.run(
++ [sys.executable, "-c", code, str(dest / "bin/activate_this.py")],
++ check=True, capture_output=True, text=True, env=os.environ.copy(),
++ )
++ self.assertEqual(json.loads(result.stdout), [str(dest), prompt])
++
++
++if __name__ == "__main__":
++ unittest.main()
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=0ce089158cf60a8ab6abb452b6405538"
SRC_URI += "file://CVE-2026-22702.patch \
file://CVE-2024-53899.patch \
+ file://CVE-2026-113776.patch \
file://powershell-curly-quotes.patch \
"
SRC_URI[sha256sum] = "7bb554bbdfeaacc3349fa614ea5bff6ac300fc7c335e9facf3a3bcfc703f45be"