/

CVE-2026-115586

Severity:

HIGH RISK

(7.8)

Shell Command Injection (CWE-78) in virtualenv Activation

CVE-2026-115586

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Command execution as the activating user

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 occur when an attacker-controlled prompt value is copied into the shell prompt without escaping. Under specific Bash settings, later prompt expansion may execute commands as the user who activates the environment.

Affected context

The issue affects virtualenv versions 21.14.9 through 21.14.13 when using the Bash bin/activate script with a prompt value supplied through --prompt. Risk depends on shell behavior: prompt variables and POSIX mode must be disabled during activation, and a later shell action must cause the stored prompt value to be expanded.

Exploit preconditions

  • Attack surface: Local Bash environment activation
  • Required access: Ability to provide or influence the virtual environment's --prompt value and have a user activate that environment
  • Trigger point: The prompt value is copied into PS1 during activation; subsequent prompt expansion may evaluate it
  • Why exploitation is possible: The prompt value is not escaped before being stored in PS1, allowing command substitution to be interpreted when shell settings or behavior later trigger expansion

Why this happens

The activation script places an attacker-controlled prompt value into PS1 without escaping shell expansion characters. When Bash later expands the prompt under applicable settings, command substitution in the value can execute commands. This is an OS command injection flaw mapped to CWE-78, caused by passing untrusted data into a shell-interpreted context.

Potential impact

  • Commands may execute with the privileges of the user activating the environment
  • The user's files, credentials, or development resources could be accessed or modified
  • Malicious changes could affect projects or processes run from the compromised shell

General mitigation guidance

Defensive patterns focus on treating prompt values as untrusted data and preventing their interpretation as shell syntax.

  • Escape or safely encode values before placing them in shell-interpreted prompt variables
  • Prefer prompt construction mechanisms that keep data separate from executable shell expressions
  • Limit who can create or modify environments and their configuration
  • Run development tools and shells with only the privileges needed for their tasks

How teams detect issues like this

  • Review shell activation scripts for untrusted values assigned to PS1 or other expansion-sensitive variables
  • Use static analysis to flag unescaped prompt data and command substitution in shell contexts
  • Check code review and CI policies for unsafe interpolation of user-controlled values into shell variables
  • Monitor environment creation and activation workflows for unexpected changes to prompt configuration

Sources

SourceLink
github.comgithub.com/pypa/virtualenv/commit/3598e201f6f044e389136b2347a8a919ac03c5f4
github.comgithub.com/pypa/virtualenv/pull/3466
github.comgithub.com/pypa/virtualenv/releases/tag/21.14.13
github.comgithub.com/pypa/virtualenv/security/advisories/GHSA-cx6f-vjhg-g3cc

Frequently asked

questions

The described issue requires a local activation workflow. An attacker would need a way to influence the prompt value and have a user activate the affected environment.

Access to provide or alter the environment's prompt value is needed. Commands execute with the privileges of the user whose shell expands the prompt.

Treat prompt values as data: escape them appropriately or use a construction method that does not interpret their contents as shell syntax.

Review shell scripts for untrusted input assigned to expansion-sensitive variables, and enforce static analysis and code review checks for unsafe interpolation.

Find out what's already
exploitable in your codebase.