CVE-2026-113776: virtualenv activation scripts run code from a path that contains a placeholder name

Published Oct 20, 2026
·
Updated

Impact

ViaTemplateActivator.instantiatetemplate replaces the placeholders in an activation template one key at a time, each across the whole text. When a value that it already substituted and quoted contains the name of a later placeholder, the later pass rewrites that name inside the quoted literal. The inserted value brings its own quotes, which close the outer literal, and the rest of the path runs as code when a user activates the environment.

VIRTUALNAME holds the environment's directory name, so a destination such as AVIRTUALNAMEB/x'$(touch PWNED)'y is enough. In the default activate for bash, the VIRTUALENV line renders as:

sh VIRTUALENV='/tmp/t/A'x'"'"'$(touch PWNED)'"'"'y'B/x'"'"'$(touch PWNED)'"'"'y'

Sourcing that script runs touch PWNED. The same payload in a path without the placeholder name runs nothing. activate.fish runs the command the same way, and the reporter also showed Python code execution through activate.xsh and bin/activatethis.py. In activate.csh, a directory named after a prompt display placeholder, such as VIRTUALPROMPTDISPLAYTCSH, breaks the script with Unmatched '''.

No change to quote() can stop this, because the rewrite happens after quote() ran; it defeats shlex.quote and repr() alike.

An attacker needs to influence the destination path or --prompt: a CI job or wrapper tool that builds the path from a branch or project name, or a directory in a cloned repository or unpacked archive.

The bug affects versions 20.26.6 through 21.14.1. Version 20.26.6 first quoted template values (#2768) and introduced the per-key loop.

Patches

Fixed in 21.14.2. Activation scripts now keep a placeholder name in the environment's path or prompt as plain text, and activating the example above runs nothing. Fix: https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74

Workarounds

Do not create an environment whose path or --prompt contains a placeholder name such as VIRTUALNAME, VIRTUALENV or VIRTUALPROMPT, and inspect the generated activation script before you source one you did not create.

Credits

Kevin Stubbings (@Kwstubbs) of GitHub Security Lab reported this issue.

Other sources

virtualenv is a tool for creating isolated virtual python environments. From 20.26.6 until 21.14.2, ViaTemplateActivator.instantiatetemplate() replaces placeholders one key at a time across the complete activation template, so trigger names such as VIRTUALNAME, VIRTUALENV, or VIRTUALPROMPT inside an already substituted and quoted environment path or prompt can be replaced during a later pass. The later value's quoting can close the earlier literal and execute the remaining path when a user activates the environment through bash, fish, xonsh, or activatethis.py. The distinct csh prompt-display token VIRTUALPROMPTDISPLAYTCSH can instead break the generated script without establishing command execution. The attacker must influence the destination path or --prompt, and a value without a relevant placeholder name does not trigger this mechanism. This issue is fixed in version 21.14.2.

— Ubuntu

Affected Software

17 affected componentsFixes available
pypi/virtualenv>=20.26.6<21.14.2
pip/virtualenv>=20.26.6<=21.14.1
21.14.2
bitnami/virtualenv>=20.26.6<21.14.2
21.14.2
debian/python-virtualenv*
debian/python-virtualenv*
debian/python-virtualenv*
pip/virtualenv>=20.26.6<21.14.2
21.14.2
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
debian/python-virtualenv<=20.17.1+ds-1, <=20.31.2+ds-1+deb13u1, <=21.5.1+ds-1
21.15.6+ds-2
virtualenv virtualenv>=20.26.6<21.14.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/virtualenv to a version that resolves this vulnerability.

    Fixed in 21.14.2
  2. Upgrade

    Upgrade bitnami/virtualenv to a version that resolves this vulnerability.

    Fixed in 21.14.2
  3. Upgrade

    Upgrade debian/python-virtualenv to a version that resolves this vulnerability.

    Fixed in 21.15.6+ds-2
  4. Upgrade

    Upgrade virtualenv to a version that resolves this vulnerability.

    Fixed in 21.14.2
  5. Compensating control

    Do not create an environment whose path or --prompt contains placeholder names such as __VIRTUAL_NAME__, __VIRTUAL_ENV__, or __VIRTUAL_PROMPT__.

  6. Compensating control

    Inspect generated activation scripts before sourcing any script you did not create.

Event History

Oct 20, 2026
CVE Published
via Ubuntu·12:00 AM
Data Sourced
via Ubuntu·12:00 AM
RemedyDescriptionSeverityAffected Software
CVE Published
via MITRE·10:03 PM
Data Sourced
via MITRE·10:03 PM
DescriptionSeverityWeakness
Advisory Published
via OSV·10:19 PM
Data Sourced
via NVD·10:19 PM
DescriptionSeverityWeakness
Oct 21, 2026
Advisory Published
via GitHub·04:39 PM
Data Sourced
via GitHub·04:39 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software
Nov 17, 2026
Data Sourced
via NVD·03:23 PM
RemedyAffected Software

Frequently Asked Questions

1

Which activation methods are susceptible to command execution?

Command execution can occur when the environment is activated through bash, fish, xonsh, or activate_this.py. The csh-specific __VIRTUAL_PROMPT_DISPLAY_TCSH__ token may break the generated script instead, without establishing command execution.

2

What must an attacker control to exploit this issue?

The attacker must be able to influence the virtual environment destination path or the value supplied through --prompt. The controlled value must contain a relevant placeholder name, such as __VIRTUAL_NAME__, __VIRTUAL_ENV__, or __VIRTUAL_PROMPT__; values without one do not trigger this mechanism.

3

Are all affected virtualenv installations exploitable by default?

No. Exploitation depends on attacker influence over the destination path or --prompt and on that value containing a relevant placeholder token. User interaction is also required because a user must activate the generated environment.

4

What version resolves the issue?

Upgrade virtualenv to version 21.14.2, which fixes the placeholder replacement behavior.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203