7.3high
virtualenv: Command injection via --prompt in activate.bat (batch activator)
- Severity
- 7.3high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.21% (higher than 11% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-x78j-v8h9-3j2qBIT-VIRTUALENV-2026-102937PYSEC-2026-4014
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| pypa virtualenv | < 21.7.12 | CVE List |
| virtualenv (PyPI) | before 21.7.12 | GitHub Advisory Database, PyPA Advisory Database |
| virtualenv virtualenv | before 21.7.12 | NVD |
| virtualenv (Bitnami) | before 21.7.12 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 7.3high CVSS:4.0 | 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 |
| GitHub | high CVSS:4.0 | 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 |
| NVD | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| Bitnami Vulnerability Database | high rating |
Classification
SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.
What each source says
CVE List
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.
GitHub Advisory Database
BatchActivator.quote() returned its input unchanged, the only activator with no escaping at all. --prompt, the VIRTUALENV_PROMPT environment variable, and the config file all set the prompt, and activate.bat writes it straight into @set "VAR=value". A prompt containing a double quote closes that string early, and whatever follows runs as live cmd.exe syntax:
$ virtualenv --prompt 'x" & calc & "' venv
$ venv\Scripts\activate.bat
runs calc the moment someone activates the environment. Confirmed on a real Windows runner. Anyone who templates a prompt from untrusted input (a CI job using a branch name, a wrapper script deriving an environment name from user input) hands an attacker code execution in the shell of anyone who activates the resulting venv on Windows.
Fixed in 21.7.12 by escaping the characters cmd.exe treats as live syntax inside this construct. Fix: https://github.com/pypa/virtualenv/pull/3250
PyPA Advisory Database
BatchActivator.quote() returned its input unchanged, the only activator with
no escaping at all. --prompt, the VIRTUALENV_PROMPT environment variable,
and the config file all set the prompt, and activate.bat writes it straight
into @set "VAR=value". A prompt containing a double quote closes that string
early, and whatever follows runs as live cmd.exe syntax. For example, a venv
created with --prompt 'x" & calc & "' runs calc the moment someone runs
activate.bat.
Anyone who templates a prompt from untrusted input (a CI job using a branch name, a wrapper script deriving an environment name from user input) hands an attacker code execution in the shell of anyone who activates the resulting venv on Windows.
Fixed in 21.7.12 by escaping the characters cmd.exe treats as live syntax inside this construct.
References
| https://github.com/pypa/virtualenv/security/advisories/GHSA-x78j-v8h9-3j2q | advisory, vendor-advisory, web | |
| https://github.com/pypa/virtualenv/pull/3250 | fix, issue-tracking, patch, web | |
| https://github.com/pypa/virtualenv/commit/d721ff140ce4afdc2a9b76751e4584e25d9fbea6 | fix, patch, web | |
| https://github.com/pypa/virtualenv/releases/tag/21.7.12 | article, release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-102937 | advisory, web | |
| https://github.com/pypa/advisory-database/tree/main/vulns/virtualenv/PYSEC-2026-4014.yaml | web | |
| https://github.com/pypa/virtualenv | package | |
| https://pypi.org/project/virtualenv | package, web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-102937 changed 2026-10-02 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-x78j-v8h9-3j2q changed 2026-10-06 | CC-BY-4.0 |
| NVD | CVE-2026-102937 changed 2026-11-19 | Public domain |
| PyPA Advisory Database | PYSEC-2026-4014 changed 2026-10-06 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-VIRTUALENV-2026-102937 changed 2026-11-27 | Apache-2.0 |