/

CVE-2026-113725

Severity:

HIGH RISK

(7.8)

Command Injection (CWE-78) in virtualenv Activation

CVE-2026-113725

Awaiting Analysis

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-116

Impact:

Command Execution in the User's Shell

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 Bash activation script can cause shell commands embedded in an environment name to execute when Bash redraws the prompt. The issue becomes risky when an attacker can influence the virtual environment name and a user activates that environment in Bash.

A command injection vulnerability in virtualenv's Bash activation script can cause shell commands embedded in an environment name to execute when Bash redraws the prompt. The issue becomes risky when an attacker can influence the virtual environment name and a user activates that environment in Bash.

Affected context

The vulnerability occurs in the Bash activation script generated for affected virtualenv environments. It is relevant when an environment name contains shell-sensitive characters, including backslashes and command-substitution syntax, and the activation script is sourced by Bash. Exploitation depends on a user activating the affected environment and subsequently having the shell render its prompt.

The vulnerability occurs in the Bash activation script generated for affected virtualenv environments. It is relevant when an environment name contains shell-sensitive characters, including backslashes and command-substitution syntax, and the activation script is sourced by Bash. Exploitation depends on a user activating the affected environment and subsequently having the shell render its prompt.

Exploit preconditions

  • Attack surface: The Bash activation script and the shell prompt rendering path
  • Required access: The attacker must be able to influence or provide the virtual environment name or its generated activation files
  • Trigger point: A user sources the activation script in Bash and the shell draws the prompt
  • Why exploitation is possible: Incomplete escaping across Bash's prompt-processing passes can leave command-substitution syntax executable
  • Attack surface: The Bash activation script and the shell prompt rendering path
  • Required access: The attacker must be able to influence or provide the virtual environment name or its generated activation files
  • Trigger point: A user sources the activation script in Bash and the shell draws the prompt
  • Why exploitation is possible: Incomplete escaping across Bash's prompt-processing passes can leave command-substitution syntax executable

Why this happens

The underlying bug is incomplete output escaping in a shell-generated prompt value. The activation script escapes the environment name for only one of Bash's processing passes, allowing a backslash in the name to undo that protection during a later pass and expose command-substitution syntax. This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-116: Improper Encoding or Escaping of Output describing the flawed escaping behavior.

The underlying bug is incomplete output escaping in a shell-generated prompt value. The activation script escapes the environment name for only one of Bash's processing passes, allowing a backslash in the name to undo that protection during a later pass and expose command-substitution syntax. This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-116: Improper Encoding or Escaping of Output describing the flawed escaping behavior.

Potential impact

  • An attacker's commands may execute with the privileges of the affected user
  • User files, credentials, source code, or environment variables could be exposed
  • The attacker could modify local projects, virtual environments, or shell configuration
  • Development workflows or build processes could be disrupted or used for further compromise
  • An attacker's commands may execute with the privileges of the affected user
  • User files, credentials, source code, or environment variables could be exposed
  • The attacker could modify local projects, virtual environments, or shell configuration
  • Development workflows or build processes could be disrupted or used for further compromise

General mitigation guidance

Mitigation focuses on treating environment names and other generated shell values as untrusted data.

Common defensive patterns include:

  • Avoiding interpolation of untrusted values into executable shell or prompt expressions
  • Applying escaping that is correct for every parsing and evaluation pass
  • Preferably using prompt mechanisms that keep displayed data separate from executable shell syntax
  • Restricting who can create or rename virtual environments in shared workspaces
  • Running development and automation tasks with least privilege and minimizing sensitive data in shell environments
  • Reviewing generated activation scripts before sourcing them when their names or contents originate outside a trusted workflow

Mitigation focuses on treating environment names and other generated shell values as untrusted data.

Common defensive patterns include:

  • Avoiding interpolation of untrusted values into executable shell or prompt expressions
  • Applying escaping that is correct for every parsing and evaluation pass
  • Preferably using prompt mechanisms that keep displayed data separate from executable shell syntax
  • Restricting who can create or rename virtual environments in shared workspaces
  • Running development and automation tasks with least privilege and minimizing sensitive data in shell environments
  • Reviewing generated activation scripts before sourcing them when their names or contents originate outside a trusted workflow

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules identifying untrusted values embedded in shell commands, PS1 assignments, or command-substitution contexts
  • Code review checks for multiple shell parsing passes and incomplete escaping of backslashes, quotes, or substitution markers
  • Tests that exercise generated scripts with shell metacharacters and prompt redraw behavior
  • Repository and CI policies that flag dynamic shell evaluation and unsafe prompt construction
  • Runtime monitoring for unexpected child processes launched when activation scripts are sourced or prompts are rendered

Organizations can look for this class of issue through:

  • Static analysis rules identifying untrusted values embedded in shell commands, PS1 assignments, or command-substitution contexts
  • Code review checks for multiple shell parsing passes and incomplete escaping of backslashes, quotes, or substitution markers
  • Tests that exercise generated scripts with shell metacharacters and prompt redraw behavior
  • Repository and CI policies that flag dynamic shell evaluation and unsafe prompt construction
  • Runtime monitoring for unexpected child processes launched when activation scripts are sourced or prompts are rendered

Sources

SourceLink
github.comgithub.com/pypa/virtualenv/commit/c3104e02474b652832a9bbaae79f6e1696296932
github.comgithub.com/pypa/virtualenv/releases/tag/21.14.7
github.comgithub.com/pypa/virtualenv/security/advisories/GHSA-vxj4-q4g9-crj7

Frequently asked

questions

Not directly in the usual deployment model. Exploitation generally requires a malicious or tampered environment name or activation script to reach a user's local Bash session.

The attacker needs a way to influence the environment name or generated activation content, but does not necessarily need an interactive shell on the victim's system. A victim must activate the environment in Bash for the trigger to occur.

Keep untrusted environment names out of executable prompt expressions, or apply context-aware escaping that remains safe through every shell parsing pass.

Test generated shell scripts with adversarial names, review prompt and activation logic for repeated evaluation, and enforce policies against unsafe dynamic shell construction.

Not directly in the usual deployment model. Exploitation generally requires a malicious or tampered environment name or activation script to reach a user's local Bash session.

The attacker needs a way to influence the environment name or generated activation content, but does not necessarily need an interactive shell on the victim's system. A victim must activate the environment in Bash for the trigger to occur.

Keep untrusted environment names out of executable prompt expressions, or apply context-aware escaping that remains safe through every shell parsing pass.

Test generated shell scripts with adversarial names, review prompt and activation logic for repeated evaluation, and enforce policies against unsafe dynamic shell construction.

Find out what's already
exploitable in your codebase.