GitHub advisory · PyPI
virtualenv: Bash prompt values can change meaning under older compatibility modes
Description
Caller-supplied prompt text can become executable syntax in the bash activation prompt. An attacker must influence the value passed to virtualenv, and a user must subsequently activate the environment and draw the prompt.
Bash runs with compatibility level 4.2 and draws the environment prompt. Its replacement-string behavior differs from newer compatibility modes, leaving prompt text subject to a second interpretation. The report concerns POSIX activation. It does not establish exposure through unrelated activators.
The attacker controls prompt or destination data passed as a virtualenv argument. The user later sources the generated activation script.
The relevant 21.14.8 source is in bash prompt assembly.
bin/activate copies the prompt into PS1. A shell expands PS1 again when it draws a prompt, so the value must
survive both the assignment and that later expansion. The bash and zsh branches escape for their usual prompt rules.
Three other paths still interpret prompt data as commands: dash sourcing activate directly, a child dash inheriting an
exported PS1 from bash, and bash running at compatibility level 4.2 or lower. A value such as x$(touch MARKER)y then
runs touch on prompt display. Creating the environment does not run the payload.
The scanner's child-shell reproducer creates an environment with --prompt 'x$(touch MARKER)y', sources bin/activate
in interactive bash, and starts interactive sh (dash). Its control leaves PS1 unexported: neither shell creates
MARKER. With PS1 exported, bash displays the prompt without executing the value, but the child dash creates
MARKER; the reproducer ends in BUG. The report gives separate console reproductions for direct dash activation and
bash…
Manual fix · PyPI
pip install --upgrade "virtualenv>=21.14.9"Sources