REDHAT-BUG-2545168: High severity pypi/virtualenv vulnerability
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, VIRTUALENVPROMPT, 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 Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
virtualenvto a version that resolves this vulnerability.Fixed in 21.7.12
Event History
Frequently Asked Questions
Who is exposed to this issue?
Windows users who activate a virtual environment generated by an affected virtualenv version are exposed when the environment’s prompt can be influenced by an attacker. The injected commands execute with the privileges of the user who runs activate.bat.
What attacker-controlled inputs are relevant?
An attacker must be able to influence the --prompt option, the VIRTUALENV_PROMPT environment variable, or the corresponding configuration value. A double quote in the prompt can terminate the intended cmd.exe variable assignment and allow subsequent command operators to be interpreted.
How can I determine whether an environment may be affected?
Check whether it was created with a virtualenv version earlier than 21.7.12 and whether its prompt value came from an untrusted or attacker-influenced source. Inspect the generated activate.bat for prompt content embedded in a cmd.exe set "VAR=value" assignment.
What should be done if immediate patching is not possible?
Do not activate Windows virtual environments whose prompt settings may be attacker-controlled. Restrict control of --prompt, VIRTUALENV_PROMPT, and the related configuration value to trusted users, and avoid prompt values containing double quotes.