{"id":"CVE-2026-113726","kind":"vulnerability","aliases":["CVE-2026-113726","GHSA-5vjq-rrrf-7h2q"],"related":[],"title":"virtualenv activate runs commands from the environment name in zsh with PROMPT_SUBST","description":"### Impact\n\nzsh users activate an environment with the bash `activate` script, which puts the environment name into `PS1`. Since\n21.13.0 the script escapes backslashes, dollar signs and backticks in that name, but only when `BASH_VERSION` is set, so\nzsh gets the raw value. With the `PROMPT_SUBST` option set, zsh runs parameter expansion, command substitution and\narithmetic expansion on `PS1` each time it draws the prompt. A name that contains `$(...)`, backticks or `${...}` then\nruns as commands in the user's shell, once per prompt.\n\nThe name comes from the environment directory, or from `--prompt` or `VIRTUALENV_PROMPT`. After you create an\nenvironment with:\n\n```console\n$ virtualenv 'x$(touch PWNED)y'\n```\n\n`source 'x$(touch PWNED)y/bin/activate'` in a zsh session with `PROMPT_SUBST` set creates `PWNED`, and the prompt shows\n`(xy)`. Passing that value as `--prompt` to an environment with a plain name has the same effect. Without\n`PROMPT_SUBST`, zsh shows the name as text and runs nothing. bash runs nothing either.\n\nA plain zsh starts with `PROMPT_SUBST` off. oh-my-zsh users have it on: oh-my-zsh loads\n[`lib/theme-and-appearance.zsh`](https://github.com/ohmyzsh/ohmyzsh/blob/4d4cfc287e9d887b81242c0e431b5f49f9cec5c1/lib/theme-and-appearance.zsh#L5)\nat startup, and that file sets it. An attacker needs to influence the environment path or prompt: a CI job or wrapper\ntool that passes a branch, project or job name through, or a directory in a cloned repository or unpacked archive.\n`--prompt .` takes the current directory's name.\n\nzsh also reads `%` in `PS1` as a prompt escape, so a name with `%n` showed the user name in place of those characters,\nthough without running commands.\n\nThe bug is in releases up to and including 21.14.3. The payload runs on 20.26.6 and 21.14.3, and the reporter confirmed\n21.9.1.\n\n### Patches\n\nFixed in 21.14.4. Under zsh, `activate` now escapes the name the way it does under bash and doubles\n`%`, so the example above runs nothing and the prompt shows the name as given. zsh gets the escaping even when\n`PROMPT_SUBST` is off, because a user can set the option after activation; a name with a backslash, dollar sign or\nbacktick then shows the added backslashes.\nFix: https://github.com/pypa/virtualenv/commit/5b915367da82bd024b2a0d28d2f98007034b4aa2\n\n### Workarounds\n\nSet `VIRTUAL_ENV_DISABLE_PROMPT=1` before you source `activate`, which leaves `PS1` alone, or run\n`unsetopt prompt_subst` if your prompt does not need it. Check the name of an environment you did not create before you\nsource its `activate`.\n\n### Credits\n\nKaya Emre Arikan (@kemrec) reported this issue.","summary":"virtualenv's bash activate script does not escape the environment name for zsh, so a name containing $(...), backticks or ${...} runs as shell commands each time the prompt is drawn when zsh PROMPT_SUBST is on. An attacker who can influence the environment path, --prompt or VIRTUALENV_PROMPT gets code execution in the victim's zsh session.","severity":"high","cvss":7.800000190734863,"epss":0.0023399998899549246,"exploited":false,"exploited_at":null,"products":[{"name":"virtualenv","fixed":["21.14.4"],"affected":"<= 21.14.3","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["ci","cwe-116","cwe-78","oh-my-zsh","package","python","virtualenv","zsh"],"not_affected_if":["bash-only","prompt-subst-off","venv-not-activated-in-zsh"],"how_to_check":"Run `echo $options[prompt_subst]` or `setopt | grep prompt_subst` in zsh to see if PROMPT_SUBST is on (oh-my-zsh enables it by default).\nRun `pip show virtualenv` and check whether the version is 21.14.3 or lower.\nList environment directory names and check for $, backtick or % characters, e.g. `ls -d */ | grep -E '[$`%]'`.","fix":"Upgrade virtualenv to 21.14.4 or later.\nUntil then, set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing activate, or run `unsetopt prompt_subst` in zsh.","status":"open","published_at":"2026-10-20T22:19:29+00:00","first_seen_at":"2026-10-23T19:11:32+00:00","triaged_at":"2026-10-23T19:52:53+00:00","updated_at":"2026-10-23T21:57:25+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-10-23T19:52:53Z","model":"claude-haiku-5-5","output":{"fix":"Upgrade virtualenv to 21.14.4 or later.\nUntil then, set VIRTUAL_ENV_DISABLE_PROMPT=1 before sourcing activate, or run `unsetopt prompt_subst` in zsh.","summary":"virtualenv's bash activate script does not escape the environment name for zsh, so a name containing $(...), backticks or ${...} runs as shell commands each time the prompt is drawn when zsh PROMPT_SUBST is on. An attacker who can influence the environment path, --prompt or VIRTUALENV_PROMPT gets code execution in the victim's zsh session.","category":"package","who_cares":["python","zsh","oh-my-zsh","ci","virtualenv"],"confidence":0.85,"analyst_note":"","how_to_check":"Run `echo $options[prompt_subst]` or `setopt | grep prompt_subst` in zsh to see if PROMPT_SUBST is on (oh-my-zsh enables it by default).\nRun `pip show virtualenv` and check whether the version is 21.14.3 or lower.\nList environment directory names and check for $, backtick or % characters, e.g. `ls -d */ | grep -E '[$`%]'`.","needs_analyst":false,"not_affected_if":["bash-only","prompt-subst-off","venv-not-activated-in-zsh"],"severity_if_unknown":"high"},"cost_usd":0.000547,"input_tokens":3052,"output_tokens":484,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-113726':16A,24A '-116':28B '-2026':15A,23A '-78':30B '/ohmyzsh/ohmyzsh/blob/4d4cfc287e9d887b81242c0e431b5f49f9cec5c1/lib/theme-and-appearance.zsh#l5)':281C '/pypa/virtualenv/commit/5b915367da82bd024b2a0d28d2f98007034b4aa2':449C '1':456C '20.26.6':372C '21.13.0':114C '21.14.3':367C,374C '21.14.4':383C '21.9.1':379C '5vjq':19A '7h2q':21A 'activ':2A,42B,98C,104C,386C,431C,460C,491C 'add':444C 'alon':464C 'also':332C 'archiv':323C 'arikan':495C 'arithmet':152C 'attack':75B,290C 'backslash':118C,436C,445C 'backtick':56B,122C,166C,440C 'bash':41B,103C,129C,253C,396C 'branch':308C 'bug':359C 'charact':353C 'check':477C 'ci':26B,300C 'clone':319C 'code':87B 'come':182C 'command':4A,61B,149C,171C,357C 'confirm':378C 'consol':199C 'contain':55B,165C 'creat':195C,218C,486C 'credit':492C 'current':327C 'cve':14A,22A 'cwe':27B,29B 'directori':186C,316C,328C 'disabl':454C 'dollar':119C,437C 'doubl':398C 'draw':159C 'drawn':67B 'effect':240C 'either':256C 'emr':494C 'env':453C 'environ':7A,48B,80B,100C,109C,185C,197C,232C,295C,482C 'escap':46B,117C,339C,388C,416C 'even':417C 'exampl':401C 'execut':88B 'expans':148C,153C 'file':286C 'fix':381C,446C 'get':86B,135C,414C 'ghsa':18A 'ghsa-5vjq-rrrf-7h2q':17A 'github.com':280C,448C 'github.com/ohmyzsh/ohmyzsh/blob/4d4cfc287e9d887b81242c0e431b5f49f9cec5c1/lib/theme-and-appearance.zsh#l5)':279C 'github.com/pypa/virtualenv/commit/5b915367da82bd024b2a0d28d2f98007034b4aa2':447C 'given':412C 'impact':95C 'includ':366C 'influenc':78B,293C 'issu':499C 'job':301C,311C 'kaya':493C 'kemrec':496C 'leav':462C 'lib/theme-and-appearance.zsh':278C 'load':277C 'n':344C 'name':8A,49B,54B,110C,125C,163C,181C,236C,247C,312C,330C,342C,348C,390C,410C,433C,479C 'need':291C,475C 'noth':252C,255C,404C 'oh':32B,266C,274C 'oh-my-zsh':31B,265C,273C 'option':143C,429C 'packag':35B 'paramet':147C 'pass':225C,306C 'patch':380C 'path':81B,296C 'payload':369C 'per':178C 'place':350C 'plain':235C,258C 'project':309C 'prompt':12A,65B,70B,82B,85B,141C,161C,179C,189C,192C,215C,222C,229C,242C,262C,298C,324C,338C,407C,419C,455C,468C,472C 'ps1':112C,155C,335C,463C 'put':107C 'pwned':203C,208C,219C 'python':36B 'raw':137C 'read':333C 'releas':362C 'report':377C,497C 'repositori':320C 'rrrf':20A 'run':3A,58B,146C,169C,251C,254C,356C,370C,403C,466C 'script':43B,105C,116C 'session':94B,213C 'set':132C,144C,217C,287C,427C,451C 'shell':60B,176C 'show':223C,245C,345C,408C,442C 'sign':120C,438C 'sinc':113C 'sourc':205C,459C,489C 'start':260C 'startup':283C 'subst':13A,71B,142C,216C,243C,263C,420C,469C 'substitut':150C 'take':325C 'text':249C 'though':354C 'time':63B,157C 'tool':304C 'touch':202C,207C 'unpack':322C 'unsetopt':467C 'user':97C,174C,269C,347C,425C 'valu':138C,227C 'version':130C 'victim':91B 'virtual':452C 'virtualenv':1A,25A,37B,39B,84B,191C,200C 'way':392C 'without':241C,355C 'workaround':450C 'wrapper':303C 'x':201C,206C 'xy':224C 'y':204C 'y/bin/activate':209C 'zsh':10A,34B,38B,51B,69B,93B,96C,134C,145C,212C,244C,259C,268C,276C,331C,385C,413C","nicknames":[],"mitigations":[],"who_affected":null,"tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-20T22:19:29+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-5vjq-rrrf-7h2q","url":"https://github.com/advisories/GHSA-5vjq-rrrf-7h2q","severity":"high","published_at":"2026-10-21T16:46:23+00:00","modified_at":"2026-10-21T16:46:24+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-113726","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-113726","severity":null,"published_at":"2026-10-20T22:19:29+00:00","modified_at":"2026-10-22T16:47:38+00:00","first_seen_at":"2026-10-23T21:57:25+00:00","fetched_at":"2026-10-23T22:29:00+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"}