/

CVE-2026-102925

Severity:

HIGH RISK

(7.8)

OS Command Injection (CWE-78) in virtualenv Activation

CVE-2026-102925

Awaiting Analysis

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

User-level arbitrary code 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

virtualenv activation scripts can mishandle already-escaped values by placing them inside an additional quoted context. If a user sources a crafted activation script, shell metacharacters may be interpreted as commands and execute with that user's privileges.

Affected context

The vulnerability occurs in generated Bash, Zsh, and Fish activation scripts when virtual environment paths or Tcl/Tk library paths contain crafted characters. It is most relevant when a relocated environment lacks its recorded directory, or when library path values are incorporated into Fish activation logic, and a user sources the generated script.

Exploit preconditions

  • Attack surface: Generated shell activation scripts - Required access: Ability to influence the virtual environment path or

relevant Tcl/Tk library path, and an opportunity for a user to source the

resulting script

  • Trigger point: Execution of the activation script through a shell sourcing

operation

  • Why exploitation is possible: Values escaped for shell use are inserted

into another quoted context, allowing crafted delimiters and metacharacters

to escape data-only handling and be parsed as shell commands

Why this happens

The underlying bug is an unsafe composition of shell-escaped data and an additional quoting layer. The scripts treat a value returned by an escaping routine as though it can safely be embedded inside a separate quoted expression, but the two contexts do not compose safely for all inputs. This permits data intended to initialize environment variables to alter shell syntax, mapping to CWE-78 because externally influenced data can reach an operating-system command interpreter.

Potential impact

  • An attacker may execute arbitrary commands with the privileges of the user who sources the script.
  • The attacker could access or modify files available to that user.
  • Credentials, environment variables, or project data could be exposed.
  • A compromised developer or automation account could be used for further compromise.

General mitigation guidance

Mitigation generally focuses on eliminating ambiguous shell quoting and treating generated activation scripts as security-sensitive code. Secure patterns include using shell-native assignments that preserve data boundaries, applying context-appropriate escaping exactly once, avoiding unnecessary command interpretation, and using secure-by-default activation templates. Input trust can be reduced by constraining environment and library paths to validated representations and by avoiding execution of activation scripts obtained from untrusted locations. Least-privilege user and process permissions can limit the consequences if script execution occurs.

How teams detect issues like this

Detection can include static analysis for nested quoting, string concatenation around shell-escaped values, command substitutions, and generated scripts that interpolate filesystem paths into executable shell syntax. Code review should examine every shell and Fish assignment for context-appropriate escaping and test values containing separators, substitutions, quotes, and metacharacters. Policy enforcement can require generated scripts to pass shell-aware linting, isolated parsing tests, and automated security review before release.

Sources

SourceLink
github.comgithub.com/pypa/virtualenv/commit/4d5a105ec2a2723b8c7f4571bb68f4f71d01e3f6
github.comgithub.com/pypa/virtualenv/pull/3252
github.comgithub.com/pypa/virtualenv/releases/tag/21.7.13
github.comgithub.com/pypa/virtualenv/security/advisories/GHSA-p58f-9548-mpm2

Frequently asked

questions

It is generally not a direct network attack. Exploitation requires a crafted

environment or library path to reach a generated activation script and a user

or automation process to source that script.

The attacker must be able to influence the relevant virtual environment

directory or Tcl/Tk library path, or distribute a generated environment that

contains such a value. The victim must then source its activation script.

Avoid composing pre-escaped values inside additional quoted shell contexts.

Use context-specific, single-pass escaping and data-only assignments that do

not invoke command interpretation.

Treat generated shell scripts as executable code, apply shell-aware static

analysis and review, test adversarial path values, restrict untrusted

environments, and run development automation with least privilege.

Find out what's already
exploitable in your codebase.