Summary
Caller-supplied prompt text in virtualenv can be interpreted as executable syntax in the Bash activation prompt. If an attacker can influence that text and a user later activates the environment and draws the prompt, commands may run with the user's permissions.
Affected context
The issue is in virtualenv's handling of caller-supplied prompt text used by the Bash activation prompt. It becomes a risk when an attacker can influence the prompt value and a user subsequently activates the environment and causes the prompt to be displayed. The description identifies versions before 21.14.9 as affected.
Exploit preconditions
- Attack surface: Prompt text supplied to virtualenv and used by a Bash activation script
- Required access: Ability to influence the value passed to virtualenv; the attacker need not necessarily have direct access to the user's shell
- Trigger point: The user activates the environment and draws the Bash prompt
- Why exploitation is possible: Caller-supplied text can be interpreted as executable shell syntax when the prompt is rendered
Why this happens
The underlying issue is command injection (CWE-78): externally influenced data is incorporated into a shell-interpreted prompt without adequate separation from executable syntax. As a result, displaying the prompt can cause text intended as data to be interpreted as shell commands.
Potential impact
- Arbitrary commands may run with the permissions of the user who activates the environment
- User files or other accessible resources could be modified or exposed
- The user's shell session could be disrupted or used to affect other accessible systems
General mitigation guidance
Defensive patterns include treating caller-supplied prompt text as untrusted data, avoiding shell-interpreted construction where possible, and safely escaping or encoding values before placing them in prompts. Prefer secure-by-default APIs that keep data separate from shell syntax, limit who can supply or alter prompt values, and run development tools with only the privileges they need.
How teams detect issues like this
Review code paths that interpolate caller-controlled values into shell activation scripts or prompt definitions. Static analysis and code review can flag shell-sensitive string construction and prompt values that are not safely quoted or escaped. Policy checks can restrict shell evaluation of externally influenced text, and automated review tools may help identify risky patterns.

