CVE-2026-113725: virtualenv bash activate runs commands from an environment name with a backslash before $

Published Oct 20, 2026
·
Updated

Summary

The bash activate script escapes the environment name for only one of the two passes bash makes over PS1, so a backslash in the name undoes the escaping and a name containing \$(...) runs as commands in the user's shell each time bash draws the prompt.

Affected area

src/virtualenv/activation/bash/activate.sh, the block that prepends the environment name to PS1.

Attacker-controlled input

The environment name: the environment directory's name, or the --prompt or VIRTUALENVPROMPT value. An attacker needs to influence it, for example through a CI job or wrapper tool that passes a branch, project or job name through, or a directory in a cloned repository or unpacked archive. --prompt . takes the current directory's name.

Details

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 runs parameter expansion, command substitution and arithmetic expansion on the result. Since 21.13.0 the script escapes backslashes, dollar signs and backticks in the name, but only for the second pass, so the decode pass strips the escaping that a backslash in the name precedes. Releases before 21.13.0 do not escape the name at all. A bash running as root decodes \$ to #, so the payload shows the wrong text there but runs nothing. zsh does no decode pass and is not affected.

Proof of concept

console $ virtualenv --prompt 'a\$(touch PWNED)' env $ bash --norc --noprofile -c 'source env/bin/activate; printf "%s" "${PS1@P}"' $ ls PWNED PWNED

Impact

Arbitrary command execution in the shell of a user who sources the activate script of an environment whose name an attacker influenced, with that user's privileges, once per prompt draw.

Versions tested

21.14.6 with bash 5.2.15 on Debian bookworm, as an unprivileged user and as root.

Known mitigation

Set VIRTUALENVDISABLEPROMPT=1 before you source activate, which leaves PS1 alone, or run shopt -u promptvars if your prompt does not need expansion. Check the name of an environment you did not create before you source its activate.

Latest release

- [x] The problem reproduces on the latest virtualenv release.

21.14.6

Patches

Fixed in 21.14.7. Under bash, activate now escapes backslashes, dollar signs and backticks for both passes, so the example above runs nothing and the prompt shows the name as given. zsh keeps the single escaping it needs. Fix: https://github.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932

Credits

Found while running the virtualenv test suite as root inside the Anthropic OSS Scanner build image.

Other sources

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.7, the bash activate script escapes the environment name for only one of the two passes bash makes over PS1, so a backslash in the name undoes the escaping and a name containing \$(...) runs as commands in the user's shell each time bash draws the prompt. This issue is fixed in version 21.14.7.

— Ubuntu

Affected Software

17 affected componentsFixes available
pypi/virtualenv<21.14.7
pip/virtualenv<=21.14.6
21.14.7
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<21.14.7
bitnami/virtualenv<21.14.7
21.14.7
pip/virtualenv<21.14.7
21.14.7
debian/python-virtualenv*
debian/python-virtualenv*
debian/python-virtualenv*

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.7
  2. Upgrade

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

    Fixed in 21.14.7
  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.7
  5. Configuration

    Set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing the activate script to leave PS1 unchanged.

    virtualenv bash activate VIRTUAL_ENV_DISABLE_PROMPT = 1

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·07:56 PM
Data Sourced
via MITRE·07:56 PM
DescriptionSeverityWeakness
Advisory Published
via OSV·08:17 PM
Data Sourced
via NVD·08:17 PM
DescriptionSeverityWeakness
Oct 21, 2026
Advisory Published
via GitHub·04:49 PM
Data Sourced
via GitHub·04:49 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software
Nov 17, 2026
Data Sourced
via NVD·03:46 PM
RemedyAffected Software

Frequently Asked Questions

1

Which environments are affected?

The issue affects virtualenv versions before 21.14.7 when the Bash activation script is used. The vulnerable behavior is in the handling of the environment name in the shell prompt.

2

What is required for command execution to occur?

The environment name must contain a backslash before a command-substitution sequence such as \$(...). A user must activate that environment in Bash; the vulnerability has a user-interaction requirement.

3

When are the embedded commands executed?

The commands run each time Bash draws the prompt after the affected environment has been activated. This can cause repeated command execution during an interactive shell session.

4

How can the issue be remediated?

Upgrade virtualenv to version 21.14.7, which fixes the Bash prompt escaping issue.

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