CVE-2026-113726: virtualenv activate runs commands from the environment name in zsh with PROMPT_SUBST

Published Oct 20, 2026
·
Updated

Impact

zsh users activate an environment with the bash activate script, which puts the environment name into PS1. Since 21.13.0 the script escapes backslashes, dollar signs and backticks in that name, but only when BASHVERSION is set, so zsh gets the raw value. With the PROMPTSUBST option set, zsh runs parameter expansion, command substitution and arithmetic expansion on PS1 each time it draws the prompt. A name that contains $(...), backticks or ${...} then runs as commands in the user's shell, once per prompt.

The name comes from the environment directory, or from --prompt or VIRTUALENVPROMPT. After you create an environment with:

console $ virtualenv 'x$(touch PWNED)y'

source 'x$(touch PWNED)y/bin/activate' in a zsh session with PROMPTSUBST set creates PWNED, and the prompt shows (xy). Passing that value as --prompt to an environment with a plain name has the same effect. Without PROMPTSUBST, zsh shows the name as text and runs nothing. bash runs nothing either.

A plain zsh starts with PROMPTSUBST off. oh-my-zsh users have it on: oh-my-zsh loads lib/theme-and-appearance.zsh at startup, and that file sets it. An attacker needs to influence the environment path or prompt: 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.

zsh also reads % in PS1 as a prompt escape, so a name with %n showed the user name in place of those characters, though without running commands.

The bug is in releases up to and including 21.14.3. The payload runs on 20.26.6 and 21.14.3, and the reporter confirmed 21.9.1.

Patches

Fixed in 21.14.4. Under zsh, activate now escapes the name the way it does under bash and doubles %, so the example above runs nothing and the prompt shows the name as given. zsh gets the escaping even when PROMPTSUBST is off, because a user can set the option after activation; a name with a backslash, dollar sign or backtick then shows the added backslashes. Fix: https://github.com/pypa/virtualenv/commit/5b915367da82bd024b2a0d28d2f98007034b4aa2

Workarounds

Set VIRTUALENVDISABLEPROMPT=1 before you source activate, which leaves PS1 alone, or run unsetopt promptsubst if your prompt does not need it. Check the name of an environment you did not create before you source its activate.

Credits

Kaya Emre Arikan (@kemrec) reported this issue.

Other sources

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.13.0, the bash activate script that zsh also sources leaves the environment name unescaped; from 21.13.0 until 21.14.4, it escapes backslashes, dollar signs, and backticks only when BASHVERSION is set, so zsh receives the raw value. The script assigns that value to PS1. In zsh with PROMPTSUBST, an attacker-influenced environment directory, --prompt, or VIRTUALENVPROMPT value containing command, parameter, or arithmetic expansion syntax can therefore execute commands in the user's shell each time the prompt is drawn. A percent sign is separately interpreted as a zsh prompt escape but does not by itself execute commands. Plain zsh with PROMPTSUBST disabled and bash are not affected by this mechanism. This issue is fixed in version 21.14.4.

— Ubuntu

Affected Software

17 affected componentsFixes available
pypi/virtualenv<21.14.4
pip/virtualenv<=21.14.3
21.14.4
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.4
bitnami/virtualenv<21.14.4
21.14.4
pip/virtualenv<21.14.4
21.14.4
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.4
  2. Upgrade

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

    Fixed in 21.14.4
  3. Upgrade

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

    Fixed in 21.15.6+ds-2
  4. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 21.14.4
  5. Configuration

    Run `unsetopt prompt_subst` if your prompt does not need PROMPT_SUBST.

    zsh PROMPT_SUBST = off
  6. Configuration

    Set `VIRTUAL_ENV_DISABLE_PROMPT=1` before sourcing `activate` to leave `PS1` alone.

    virtualenv 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·10:05 PM
Data Sourced
via MITRE·10:05 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:46 PM
Data Sourced
via GitHub·04:46 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software
Nov 17, 2026
Data Sourced
via NVD·03:27 PM
RemedyAffected Software

Frequently Asked Questions

1

Who is exposed to command execution through this issue?

Users who source a vulnerable virtualenv activation script in zsh with the PROMPT_SUBST option enabled are exposed when the environment directory name, --prompt value, or VIRTUALENV_PROMPT value is attacker-influenced. Bash and zsh with PROMPT_SUBST disabled are not affected by this mechanism.

2

What does an attacker need to control?

The attacker needs to influence the virtual environment directory name, the value passed through --prompt, or VIRTUALENV_PROMPT, and include command, parameter, or arithmetic expansion syntax. The payload executes when the activated shell draws its prompt.

3

Are percent signs alone sufficient to execute commands?

No. A percent sign is interpreted as a zsh prompt escape, but it does not itself cause command execution.

4

Which versions need remediation?

Versions before 21.13.0 are affected, as are versions from 21.13.0 through 21.14.4 under the described zsh configuration. The issue is fixed in 21.14.4.

5

What can be done if upgrading is not immediately possible?

Avoid sourcing affected activation scripts in zsh while PROMPT_SUBST is enabled, especially for environments or prompt values influenced by untrusted sources. Use bash or zsh with PROMPT_SUBST disabled for activation until the fixed version is deployed.

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