/

CVE-2026-113732

Severity:

HIGH RISK

(7.8)

Command Injection (CWE-78) in virtualenv FishActivator

CVE-2026-113732

Awaiting Analysis

Vulnerability type

Category:

Command Injection

CWE:

CWE-78, CWE-116

Impact:

Command Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection vulnerability in virtualenv's Fish shell activator can arise when attacker-influenced paths or prompt values are improperly quoted for Fish syntax. If a user sources the generated activate.fish script containing a crafted backslash-and-quote sequence, command substitution may execute with the user's shell privileges.

A command injection vulnerability in virtualenv's Fish shell activator can arise when attacker-influenced paths or prompt values are improperly quoted for Fish syntax. If a user sources the generated activate.fish script containing a crafted backslash-and-quote sequence, command substitution may execute with the user's shell privileges.

Affected context

The issue affects virtualenv environments using the Fish shell activator when an environment path, --prompt value, or VIRTUALENV_PROMPT value can be influenced by an attacker. Risk exists because the activator generates shell code using quoting behavior intended for POSIX shells, while Fish interprets backslashes and single quotes differently. Exploitation requires the generated activation script to be sourced by a user.

The issue affects virtualenv environments using the Fish shell activator when an environment path, --prompt value, or VIRTUALENV_PROMPT value can be influenced by an attacker. Risk exists because the activator generates shell code using quoting behavior intended for POSIX shells, while Fish interprets backslashes and single quotes differently. Exploitation requires the generated activation script to be sourced by a user.

Exploit preconditions

  • Attack surface: Generated Fish shell activation script
  • Required access: Ability to influence the virtual environment path or prompt-related configuration
  • Trigger point: A user sources the resulting activate.fish script
  • Why exploitation is possible: The activator applies POSIX shlex.quote() escaping to values interpreted under Fish syntax, allowing crafted characters to alter the generated command structure and trigger command substitution
  • Attack surface: Generated Fish shell activation script
  • Required access: Ability to influence the virtual environment path or prompt-related configuration
  • Trigger point: A user sources the resulting activate.fish script
  • Why exploitation is possible: The activator applies POSIX shlex.quote() escaping to values interpreted under Fish syntax, allowing crafted characters to alter the generated command structure and trigger command substitution

Why this happens

The underlying bug is a shell-context mismatch in output escaping. FishActivator inherits quoting behavior designed for POSIX shell syntax, but Fish has different parsing rules for backslashes and single quotes. Consequently, data that appears escaped for one shell can become executable syntax in another, mapping to CWE-78: Improper Neutralization of Special Elements used in an OS Command and CWE-116: Improper Encoding or Escaping of Output.

The underlying bug is a shell-context mismatch in output escaping. FishActivator inherits quoting behavior designed for POSIX shell syntax, but Fish has different parsing rules for backslashes and single quotes. Consequently, data that appears escaped for one shell can become executable syntax in another, mapping to CWE-78: Improper Neutralization of Special Elements used in an OS Command and CWE-116: Improper Encoding or Escaping of Output.

Potential impact

  • Execution of attacker-controlled commands in the user's shell context
  • Exposure or modification of files accessible to that user
  • Theft of environment variables, credentials, or tokens available to the shell
  • Modification of the virtual environment or project files
  • Potential lateral movement if the affected user has broader system access
  • Execution of attacker-controlled commands in the user's shell context
  • Exposure or modification of files accessible to that user
  • Theft of environment variables, credentials, or tokens available to the shell
  • Modification of the virtual environment or project files
  • Potential lateral movement if the affected user has broader system access

General mitigation guidance

Mitigation generally focuses on generating shell-specific code with shell-specific escaping rules and minimizing trust in values embedded into activation scripts.

Common defensive patterns include:

  • Use a Fish-aware quoting or escaping routine for every value inserted into Fish scripts
  • Prefer structured activation mechanisms that avoid embedding untrusted data in executable shell source
  • Validate and constrain environment paths and prompt values before code generation
  • Treat environment metadata and prompt configuration as untrusted input
  • Run development and automation workflows with least-privilege accounts and limited credentials
  • Review generated activation scripts before sourcing them when values originate outside trusted project controls

Mitigation generally focuses on generating shell-specific code with shell-specific escaping rules and minimizing trust in values embedded into activation scripts.

Common defensive patterns include:

  • Use a Fish-aware quoting or escaping routine for every value inserted into Fish scripts
  • Prefer structured activation mechanisms that avoid embedding untrusted data in executable shell source
  • Validate and constrain environment paths and prompt values before code generation
  • Treat environment metadata and prompt configuration as untrusted input
  • Run development and automation workflows with least-privilege accounts and limited credentials
  • Review generated activation scripts before sourcing them when values originate outside trusted project controls

How teams detect issues like this

Organizations can detect similar issues through:

  • Static analysis rules that identify shell code generation from externally influenced values
  • Checks for reuse of POSIX escaping functions in Fish or other non-POSIX shell output
  • Code review of activator templates, quoting helpers, and interpolation boundaries
  • Tests using shell-specific metacharacters, backslashes, quotes, and command-substitution syntax
  • Repository policies requiring shell-language-aware escaping and security tests for generated scripts
  • Automated security review tools that flag possible command injection and output-encoding mismatches

Organizations can detect similar issues through:

  • Static analysis rules that identify shell code generation from externally influenced values
  • Checks for reuse of POSIX escaping functions in Fish or other non-POSIX shell output
  • Code review of activator templates, quoting helpers, and interpolation boundaries
  • Tests using shell-specific metacharacters, backslashes, quotes, and command-substitution syntax
  • Repository policies requiring shell-language-aware escaping and security tests for generated scripts
  • Automated security review tools that flag possible command injection and output-encoding mismatches

Sources

SourceLink
github.comgithub.com/pypa/virtualenv/commit/3bddeaf8d02c3ee7f576503efb082f8f494cfcab
github.comgithub.com/pypa/virtualenv/releases/tag/21.14.2
github.comgithub.com/pypa/virtualenv/security/advisories/GHSA-c947-3pg5-gm8q

Frequently asked

questions

It is not inherently a network-facing vulnerability. Exploitation generally requires an attacker to influence a path or prompt value and have a user source the resulting Fish activation script.

The attacker needs a way to control relevant virtualenv inputs, such as project-controlled configuration, a path, or an environment variable. The victim must then use the affected activation script.

Generate Fish syntax using Fish-specific escaping and avoid placing attacker-influenced values directly into executable shell code whenever possible.

Treat generated shell scripts as code, apply language-specific escaping, validate input values, and test activation templates with adversarial quoting and metacharacter cases.

It is not inherently a network-facing vulnerability. Exploitation generally requires an attacker to influence a path or prompt value and have a user source the resulting Fish activation script.

The attacker needs a way to control relevant virtualenv inputs, such as project-controlled configuration, a path, or an environment variable. The victim must then use the affected activation script.

Generate Fish syntax using Fish-specific escaping and avoid placing attacker-influenced values directly into executable shell code whenever possible.

Treat generated shell scripts as code, apply language-specific escaping, validate input values, and test activation templates with adversarial quoting and metacharacter cases.

Find out what's already
exploitable in your codebase.