Description
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.
Published: 2026-09-29
Score: 7.3 High
EPSS: < 1% Very Low
KEV: No
Impact: Command Injection leading to arbitrary command execution
Action: Immediate Patch
AI Analysis

Impact

Virtualenv can generate a Windows activate.bat file that assigns the supplied prompt text to an environment variable in a cmd.exe set command. The library incorrectly preserves the value of the --prompt option before insertion, allowing an attacker who can set the --prompt argument, the VIRTUALENV_PROMPT environment variable, or the configuration value to inject a double quote that terminates the assignment. The remaining text is interpreted as additional cmd.exe operators, enabling arbitrary command execution when the batch activator is run. The flaw is classified as OS Command Injection (CWE-78) and permits execution of arbitrary commands with the privileges of the user who activates the environment.

Affected Systems

Affected vendor is pypa, product is the virtualenv tool used to create isolated Python environments. The vulnerability exists in all releases prior to virtualenv 21.7.12. The fix is applied in the 21.7.12 release and later.

Risk and Exploitability

The CVSS score of 7.3 indicates a high impact, although the EPSS score is not available and the vulnerability is not listed in CISA’s KEV catalog, suggesting a lower likelihood of widespread exploitation. The attack requires local access and the ability to influence the prompt value used when creating or activating a virtual environment. An attacker who can modify the --prompt option, the VIRTUALENV_PROMPT environment variable or the corresponding configuration file can insert command syntax that will run immediately when a user activates the environment, allowing execution of arbitrary commands with that user's privileges. Because the exploit is confined to the local user account, the risk is moderate to high for individual users or processes that trust the activated environment.

Generated by OpenCVE AI on September 30, 2026 at 10:50 UTC.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Update virtualenv to version 21.7.12 or later to apply the vendor patch.
  • If an update is not immediately possible, avoid setting a custom prompt by using --prompt='venv' or setting the VIRTUALENV_PROMPT variable to a harmless string.
  • Restrict write permissions on virtualenv configuration files and environment variables to prevent untrusted users from modifying prompt values.
  • Ensure that only trusted users can create or modify virtual environments that are subsequently activated on the system.

Generated by OpenCVE AI on September 30, 2026 at 10:50 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-x78j-v8h9-3j2q virtualenv: Command injection via --prompt in activate.bat (batch activator)
History

Sat, 03 Oct 2026 00:30:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'}

threat_severity

Important


Fri, 02 Oct 2026 13:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Wed, 30 Sep 2026 21:00:00 +0000

Type Values Removed Values Added
First Time appeared Pypa
Pypa virtualenv
Python
Python virtualenv
Vendors & Products Pypa
Pypa virtualenv
Python
Python virtualenv

Tue, 29 Sep 2026 21:00:00 +0000

Type Values Removed Values Added
Description 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.
Title virtualenv: Command injection via --prompt in activate.bat (batch activator)
Weaknesses CWE-78
References
Metrics cvssV4_0

{'score': 7.3, 'vector': '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'}


Subscriptions

Pypa Virtualenv
Python Virtualenv
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-10-02T12:28:15.446Z

Reserved: 2026-09-29T20:24:43.340Z

Link: CVE-2026-102937

cve-icon Vulnrichment

Updated: 2026-10-02T12:28:08.381Z

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-09-29T21:17:18.893

Modified: 2026-10-02T13:17:35.440

Link: CVE-2026-102937

cve-icon Redhat

Severity : Important

Publid Date: 2026-09-29T20:56:13Z

Links: CVE-2026-102937 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-09-30T20:35:31Z

Weaknesses
  • CWE-78

    Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')