7.8high
virtualenv activate.fish runs commands from a path or prompt with a backslash before a quote
- Severity
- 7.8high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.26% (higher than 18% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-c947-3pg5-gm8qBIT-VIRTUALENV-2026-113732PYSEC-2026-4386
Description
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.2, FishActivator inherits ViaTemplateActivator.quote(), which uses POSIX shlex.quote() even though fish interprets backslashes and single quotes differently. An attacker-influenced environment path, --prompt, or VIRTUALENV_PROMPT value containing a backslash before a quote can therefore terminate the generated fish literal and execute command substitution when the user sources activate.fish. This issue is fixed in version 21.14.2.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| pypa virtualenv | < 21.14.2 | CVE List |
| virtualenv (PyPI) | before 21.14.2 | GitHub Advisory Database, PyPA Advisory Database |
| virtualenv virtualenv | before 21.14.2 | NVD |
| virtualenv (Bitnami) | before 21.14.2 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| GitHub | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| PyPA Advisory Database | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| Bitnami Vulnerability Database | high rating |
Classification
What each source says
CVE List
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.2, FishActivator inherits ViaTemplateActivator.quote(), which uses POSIX shlex.quote() even though fish interprets backslashes and single quotes differently. An attacker-influenced environment path, --prompt, or VIRTUALENV_PROMPT value containing a backslash before a quote can therefore terminate the generated fish literal and execute command substitution when the user sources activate.fish. This issue is fixed in version 21.14.2.
GitHub Advisory Database
Impact
FishActivator defines no quote(), so it inherits ViaTemplateActivator.quote, which returns shlex.quote(string). That function follows POSIX sh rules, where a backslash inside single quotes stays a literal character. fish reads \' inside single quotes as an escaped quote and \\ as an escaped backslash. A value with a backslash before a quote therefore ends the literal somewhere other than where shlex.quote put the end, and fish expands the command substitution that follows.
The environment path reaches set -gx VIRTUAL_ENV, and --prompt or VIRTUALENV_PROMPT reaches set -gx VIRTUAL_ENV_PROMPT. For --prompt "x\'\$(touch PWNED)'\'", the generated activate.fish contains:
set -gx VIRTUAL_ENV_PROMPT 'x\'"'"'$(touch PWNED)'"'"'\'"'"''
source bin/activate.fish runs touch PWNED, and fish prints no error. The same payload as a directory name runs through VIRTUAL_ENV. --prompt . takes the current directory's name, so running virtualenv inside a directory someone else named is enough. Without the backslash the payload runs nothing, and under bash it runs nothing either.
virtualenv generates activate.fish by default. An attacker needs to influence the environment path or prompt: a CI job or wrapper tool that passes a branch, project or job name through, or a directory in a cloned repository or unpacked archive.
The bug affects every release up to 21.14.1 that ships activate.fish. The GHSA-p58f-9548-mpm2 fix in 21.7.13 moved the placeholders outside their quotes but kept shlex.quote.
Patches
Fixed in 21.14.2. activate.fish now escapes backslashes and single quotes the way fish reads them, so the example above runs nothing and shows the prompt as given. Fix: https://github.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab
Workarounds
Do not create an environment whose path or prompt contains a backslash, and inspect activate.fish before you source one you did not create.
Credits
Kevin Stubbings (@Kwstubbs) of GitHub Security Lab reported this issue.
References
| https://github.com/pypa/virtualenv/security/advisories/GHSA-c947-3pg5-gm8q | advisory, fix, patch, vendor-advisory, web | |
| https://github.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab | fix, patch, web | |
| https://github.com/pypa/virtualenv/releases/tag/21.14.2 | advisory, article, release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-113732 | advisory, web | |
| https://github.com/pypa/virtualenv | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-113732 changed 2026-10-27 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-c947-3pg5-gm8q changed 2026-11-18 | CC-BY-4.0 |
| NVD | CVE-2026-113732 changed 2026-11-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-4386 changed 2026-11-18 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-VIRTUALENV-2026-113732 changed 2026-11-27 | Apache-2.0 |