Skip to main content

virtualenv CVE-2026-102937

| EUVDEUVD-2026-89464 HIGH
OS Command Injection (CWE-78)
2026-09-29 GitHub_M GHSA-x78j-v8h9-3j2q PYSEC-2026-4014
7.3
CVSS 4.0 · Vendor: GitHub_M
View

Attack ChainAIDerived

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

  1. Access
    Plant malicious --prompt/VIRTUALENV_PROMPT/config value
  2. Delivery
    Victim generates virtualenv on Windows
  3. Exploit
    Quote closes set "VAR=value" assignment
  4. Execution
    Injected cmd.exe operators run on activate.bat
  5. Impact
    Arbitrary commands execute as activating 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 all of: virtualenv version prior to 21.7.12; the Windows platform, because the flaw is only in the cmd.exe activate.bat batch activator that inserts the prompt into a set "VAR=value" statement; attacker influence over the --prompt argument, the VIRTUALENV_PROMPT environment variable, or the corresponding prompt configuration value (the injection carrier is a double quote plus cmd.exe operators); and a victim who then generates and activates that environment. Limiting factors: local vector only, mandatory user interaction (running activate.bat), Windows-only, and the attacker must first get a hostile value into the prompt input - non-Windows activators and default/attacker-uncontrolled prompts are not affected.

Impact

This is a genuine but conditionally-gated command-injection flaw (CWE-78) in the ubiquitous PyPA virtualenv tool, specific to the Windows batch activator. The vendor CVSS 4.0 vector (AV:L/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H = 7.3) is internally consistent with the description: exploitation is local, requires a passive attack precondition (AT:P - the attacker must first get a malicious value into --prompt, VIRTUALENV_PROMPT, or the prompt config), and requires the victim to activate the generated environment (UI:P). The technical impact is severe (full C/I/A on the activating user) because arbitrary cmd.exe operators execute with the user's privileges, but the local vector plus mandatory user interaction plus attacker-influence precondition sharply limit real-world reach - this is not a remote, wormable bug. No EPSS score, no CISA KEV listing, and no public exploit code are present in the provided data, so exploitation status is: no public exploit identified at time of analysis. Net: a real, patch-worthy issue for Windows Python developers/CI, but a targeted/supply-chain-flavored risk rather than mass-exploitable - priority is moderate. The vendor CVSS scores it as HIGH; I concur that severity-when-triggered is high while likelihood is constrained.

Exploit ScenarioDerived

An attacker seeds a shared repository, template, or environment with a crafted prompt value (e.g. a malicious .cfg prompt setting or an exported VIRTUALENV_PROMPT) containing a double quote that closes the cmd.exe set assignment followed by executable operators. A Windows developer or CI job using virtualenv < 21.7.12 creates the environment and runs activate.bat, at which point the injected commands execute with that user's privileges. No public exploit code is identified, but the injection is straightforward given control of the prompt input.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.1% 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 PyPA virtualenv before 21.7.12 allows an attacker who controls the environment's prompt value - via the --prompt argument, the VIRTUALENV_PROMPT environment variable, or the equivalent configuration setting - to run arbitrary cmd.exe commands on Windows with the privileges of the user who activates the generated environment. The flaw is confined to the batch activator: BatchActivator.quote() returns the prompt text unchanged, so a supplied double quote closes the set "VAR=value" assignment in activate.bat and any following cmd.exe operators are executed as live syntax when the victim runs the script. Coverage is limited by a local attack vector, Windows-only exposure, and mandatory victim interaction (generating and then activating the environment); no public exploit was identified at time of analysis, and a vendor fix is available in 21.7.12.

RemediationAI

Vendor-released patch: upgrade to virtualenv 21.7.12 (https://github.com/pypa/virtualenv/releases/tag/21.7.12), which corresponds to PR #3250 and commit d721ff140ce4afdc2a9b76751e4584e25d9fbea6 and neutralizes the injection by replacing &, |, <, >, ^, !, and " with spaces, doubling %, and collapsing all recognized line-boundary characters. Where patching is not immediately possible, treat the prompt as untrusted input: never pass --prompt, VIRTUALENV_PROMPT, or a config-file prompt value derived from user, ticket, repository, or CI-supplied data, and restrict creation of new virtual environments to trusted callers - this removes the injection carrier entirely, since a default or developer-chosen prompt contains no double quote or cmd.exe operator. As a defense-in-depth check, inspect the set lines of any freshly generated activate.bat before running it on Windows and regenerate the environment with a sanitized prompt if a quote or operator appears. Note the patched behavior's side effect: if the environment destination path, Tcl library path, or Tk library path contains &, virtualenv 21.7.12 will log a warning and skip generating batch activation scripts for that environment, so affected users must rename the directory or activate through an alternative mechanism (for example the generated PowerShell activate.ps1 or direct interpreter invocation) rather than expecting activate.bat to exist. Users who already generated environments with an attacker-influenced prompt should delete and recreate them rather than invoking the existing activate.bat. Advisory: https://github.com/pypa/virtualenv/security/advisories/GHSA-x78j-v8h9-3j2q.

Affected VersionsENISA

virtualenv < 21.7.12

Affected Packages

pypi virtualenv fix: 21.7.12

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

The affected code is virtualenv's batch activation template generator (src/virtualenv/activation/batch/__init__.py). On Windows, activate.bat is generated from a template that embeds the environment prompt using cmd.exe's quoted assignment form @set "VAR=value". Batch has no escape sequence for a literal double quote inside that construct: the quote always terminates the quoted string, and whatever follows on the same physical line is then parsed by cmd.exe as a fresh statement. The pre-fix BatchActivator.quote() returned the prompt text verbatim, so a value containing " plus operators such as &, |, <, >, or ^ (and ! under delayed expansion) would break out of the assignment and execute. This is CWE-78 (Improper Neutralization of Special Elements used in an OS Command), reachable purely by influencing a prompt string that is later rendered into a Windows batch file. The public fix (PR #3250, commit d721ff1) replaces those cmd.exe metacharacters with spaces, doubles % so it stays a literal rather than triggering variable expansion inside the quotes, and funnels all line-boundary characters (\n, \r, \v, \f, FS/GS/RS, NEL, U+2028, U+2029) through a new shared helper collapse_line_boundaries so a value can never be read back as an extra config line or script statement - the same helper is now also applied to pyvenv.cfg keys and values. Because & cannot be safely neutralized in a real Windows path without pointing activation at a nonexistent directory, the patched code refuses to emit batch activation scripts at all when a path replacement value contains &, logging a warning instead.

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.3 HIGH
CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
vuln.today AI 7.8 HIGH

Local Windows activation with required user interaction (UI:R); no privileges needed to plant the prompt value (PR:N); injected commands run as the activating user giving full C/I/A and no scope change.

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:P/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
Attack Requirements
Present
Privileges Required
None
User Interaction
Passive
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

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

DescriptionCVE.org

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.7.12, BatchActivator.quote() returns prompt text unchanged before activate.bat inserts it into a cmd.exe set "VAR=value" statement. An attacker who influences --prompt, VIRTUALENV_PROMPT, or the corresponding configuration value can include a double quote that closes the assignment and leaves following cmd.exe operators as executable syntax. When a user activates the generated Windows environment, the injected commands run with that user's privileges. This issue is fixed in version 21.7.12.

Technical POC Analysis

CWE-78 (OS Command Injection).

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

A command-injection vulnerability in PyPA virtualenv (versions before 21.7.12) allows an attacker who controls a project's environment prompt setting to execute arbitrary commands on Windows with the privileges of the developer who activates the generated environment. Because virtualenv underpins a large share of Python development, build, and CI workflows, a single poisoned prompt value can convert routine environment activation on a Windows host into user-level code execution. Exposure is constrained to Windows endpoints and requires the victim to generate and then activate the environment, and no public exploit has been identified at time of analysis, but leadership should treat this as an urgent developer-workstation and build-pipeline hardening item.

Business Impact: Medium
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.1%
Top 97% exploitable
Prevalence
Ubiquitous
virtualenv is a foundational, near-universal Python environment tool
Threat Intel
1
1 sources
Data Quality
6 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.1%
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
Defer
Exploitation
None
System Exposure· derived
Small
Automatable
Yes
Human Impact
Medium
Technical Impact
Total

Priority Score

36
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +36
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.

Vendor StatusVendor

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