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.
OpenCVE Enrichment
Github GHSA