Skip to content

Bash activator leaves the --prompt value unescaped in PS1 when promptvars is off, so prompt expansion later executes it #23376

Backlog

Description

@musicinmybrain

Summary

CVE-2026-115586 was recently disclosed for virtualenv, corresponding to GHSA-cx6f-vjhg-g3cc.

The bash activator puts the caller-supplied prompt value into PS1 unescaped whenever promptvars is off at activation time, and assumes prompt expansion can never run afterwards. promptvars and posix mode are runtime shell state, not a property of the activation moment: re-enabling prompt expansion in the same shell (shopt -s promptvars, set -o posix) or starting an interactive child bash that inherits the exported PS1 makes bash expand the stored value and run the command substitution in it. An attacker who controls the prompt value gets command execution as the user who sources bin/activate.

Since uv uses activation scripts derived from virtualenv, I tried the proof of concept from GHSA-cx6f-vjhg-g3cc and was able to reproduce it, indicating that uv is affected by the same issue:

$ uv venv --prompt 'x$(id > /tmp/ve-pwn)y' /tmp/venv-demo
$ cat > /tmp/rc <<'EOF'                       
shopt -u promptvars
. /tmp/venv-demo/bin/activate
shopt -s promptvars
EOF
$ printf 'exit\n' | script -qec 'bash --noprofile --rcfile /tmp/rc -i' /dev/null
$ cat /tmp/ve-pwn
uid=1000(user) gid=1000(user) groups=1000(user) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

It’s my understanding from previous issues like #23059 and #23058 that that this would not be considered a vulnerability under uv’s attacker and threat models, because uv does not expect a hostile user to control the environment or parameters with which a virtual environment is created. I am therefore reporting this as a regular public bug.

Platform

Fedora 45 x86_64

Version

uv 0.13.7

Python version

Python 3.15.2

Activity

  1. added
    bug
    on Nov 24, 2026
  2. LiHuan02 commented on Nov 25, 2026

    @LiHuan02

    Hi, I would like to work on this. My plan is to escape the prompt value when it is written into the bash activator's PS1 assignment (mirroring the upstream virtualenv fix for GHSA-cx6f-vjhg-g3cc), so that re-enabling promptvars or inheriting the exported PS1 in a child shell cannot trigger command substitution. I will open a PR with the fix and a regression test; please let me know if you would prefer a different approach.

  3. added a commit that references this issue on Nov 25, 2026
    c6ba5a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions