Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessPlant crafted venv or Tcl/Tk path
-
DeliveryVictim sources activate script
-
ExploitSurplus quotes terminate quoted context
-
ExecutionShell metacharacters parsed as commands
-
ImpactCode execution as sourcing user
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization OS command sanitization, avoid shell exec
MITRE ATT&CK
2 techniques across 1 tactic: Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Requires an attacker to control the virtual environment's filesystem path (bash/zsh path) or the interpreter's Tcl/Tk library paths (fish path) with embedded shell metacharacters, AND the victim to source the generated activation script (UI:R). For the bash/zsh vector, there is an additional precondition: the environment must have been relocated such that its recorded directory is absent, forcing the fallback that reaches the vulnerable __VIRTUAL_ENV__ echo. Limiting factors: local access vector (AV:L), mandatory user interaction (sourcing), the specific relocation/absent-directory state for bash/zsh, and shell-specific paths (bash, zsh, or fish activators). Affected only in virtualenv prior to 21.7.13; fixed in 21.7.13. |
| Impact | This is a genuine code-execution flaw (CWE-78 OS command injection) confirmed by the PyPA vendor advisory GHSA-p58f-9548-mpm2 and fixed in virtualenv 21.7.13 (PR #3252, commit 4d5a105). The provided CVSS 3.1 vector CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H (7.8, HIGH) is internally consistent with the description: exploitation is LOCAL (AV:L) and requires the victim to source the activation script (UI:R), yielding full C/I/A impact as arbitrary shell commands run with the sourcing user's privileges. No EPSS score, KEV listing, or public exploit was provided, so exploitation status is 'no public exploit identified at time of analysis' - though the patch's regression tests contain concrete injection payloads (command substitution, backticks, statement separators) that effectively function as a proof-of-concept methodology. Despite the widespread deployment of virtualenv, real-world risk is tempered by the specific and somewhat unusual preconditions (attacker-controlled venv path or Tcl/Tk library path, plus a relocated environment whose recorded directory is absent for the bash/zsh path), making this a real-but-conditional priority rather than a mass-exploitable network vulnerability. No conflicting signals were found: the CVSS local vector matches the description of code execution on sourcing. |
| Exploit ScenarioDerived | An attacker who can influence the filesystem path of a Python virtual environment (e.g., a maliciously named directory in a shared build/CI system, a downloaded/relocated environment, or a crafted Tcl/Tk library path) embeds shell metacharacters that survive the flawed escaping in the generated activate scripts. When a victim later sources the activation script - and, for bash/zsh, the environment has been relocated so its recorded directory is absent - the surplus quotes break out of the data-only quoted run and the metacharacters execute as commands. The fix commit ships regression tests with working payloads (e.g. x'$(id > PWNED)'y), demonstrating the technique. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Sep 29, 2026
Command injection in the bash, zsh, and fish activation scripts generated by virtualenv releases prior to 21.7.13 lets a crafted virtual environment path or interpreter Tcl/Tk library path execute arbitrary commands with the privileges of any user who sources the activate script. The root cause is double quoting: values already escaped by shlex.quote are embedded inside an additional quoted context, so the surplus quotes terminate the data-only quoted run and leave shell metacharacters parsed as commands - reaching __VIRTUAL_ENV__ in bash/zsh when a relocated environment's recorded directory is absent, and __TCL_LIBRARY__/__TK_LIBRARY__ in fish. Exploitation requires attacker control of the affected path string plus the victim sourcing the script (CVSS 3.1 score 7.8, AV:L/AC:L/PR:N/UI:R, CWE-78 OS command injection); no public exploit identified at time of analysis, and the flaw is fixed in virtualenv 21.7.13 per PyPA advisory GHSA-p58f-9548-mpm2.
RemediationAI
Vendor-released patch: 21.7.13. Upgrade the virtualenv package to 21.7.13 or later (for example python -m pip install --upgrade 'virtualenv>=21.7.13') and then regenerate the activation scripts, because the vulnerable code is baked into the emitted activate/activate.fish files - simply upgrading the package does not rewrite scripts already present in existing environments; recreate affected environments or re-run the activator generation for them. Reference the advisory at https://github.com/pypa/virtualenv/security/advisories/GHSA-p58f-9548-mpm2 and the fix at https://github.com/pypa/virtualenv/pull/3252 if a version pin must be justified internally. If upgrading immediately is not possible, the most practical compensating controls are: avoid sourcing activation scripts from environments whose filesystem path contains quotes, $, backticks, semicolons, or parentheses, and avoid relocating an environment into such a path (this blocks the bash/zsh vector but does nothing for the fish Tcl/Tk vector); for fish users, ensure the interpreter's reported Tcl/Tk library directories contain no shell metacharacters, or patched activation scripts are used; alternatively bypass sourcing entirely by exporting the required variables manually (export VIRTUAL_ENV=/path/to/env and prepend $VIRTUAL_ENV/bin to PATH), whose trade-off is that deactivate and prompt handling must be managed by hand. Treat virtual environment directories with shell metacharacters in their names as untrusted input until the generated scripts have been regenerated with 21.7.13.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
virtualenv generates shell activation scripts (activate for bash/zsh, activate.fish for fish) that set VIRTUAL_ENV, PATH, and - where the interpreter reports them - TCL_LIBRARY and TK_LIBRARY. The vulnerable code path passes values through Python's shlex.quote, which is designed to render an arbitrary string safe for shell parsing, but then places the already-quoted result inside a second layer of single quotes (e.g. the emitted line set -gx TCL_LIBRARY '__TCL_LIBRARY__' for fish, or the diagnostic echo "Virtual environment directory __VIRTUAL_ENV__ does not exist!" in bash/zsh). Because the escaped content can contain single quotes, the extra wrapper is broken out of and the remainder of the attacker-controlled string is evaluated as shell syntax: command substitution $(...), backticks, and statement separators (;) all become live. The bash/zsh path is only reached when a virtual environment has been moved or renamed so its recorded directory no longer exists, forcing the fallback error branch that interpolates __VIRTUAL_ENV__; the fish path is reached whenever the interpreter reports Tcl/Tk library directories containing metacharacters. The weakness class is CWE-78 (improper neutralization of special elements used in an OS command), and the affected distribution is captured by CPE cpe:2.3:a:pypa:virtualenv:*:*:*:*:*:*:*:* (all releases before 21.7.13). Note that the attacker does not need to compromise the interpreter or pip - control of the directory path or library string is sufficient because the generated script is regenerated/consumed locally and executed by the shell, not by Python.
Know when Virtualenv gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Local injection via attacker-controlled path executes when the victim sources the script (UI:R); no attacker privileges needed (PR:N) and code execution yields full C/I/A.
Primary rating from Vendor (GitHub_M).
CVSS VectorVendor: GitHub_M
Lifecycle Timeline
2DescriptionCVE.org
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.7.13, the generated activate (bash and zsh) and activate.fish scripts place values already escaped by shlex.quote inside an additional quoted context. In the bash and zsh script, a crafted virtual environment path reaches __VIRTUAL_ENV__ when a relocated environment's recorded directory is absent; in the fish script, crafted Tcl or Tk library paths reach __TCL_LIBRARY__ or __TK_LIBRARY__. The surplus quotes can terminate the data-only quoted run and leave shell metacharacters parsed as commands when a user sources the activation script, allowing code execution with that user's privileges. This issue is fixed in version 21.7.13.
Blast Radius
ecosystem impact- 1 pypi packages depend on virtualenv (1 direct, 0 indirect)
Ecosystem-wide dependent count for version 21.7.13.
Technical POC Analysis
CWE-78 (OS command injection) via double quoting of data in generated shell scripts.
Full technical POC analysis - root cause, step-by-step exploitation and patch breakdown - is part of the Pro and Business plans.
Executive ViewAI
The Python packaging tool virtualenv - embedded across virtually every development workstation and CI/CD pipeline that isolates application dependencies - generates bash, zsh, and fish activation scripts that can be abused to run arbitrary commands as the user who sources them. Any engineer, build runner, or automation account that activates a virtual environment whose path can be influenced by an attacker is exposed, putting source code, credentials, and build-pipeline access on that host at risk. The vendor has published a fixed release (21.7.13, PyPA advisory GHSA-p58f-9548-mpm2) and no public exploit has been identified at time of analysis, so exposure is containable but warrants prompt remediation given how deeply virtualenv is embedded in engineering workflows.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
OS command injection occurs when an application passes unsanitized user input directly into system shell commands.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
More in Virtualenv
View allvirtualenv before 20.26.6 allows command injection through the activation scripts for a virtual environment. Rated high
virtualenv versions prior to 21.7.12 cache and seed pip/setuptools wheels without verifying their bytes, so an attacker
Configuration injection in PyPA virtualenv before 21.7.11 lets a line boundary embedded in a prompt value inject extra k
Command injection in PyPA virtualenv before 21.7.12 allows an attacker who controls the environment's prompt value - via
Virtualenv versions up to 20.36.1 is affected by improper link resolution before file access (CVSS 4.5).
EUVD-2026-89461
GHSA-p58f-9548-mpm2
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB