Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-113726 Overview
CVE-2026-113726 is a command injection vulnerability in virtualenv, the Python tool used to create isolated virtual environments. The bash activate script that zsh also sources fails to escape prompt metacharacters when BASH_VERSION is unset. In zsh with PROMPT_SUBST enabled, an attacker-controlled environment directory, --prompt, or VIRTUALENV_PROMPT value can trigger command, parameter, or arithmetic expansion each time the shell prompt is redrawn. Versions prior to 21.13.0 do not escape at all, and versions 21.13.0 through 21.14.3 only escape under BASH_VERSION. The issue is resolved in version 21.14.4.
Critical Impact
Attacker-influenced virtual environment names can execute arbitrary commands in a user's zsh session on every prompt redraw after activation.
Affected Products
- virtualenv versions prior to 21.13.0 (no escaping of prompt metacharacters)
- virtualenv versions 21.13.0 through 21.14.3 (escaping gated on BASH_VERSION only)
- Users of zsh with PROMPT_SUBST enabled who source the bash activate script
Discovery Timeline
- 2026-10-20 - CVE-2026-113726 published to the National Vulnerability Database (NVD)
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-113726
Vulnerability Analysis
The vulnerability is a shell command injection [CWE-78] in the bash activate script shipped by virtualenv. When a user runs source bin/activate under zsh, the script prepends the virtual environment prompt string to PS1. If PROMPT_SUBST is set in zsh, the prompt string is re-expanded on every redraw. Expansion syntax inside the prompt therefore executes as shell code under the user's identity.
Exploitation requires local user interaction. A victim must activate an attacker-supplied virtual environment, or activate one whose directory name, --prompt argument, or VIRTUALENV_PROMPT value was influenced by an attacker. Once activated, commands run each time the prompt is drawn, which happens frequently during interactive use.
Root Cause
The activate script guards its escaping logic with a check for BASH_VERSION. Under zsh, this variable is unset, so backslashes, dollar signs, and backticks are passed to PS1 unescaped. The script also failed to escape % sequences that zsh interprets as prompt escapes. Combined with PROMPT_SUBST, the raw prompt string is treated as executable expansion syntax.
Attack Vector
An attacker who can control the environment directory name, the value passed to --prompt, or the VIRTUALENV_PROMPT variable can embed $(...), backtick, or arithmetic expansion payloads. These execute silently inside the victim's zsh session after activation. Supply-chain tooling that creates virtual environments from untrusted project metadata is a realistic delivery path.
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1-}"
_VIRTUAL_PROMPT="${VIRTUAL_ENV_PROMPT}"
- # bash re-expands backslashes, dollar signs and backticks in PS1 on every redraw; the guard keeps the
- # bash-only substitution away from POSIX shells such as dash, which reject it with "Bad substitution"
- if [ -n "${BASH_VERSION-}" ]; then
+ # bash, and zsh under PROMPT_SUBST, re-expand backslashes, dollar signs and backticks in PS1 on every redraw;
+ # zsh gets the escaping even without the option, since a user can set it after activation. The guards keep
+ # the substitution away from POSIX shells such as dash, which reject it with "Bad substitution"
+ if [ -n "${BASH_VERSION-}${ZSH_VERSION-}" ]; then
_VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\\/\\\\}"
_VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\$/\\\$}"
_VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\`/\\\`}"
fi
+ # zsh expands % sequences in PS1 as prompt escapes
+ if [ -n "${ZSH_VERSION-}" ]; then
+ _VIRTUAL_PROMPT="${_VIRTUAL_PROMPT//\%/%%}"
+ fi
PS1="(${_VIRTUAL_PROMPT}) ${PS1-}"
unset _VIRTUAL_PROMPT
fi
Source: pypa/virtualenv commit 5b91536
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-113726
Indicators of Compromise
- Virtual environment directory names containing shell expansion syntax such as $(...), backticks, or % sequences.
- VIRTUAL_ENV_PROMPT values that include command or parameter expansion metacharacters.
- Unexpected child processes spawned by zsh immediately after sourcing an activate script.
Detection Strategies
- Inventory installed virtualenv versions across developer workstations and CI runners; flag any below 21.14.4.
- Monitor process creation events where zsh is the parent and the triggering command correlates with prompt redraws rather than user input.
- Audit project repositories, lockfiles, and automation that produce virtual environments from externally sourced names or metadata.
Monitoring Recommendations
- Collect shell command execution telemetry from developer endpoints and ingest into a centralized analytics platform for behavioral review.
- Alert on activation of virtual environments whose paths include unusual characters such as $, `, or %.
- Review shell history for anomalous commands executed in sessions that recently sourced an activate script.
How to Mitigate CVE-2026-113726
Immediate Actions Required
- Upgrade virtualenv to version 21.14.4 or later on all workstations, build servers, and container images.
- Re-create any existing virtual environments after upgrading so the patched activate script is written to disk.
- Audit shared tooling and templates for virtual environment names derived from untrusted input.
Patch Information
The fix is published in virtualenv 21.14.4. The patched src/virtualenv/activation/bash/activate.sh applies escaping when either BASH_VERSION or ZSH_VERSION is set, and additionally doubles % characters under zsh to neutralize prompt escapes. See the GitHub Security Advisory GHSA-5vjq-rrrf-7h2q and the virtualenv 21.14.4 release notes.
Workarounds
- Set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing activate to skip the vulnerable PS1 modification.
- Disable PROMPT_SUBST in zsh by running setopt no_prompt_subst for interactive sessions where upgrading is not yet possible.
- Avoid activating virtual environments whose directory names, --prompt arguments, or VIRTUALENV_PROMPT values originate from untrusted sources.
# Upgrade virtualenv and verify the installed version
python -m pip install --upgrade 'virtualenv>=21.14.4'
python -m virtualenv --version
# Temporary mitigation: disable prompt modification before activation
export VIRTUAL_ENV_DISABLE_PROMPT=1
source ./venv/bin/activate
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

