{"id":"CVE-2026-113725","kind":"vulnerability","aliases":["CVE-2026-113725","GHSA-vxj4-q4g9-crj7"],"related":[],"title":"virtualenv bash activate runs commands from an environment name with a backslash before $","description":"### Summary\n\nThe bash `activate` script escapes the environment name for only one of the two passes bash makes over `PS1`, so a\nbackslash in the name undoes the escaping and a name containing `\\$(...)` runs as commands in the user's shell each\ntime bash draws the prompt.\n\n### Affected area\n\n`src/virtualenv/activation/bash/activate.sh`, the block that prepends the environment name to `PS1`.\n\n### Attacker-controlled input\n\nThe environment name: the environment directory's name, or the `--prompt` or `VIRTUALENV_PROMPT` value. An attacker\nneeds to influence it, for example through a CI job or wrapper tool that passes a branch, project or job name through,\nor a directory in a cloned repository or unpacked archive. `--prompt .` takes the current directory's name.\n\n### Details\n\nbash handles `PS1` in two passes each time it draws the prompt: it first decodes backslash prompt escapes, turning `\\\\`\ninto `\\` and `\\$` into `$` (or `#` for root), and then runs parameter expansion, command substitution and arithmetic\nexpansion on the result. Since 21.13.0 the script escapes backslashes, dollar signs and backticks in the name, but only\nfor the second pass, so the decode pass strips the escaping that a backslash in the name precedes. Releases before\n21.13.0 do not escape the name at all. A bash running as root decodes `\\$` to `#`, so the payload shows the wrong text\nthere but runs nothing. zsh does no decode pass and is not affected.\n\n### Proof of concept\n\n```console\n$ virtualenv --prompt 'a\\$(touch PWNED)' env\n$ bash --norc --noprofile -c 'source env/bin/activate; printf \"%s\" \"${PS1@P}\"'\n$ ls PWNED\nPWNED\n```\n\n### Impact\n\nArbitrary command execution in the shell of a user who sources the `activate` script of an environment whose name an\nattacker influenced, with that user's privileges, once per prompt draw.\n\n### Versions tested\n\n21.14.6 with bash 5.2.15 on Debian bookworm, as an unprivileged user and as root.\n\n### Known mitigation\n\nSet `VIRTUAL_ENV_DISABLE_PROMPT=1` before you source `activate`, which leaves `PS1` alone, or run `shopt -u promptvars`\nif your prompt does not need expansion. Check the name of an environment you did not create before you source its\n`activate`.\n\n### Latest release\n\n- [x] The problem reproduces on the latest virtualenv release.\n\n21.14.6\n\n### Patches\n\nFixed in 21.14.7. Under bash, `activate` now escapes backslashes, dollar signs and backticks for both passes, so the\nexample above runs nothing and the prompt shows the name as given. zsh keeps the single escaping it needs.\nFix: https://github.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932\n\n### Credits\n\nFound while running the virtualenv test suite as root inside the Anthropic OSS Scanner build image.","summary":"virtualenv's bash activate script fails to escape backslashes in the environment name before bash expands PS1, so a name containing \\$(...) runs attacker-chosen commands in the user's shell on every prompt draw. An attacker who controls an environment name (directory name, --prompt or VIRTUALENV_PROMPT, e.g. via CI or a cloned repo) gets command execution with the victim's privileges once the victim sources that environment's activate script.","severity":"high","cvss":7.800000190734863,"epss":0.001550000044517219,"exploited":false,"exploited_at":null,"products":[{"name":"virtualenv","fixed":["21.14.7"],"affected":"<= 21.14.6","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["bash","ci","cwe-116","cwe-78","developer-workstations","package","python","virtualenv"],"not_affected_if":["fixed-version-21.14.7-or-later","vendor-managed-environments-with-no-untrusted-names","zsh-only"],"how_to_check":"Run pip show virtualenv or python -m virtualenv --version and check whether it is 21.14.6 or earlier (affected <= 21.14.6).\nIn each environment, check whether bin/activate and bin/activate.sh were created by an affected version and whether any environment name contains a backslash followed by $.","fix":"Upgrade virtualenv to 21.14.7 or later.\nUntil upgraded, set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing activate, or run shopt -u promptvars.","status":"open","published_at":"2026-10-20T20:17:19+00:00","first_seen_at":"2026-10-23T19:11:32+00:00","triaged_at":"2026-10-23T19:52:51+00:00","updated_at":"2026-10-23T21:57:21+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-10-23T19:52:51Z","model":"claude-haiku-5-5","output":{"fix":"Upgrade virtualenv to 21.14.7 or later.\nUntil upgraded, set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing activate, or run shopt -u promptvars.","summary":"virtualenv's bash activate script fails to escape backslashes in the environment name before bash expands PS1, so a name containing \\$(...) runs attacker-chosen commands in the user's shell on every prompt draw. An attacker who controls an environment name (directory name, --prompt or VIRTUALENV_PROMPT, e.g. via CI or a cloned repo) gets command execution with the victim's privileges once the victim sources that environment's activate script.","category":"package","who_cares":["python","virtualenv","bash","ci","developer-workstations"],"confidence":0.85,"analyst_note":"","how_to_check":"Run pip show virtualenv or python -m virtualenv --version and check whether it is 21.14.6 or earlier (affected <= 21.14.6).\nIn each environment, check whether bin/activate and bin/activate.sh were created by an affected version and whether any environment name contains a backslash followed by $.\nunknown for any other check the sources do not describe.","needs_analyst":false,"not_affected_if":["zsh-only","fixed-version-21.14.7-or-later","vendor-managed-environments-with-no-untrusted-names"],"severity_if_unknown":"unknown"},"cost_usd":0.000546,"input_tokens":2994,"output_tokens":493,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-113725':15A,23A '-116':28B '-2026':14A,22A '-78':30B '/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932':504C '1':415C '21.13.0':268C,302C '21.14.6':394C,462C '21.14.7':466C '5.2.15':397C 'activ':3A,40B,107B,112C,373C,419C,450C,469C 'affect':156C,336C 'alon':423C 'anthrop':517C 'arbitrari':361C 'archiv':220C 'area':157C 'arithmet':262C 'attack':60B,73B,169C,188C,381C 'attacker-chosen':59B 'attacker-control':168C 'backslash':12A,45B,131C,244C,272C,295C,472C 'backtick':276C,476C 'bash':2A,25B,39B,51B,111C,125C,152C,229C,311C,347C,396C,468C 'block':160C 'bookworm':400C 'branch':205C 'build':520C 'c':350C 'check':436C 'chosen':61B 'ci':26B,87B,197C 'clone':90B,216C 'command':5A,62B,93B,144C,259C,362C 'concept':339C 'consol':340C 'contain':57B,141C 'control':75B,170C 'creat':445C 'credit':505C 'crj7':20A 'current':224C 'cve':13A,21A 'cwe':27B,29B 'debian':399C 'decod':243C,288C,315C,331C 'detail':228C 'develop':32B 'developer-workst':31B 'directori':79B,177C,213C,225C 'disabl':413C 'dollar':273C,473C 'draw':71B,153C,238C,391C 'e.g':85B 'env':346C,412C 'env/bin/activate':352C 'environ':8A,48B,77B,105B,116C,164C,173C,176C,377C,441C 'escap':44B,114C,137C,246C,271C,292C,305C,471C,498C 'everi':69B 'exampl':194C,482C 'execut':94B,363C 'expand':52B 'expans':258C,263C,435C 'fail':42B 'first':242C 'fix':464C,501C 'found':506C 'get':92B 'ghsa':17A 'ghsa-vxj4-q4g9-crj7':16A 'github.com':503C 'github.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932':502C 'given':493C 'handl':230C 'imag':521C 'impact':360C 'influenc':191C,382C 'input':171C 'insid':515C 'job':198C,208C 'keep':495C 'known':408C 'latest':451C,459C 'leav':421C 'ls':357C 'make':126C 'mitig':409C 'name':9A,49B,56B,78B,80B,117C,134C,140C,165C,174C,179C,209C,227C,279C,298C,307C,379C,438C,491C 'need':189C,434C,500C 'noprofil':349C 'norc':348C 'noth':327C,485C 'one':120C 'oss':518C 'p':356C 'packag':34B 'paramet':257C 'pass':124C,203C,234C,285C,289C,332C,479C 'patch':463C 'payload':319C 'per':389C 'preced':299C 'prepend':162C 'printf':353C 'privileg':99B,387C 'problem':455C 'project':206C 'prompt':70B,81B,84B,155C,182C,185C,221C,240C,245C,342C,390C,414C,431C,488C 'promptvar':428C 'proof':337C 'ps1':53B,128C,167C,231C,355C,422C 'pwned':345C,358C,359C 'python':35B 'q4g9':19A 'releas':300C,452C,461C 'repo':91B 'repositori':217C 'reproduc':456C 'result':266C 'root':253C,314C,407C,514C 'run':4A,58B,142C,256C,312C,326C,425C,484C,508C 'scanner':519C 'script':41B,108B,113C,270C,374C 'second':284C 'set':410C 'shell':67B,149C,366C 'shopt':426C 'show':320C,489C 'sign':274C,474C 'sinc':267C 'singl':497C 'sourc':103B,351C,371C,418C,448C 'src/virtualenv/activation/bash/activate.sh':158C 'strip':290C 'substitut':260C 'suit':512C 'summari':109C 'take':222C 'test':393C,511C 'text':323C 'time':151C,236C 'tool':201C 'touch':344C 'turn':247C 'two':123C,233C 'u':427C 'undo':135C 'unpack':219C 'unprivileg':403C 'user':65B,147C,369C,385C,404C 'valu':186C 'version':392C 'via':86B 'victim':97B,102B 'virtual':411C 'virtualenv':1A,24A,36B,37B,83B,184C,341C,460C,510C 'vxj4':18A 'whose':378C 'workstat':33B 'wrapper':200C 'wrong':322C 'x':453C 'zsh':328C,494C","nicknames":[],"mitigations":[],"who_affected":null,"tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-20T20:17:19+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-vxj4-q4g9-crj7","url":"https://github.com/advisories/GHSA-vxj4-q4g9-crj7","severity":"high","published_at":"2026-10-21T16:49:01+00:00","modified_at":"2026-10-21T16:49:02+00:00","first_seen_at":"2026-10-23T19:11:32+00:00","fetched_at":"2026-10-23T19:11:32+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-113725","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-113725","severity":null,"published_at":"2026-10-20T20:17:19+00:00","modified_at":"2026-10-22T16:47:38+00:00","first_seen_at":"2026-10-23T21:57:21+00:00","fetched_at":"2026-10-23T22:28:58+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}