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-102925 Overview
CVE-2026-102925 is a command injection vulnerability [CWE-78] in virtualenv, the widely used tool for creating isolated Python environments. Versions prior to 21.7.13 generate activate (bash and zsh) and activate.fish scripts that place values already escaped by shlex.quote inside an additional quoted context. The surplus quotes can terminate the data-only quoted run, allowing shell metacharacters embedded in a crafted path to be parsed as commands. When a user sources the activation script, attacker-controlled input executes with that user's privileges. The Python Packaging Authority (PyPA) fixed the issue in virtualenv21.7.13.
Critical Impact
A crafted virtual environment path or Tcl/Tk library path triggers arbitrary shell command execution as the user who sources the activation script.
Affected Products
- virtualenv versions prior to 21.7.13 (bash activate script)
- virtualenv versions prior to 21.7.13 (zsh activate script)
- virtualenv versions prior to 21.7.13 (activate.fish script)
Discovery Timeline
- 2026-09-29 - CVE-2026-102925 published to NVD
- 2026-09-29 - Last updated in NVD database
Technical Details for CVE-2026-102925
Vulnerability Analysis
The flaw resides in the template used to generate shell activation scripts. virtualenv substitutes runtime values into placeholders such as __VIRTUAL_ENV__, __TCL_LIBRARY__, and __TK_LIBRARY__. Those values are pre-escaped with shlex.quote, which wraps unsafe strings in single quotes. The templates then wrap the substituted value in another set of quotes. The outer quotes close the intended data context and expose the inner escape characters to the shell parser.
When a user runs source activate or source activate.fish against an environment whose recorded path contains shell metacharacters, the shell interprets those characters as commands. This turns a routine developer action into local code execution. The attack requires user interaction (sourcing the script) but no elevated privileges.
Root Cause
The root cause is double-quoting of data already escaped by shlex.quote. In the bash and zsh templates, __VIRTUAL_ENV__ is reached when a relocated environment's recorded directory is absent. In the fish template, __TCL_LIBRARY__ and __TK_LIBRARY__ follow the same unsafe pattern. Placing a properly quoted token inside another quoted string produces a broken, exploitable command line.
Attack Vector
An attacker crafts a directory path or Tcl/Tk library path containing shell metacharacters. The attacker delivers the environment through a shared filesystem, an archived project, a supply-chain package, or a relocated virtualenv. When a developer sources the activation script, the embedded commands run under the developer's account.
# Security patch in src/virtualenv/activation/bash/activate.sh
deactivate nondestructive
if [ ! -d __VIRTUAL_ENV__ ]; then
- echo "Virtual environment directory __VIRTUAL_ENV__ does not exist!" >&2
+ echo "Virtual environment directory" __VIRTUAL_ENV__ "does not exist!" >&2
CURRENT_PATH=$(realpath "${BASH_SOURCE[0]}")
CURRENT_DIR=$(dirname "${CURRENT_PATH}")
VIRTUAL_ENV="$(realpath "${CURRENT_DIR}/../")"
The patch removes the surrounding double quotes around __VIRTUAL_ENV__ in the echo statement, letting the pre-quoted substitution stand on its own as a distinct argument. Source: GitHub Commit 4d5a105.
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-102925
Indicators of Compromise
- Unexpected child processes spawned from interactive shells immediately after a source of an activate or activate.fish script.
- Virtual environment directories whose paths contain shell metacharacters such as $(, backticks, ;, or |.
- Modified pyvenv.cfg files whose recorded home path differs from the environment's actual on-disk location.
Detection Strategies
- Inventory installed virtualenv versions across developer workstations and CI runners; flag any version below 21.7.13.
- Scan project repositories and archived environments for directory names containing shell metacharacters.
- Monitor shell process trees for command execution originating from source or . invocations of activation scripts.
Monitoring Recommendations
- Log and alert on execve events where the parent is bash, zsh, or fish and the command line references activate or activate.fish.
- Track file writes to bin/activate, bin/activate.fish, and pyvenv.cfg that occur outside of package manager operations.
- Correlate developer endpoint telemetry with source control events to identify supply-chain delivery of tampered virtual environments.
How to Mitigate CVE-2026-102925
Immediate Actions Required
- Upgrade virtualenv to 21.7.13 or later on all workstations, build agents, and container images.
- Regenerate any activation scripts created by older virtualenv versions after upgrading.
- Audit shared or relocated virtual environments for suspicious path values before sourcing.
Patch Information
The fix is included in virtualenv21.7.13. See the GitHub Release Notes 21.7.13, the GitHub Security Advisory GHSA-p58f-9548-mpm2, and the GitHub Pull Request Discussion for full technical context. The corrective commit is documented in the GitHub Commit Detail.
Workarounds
- Avoid sourcing activation scripts from virtual environments received from untrusted sources until upgraded.
- Recreate virtual environments locally with a patched virtualenv instead of relocating existing environments.
- Restrict directory names for virtual environments to alphanumeric characters, dots, hyphens, and underscores.
# Upgrade virtualenv to the patched release
python -m pip install --upgrade 'virtualenv>=21.7.13'
# Verify the installed version
virtualenv --version
# Recreate an existing environment with the patched tool
rm -rf .venv
virtualenv .venv
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

