CVE-2026-113732: virtualenv activate.fish runs commands from a path or prompt with a backslash before a quote

Published Oct 20, 2026
·
Updated

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 VIRTUALENV, and --prompt or VIRTUALENVPROMPT reaches set -gx VIRTUALENVPROMPT. For --prompt "x\'\$(touch PWNED)'\'", the generated activate.fish contains:

fish set -gx VIRTUALENVPROMPT 'x\'"'"'$(touch PWNED)'"'"'\'"'"''

source bin/activate.fish runs touch PWNED, and fish prints no error. The same payload as a directory name runs through VIRTUALENV. --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.

Other sources

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 VIRTUALENVPROMPT 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.

— Ubuntu

Affected Software

17 affected componentsFixes available
pypi/virtualenv<21.14.2
pip/virtualenv<=21.14.1
21.14.2
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
ubuntu/python-virtualenv*
debian/python-virtualenv<=20.17.1+ds-1, <=20.31.2+ds-1+deb13u1, <=21.5.1+ds-1
21.15.6+ds-2
virtualenv virtualenv<21.14.2
debian/python-virtualenv*
debian/python-virtualenv*
debian/python-virtualenv*
pip/virtualenv<21.14.2
21.14.2
bitnami/virtualenv<21.14.2
21.14.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/virtualenv to a version that resolves this vulnerability.

    Fixed in 21.14.2
  2. Upgrade

    Upgrade bitnami/virtualenv to a version that resolves this vulnerability.

    Fixed in 21.14.2
  3. Upgrade

    Upgrade debian/python-virtualenv to a version that resolves this vulnerability.

    Fixed in 21.15.6+ds-2
  4. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 21.14.2
  5. Compensating control

    Do not create a virtual environment whose path or prompt contains a backslash before a quote.

  6. Compensating control

    Inspect activate.fish before sourcing one you did not create.

Event History

Oct 20, 2026
CVE Published
via Ubuntu·12:00 AM
Data Sourced
via Ubuntu·12:00 AM
RemedyDescriptionSeverityAffected Software
CVE Published
via MITRE·10:01 PM
Data Sourced
via MITRE·10:01 PM
DescriptionSeverityWeakness
Advisory Published
via OSV·10:19 PM
Data Sourced
via NVD·10:19 PM
DescriptionSeverityWeakness
Oct 21, 2026
Advisory Published
via GitHub·04:39 PM
Data Sourced
via GitHub·04:39 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software
Nov 17, 2026
Data Sourced
via NVD·03:16 PM
RemedyAffected Software

Frequently Asked Questions

1

Who is exposed to this issue?

Users of virtualenv versions earlier than 21.14.2 who use the fish shell and source a generated activate.fish script are exposed when the environment path, --prompt value, or VIRTUALENV_PROMPT value is attacker-influenced and contains a backslash immediately before a quote.

2

What must an attacker control to exploit it?

The attacker must be able to influence the virtual environment path, the --prompt option, or the VIRTUALENV_PROMPT value used when generating the activation script. Exploitation also requires a user to source the resulting activate.fish script in fish.

3

Are other activation shells affected by the described flaw?

The issue described is specific to FishActivator and the generated activate.fish script. The vulnerable behavior comes from using POSIX shlex.quote() despite fish handling backslashes and single quotes differently.

4

How can I remediate the issue?

Upgrade virtualenv to version 21.14.2 or later. If upgrading is not immediately possible, avoid sourcing activate.fish scripts generated from attacker-influenced environment paths or prompt values, especially values containing a backslash before a quote.

5

How can I determine whether a generated activation script is risky?

Review the inputs used to generate it: the environment path, --prompt value, and VIRTUALENV_PROMPT. A script is at risk when one of those attacker-influenced values contains a backslash immediately before a quote and the script is sourced by fish.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203