Skip to main content

virtualenv CVE-2026-102925

| EUVDEUVD-2026-89461 HIGH
OS Command Injection (CWE-78)
2026-09-29 GitHub_M GHSA-p58f-9548-mpm2 PYSEC-2026-4013
7.8
CVSS 3.1 · Vendor: GitHub_M
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Plant crafted venv or Tcl/Tk path
  2. Delivery
    Victim sources activate script
  3. Exploit
    Surplus quotes terminate quoted context
  4. Execution
    Shell metacharacters parsed as commands
  5. Impact
    Code 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.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

virtualenv < 21.7.13

Affected Packages

pypi virtualenv fix: 21.7.13

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

Vendor (GitHub_M) PRIMARY 7.8 HIGH
AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
vuln.today AI 7.8 HIGH

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.

3.1 AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
4.0 AV:L/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Red Hat 7.8 HIGH

Primary rating from Vendor (GitHub_M).

CVSS VectorVendor: GitHub_M

Attack Vector
Local
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

Lifecycle Timeline

2
Patch available
Sep 29, 2026 - 22:19 EUVD
CVE Published
Sep 29, 2026 - 20:50 cve.org
HIGH 7.8

DescriptionCVE.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
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 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

Why It Matters

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.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.2%
Top 96% exploitable
Prevalence
High
PyPA virtualenv is a core, extremely widely used Python environment tool
Threat Intel
1
1 sources
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA MSRC Vendor GitHub

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.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Scheduled
Exploitation
None
System Exposure· derived
Small
Automatable
No
Human Impact
High
Technical Impact
Total

Priority Score

39
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +39
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

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.

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy