Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-113732 Overview
CVE-2026-113732 is a command injection vulnerability in virtualenv, the widely used tool for creating isolated Python environments. The flaw affects the fish shell activator (activate.fish) in versions prior to 21.14.2. The FishActivator class inherits ViaTemplateActivator.quote(), which relies on POSIX shlex.quote(). Fish interprets backslashes and single quotes differently than POSIX shells, so the inherited quoting logic produces unsafe output. An attacker-influenced environment path, --prompt argument, or VIRTUALENV_PROMPT value containing a backslash before a quote can terminate the generated fish literal and trigger command substitution when a user sources activate.fish.
Critical Impact
Sourcing a maliciously named virtual environment in fish executes attacker-controlled commands under the invoking user's identity.
Affected Products
- virtualenv versions prior to 21.14.2
- Fish shell activate.fish script generated by FishActivator
- Python environments provisioned through virtualenv on systems using fish as the user shell
Discovery Timeline
- 2026-10-20 - CVE-2026-113732 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-113732
Vulnerability Analysis
The vulnerability is a Command Injection flaw classified under [CWE-78] (Improper Neutralization of Special Elements used in an OS Command). virtualenv generates shell activation scripts by substituting user-controlled values, such as the environment path and prompt string, into shell literal templates. For the fish activator, the inherited quote() method wraps strings in POSIX-style single quotes using shlex.quote().
Unlike POSIX sh, fish treats \ and \' as escape sequences inside single-quoted strings. A value containing a backslash immediately before a single quote can close the literal early. Any subsequent fish syntax, including $(...) or backtick command substitutions, executes when the user sources activate.fish.
Root Cause
The root cause is a mismatch between the quoting function used (shlex.quote(), designed for POSIX shells) and the lexical rules of the target shell (fish). The FishActivator subclass did not override quote() to apply fish-specific escaping for backslashes and single quotes before writing user-influenced strings into the generated script.
Attack Vector
Exploitation requires user interaction (UI:R) and local access (AV:L). An attacker influences the environment path, the --prompt CLI argument, or the VIRTUALENV_PROMPT environment variable with a payload containing a backslash-escaped quote followed by fish command substitution syntax. When a developer or CI job creates the virtualenv and later runs source activate.fish, the injected commands execute with the user's privileges.
def templates(self) -> Iterator[str]:
yield "activate.fish"
+ @staticmethod
+ def quote(string: str) -> str:
+ # fish reads \\ and \' as escapes inside single quotes, unlike POSIX sh, so shlex.quote's output lets a
+ # backslash before a quote end the literal early
+ return "'" + string.replace("\\", "\\\\").replace("'", "\\'") + "'"
+
def replacements(self, creator: Creator, dest_folder: Path) -> dict[str, str]:
data = super().replacements(creator, dest_folder)
data.update({
Source: pypa/virtualenv commit 3bddeaf8. The patch introduces a fish-specific quote() that doubles backslashes and escapes single quotes before wrapping the string.
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-113732
Indicators of Compromise
- Generated activate.fish files containing unbalanced single quotes or embedded $(...) or backtick sequences inside the prompt literal.
- Virtual environment directory paths or VIRTUALENV_PROMPT values containing a backslash followed by a single quote (\').
- Unexpected child processes spawned by fish shortly after a developer runs source activate.fish.
Detection Strategies
- Audit virtualenv --version across developer workstations and CI runners to identify installations below 21.14.2.
- Statically scan generated activate.fish scripts for suspicious shell metacharacters inside the VIRTUAL_ENV_PROMPT assignment.
- Monitor process ancestry where fish is the parent and short-lived utilities such as curl, wget, bash -c, or sh -c are the children immediately after a source command.
Monitoring Recommendations
- Collect endpoint telemetry on virtualenv CLI invocations, capturing the --prompt argument and target directory.
- Alert on VIRTUALENV_PROMPT environment variable values that contain backslashes, quotes, $, or backticks.
- Review CI/CD pipeline logs where virtual environment paths are derived from branch names, pull-request titles, or other untrusted inputs.
How to Mitigate CVE-2026-113732
Immediate Actions Required
- Upgrade virtualenv to version 21.14.2 or later on all developer endpoints, build agents, and container images.
- Regenerate any existing virtual environments created with a vulnerable version so that activate.fish is rewritten using the patched quote() method.
- Review automation that derives virtualenv paths or prompts from external input, and sanitize those values at the source.
Patch Information
The fix is included in virtualenv 21.14.2 and tracked by GHSA-c947-3pg5-gm8q. The patch overrides FishActivator.quote() to escape backslashes and single quotes before wrapping strings in fish-compatible single-quoted literals.
Workarounds
- Avoid using fish as the activation shell on vulnerable virtualenv versions; use bash, zsh, or activate directly until upgrading.
- Do not pass untrusted strings to --prompt or set VIRTUALENV_PROMPT from untrusted sources.
- Enforce virtual environment directory names that exclude backslashes and single quotes in CI pipelines.
# Upgrade virtualenv to the patched release
python -m pip install --upgrade 'virtualenv>=21.14.2'
# Verify the installed version
virtualenv --version
# Recreate affected environments so activate.fish is regenerated
rm -rf .venv && virtualenv .venv
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

