/

CVE-2026-113722

Severity:

HIGH RISK

(7.8)

OS Command Injection (CWE-78) in virtualenv Launchers

CVE-2026-113722

Awaiting Analysis

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Command Execution with User Privileges

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-generated POSIX launchers can allow shell command execution when an interpreter path contains spaces or results in an overly long shebang. An attacker who can influence an environment's destination may cause commands to run with the user's privileges when the user later executes an affected launcher.

A command injection vulnerability in virtualenv-generated POSIX launchers can allow shell command execution when an interpreter path contains spaces or results in an overly long shebang. An attacker who can influence an environment's destination may cause commands to run with the user's privileges when the user later executes an affected launcher.

Affected context

The issue occurs during POSIX console-script generation when virtualenv or pip passes an incompletely quoted interpreter path to distlib. If the resulting shebang is too long or contains a space, distlib may generate a /bin/sh wrapper whose double-quoted path can still interpret command substitutions or backticks. Environment creation and activation alone do not trigger the behavior; an affected launcher must later be executed.

The issue occurs during POSIX console-script generation when virtualenv or pip passes an incompletely quoted interpreter path to distlib. If the resulting shebang is too long or contains a space, distlib may generate a /bin/sh wrapper whose double-quoted path can still interpret command substitutions or backticks. Environment creation and activation alone do not trigger the behavior; an affected launcher must later be executed.

Exploit preconditions

  • Attack surface: POSIX console-script launchers generated inside Python virtual environments
  • Required access: Ability to influence the environment destination or interpreter path used during launcher generation
  • Trigger point: Execution of a previously generated affected launcher by a user or automated process
  • Why exploitation is possible: Shell wrapper generation preserves command-substitution behavior in an incompletely quoted interpreter path
  • Additional condition: Existing launchers may remain affected after the package used to create them is changed, and later package installation activity may generate new affected launchers
  • Attack surface: POSIX console-script launchers generated inside Python virtual environments
  • Required access: Ability to influence the environment destination or interpreter path used during launcher generation
  • Trigger point: Execution of a previously generated affected launcher by a user or automated process
  • Why exploitation is possible: Shell wrapper generation preserves command-substitution behavior in an incompletely quoted interpreter path
  • Additional condition: Existing launchers may remain affected after the package used to create them is changed, and later package installation activity may generate new affected launchers

Why this happens

The vulnerability results from treating an interpreter path as data while generating a shell script without fully preventing shell metacharacter interpretation. When distlib falls back to a /bin/sh wrapper, double quotes do not suppress command substitutions or backticks, allowing attacker-controlled path content to be interpreted by the shell. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because data incorporated into a command-execution context is not safely escaped.

The vulnerability results from treating an interpreter path as data while generating a shell script without fully preventing shell metacharacter interpretation. When distlib falls back to a /bin/sh wrapper, double quotes do not suppress command substitutions or backticks, allowing attacker-controlled path content to be interpreted by the shell. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because data incorporated into a command-execution context is not safely escaped.

Potential impact

  • Arbitrary commands may execute with the privileges of the user running the launcher
  • User credentials, source code, or environment secrets could be exposed
  • Development or build environments could be modified
  • Automated workflows may execute attacker-controlled actions
  • Compromised environments could facilitate broader supply-chain or lateral attacks
  • Arbitrary commands may execute with the privileges of the user running the launcher
  • User credentials, source code, or environment secrets could be exposed
  • Development or build environments could be modified
  • Automated workflows may execute attacker-controlled actions
  • Compromised environments could facilitate broader supply-chain or lateral attacks

General mitigation guidance

Mitigation generally focuses on preventing untrusted path data from entering shell command contexts and ensuring generated launchers use safe execution semantics.

Common defensive patterns include:

  • Use maintained tooling that fully quotes interpreter paths or avoids shell wrappers
  • Regenerate existing launchers after applying the relevant vendor remediation
  • Treat environment destinations and interpreter paths as untrusted input
  • Prefer direct process execution over shell-mediated command construction
  • Restrict who can create or modify virtual-environment directories
  • Run build and automation jobs with least privilege and isolated credentials
  • Review package installation workflows so later pip activity cannot recreate unsafe launchers
  • Avoid executing launchers from environment directories whose ownership or contents are not trusted

Mitigation generally focuses on preventing untrusted path data from entering shell command contexts and ensuring generated launchers use safe execution semantics.

Common defensive patterns include:

  • Use maintained tooling that fully quotes interpreter paths or avoids shell wrappers
  • Regenerate existing launchers after applying the relevant vendor remediation
  • Treat environment destinations and interpreter paths as untrusted input
  • Prefer direct process execution over shell-mediated command construction
  • Restrict who can create or modify virtual-environment directories
  • Run build and automation jobs with least privilege and isolated credentials
  • Review package installation workflows so later pip activity cannot recreate unsafe launchers
  • Avoid executing launchers from environment directories whose ownership or contents are not trusted

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis of launcher-generation code for shell wrappers and incomplete quoting
  • Code review checks for interpreter paths interpolated into shell scripts
  • Repository and artifact scans for generated launchers containing command substitutions or backticks
  • File-integrity monitoring for unexpected changes in virtual-environment bin directories
  • Policy enforcement requiring trusted ownership and controlled creation of environment directories
  • CI checks that create environments using paths containing spaces and long interpreter paths, then inspect generated scripts
  • Automated code-review or software-composition tools that flag vulnerable launcher-generation components

Organizations can look for this issue through:

  • Static analysis of launcher-generation code for shell wrappers and incomplete quoting
  • Code review checks for interpreter paths interpolated into shell scripts
  • Repository and artifact scans for generated launchers containing command substitutions or backticks
  • File-integrity monitoring for unexpected changes in virtual-environment bin directories
  • Policy enforcement requiring trusted ownership and controlled creation of environment directories
  • CI checks that create environments using paths containing spaces and long interpreter paths, then inspect generated scripts
  • Automated code-review or software-composition tools that flag vulnerable launcher-generation components

Sources

SourceLink
github.comgithub.com/pypa/virtualenv/commit/2519941bed33ee0d3ac99277f67913e439e476a9
github.comgithub.com/pypa/virtualenv/pull/3417
github.comgithub.com/pypa/virtualenv/releases/tag/21.14.9
github.comgithub.com/pypa/virtualenv/security/advisories/GHSA-c978-59m8-c77v

Frequently asked

questions

Generally, no. Exploitation requires an affected launcher to be generated and subsequently executed; creating or activating the environment does not by itself trigger the command substitution.

The attacker generally needs a way to influence the environment destination or interpreter path used during launcher generation. They also need the resulting launcher to be executed by a user or automated process.

Use tooling that safely handles interpreter paths without shell interpretation, apply the relevant remediation, and regenerate launchers that were created under vulnerable conditions.

Treat filesystem paths as untrusted data, avoid constructing shell commands when direct execution is possible, enforce trusted ownership for environment directories, and test generated scripts with hostile path values.

Generally, no. Exploitation requires an affected launcher to be generated and subsequently executed; creating or activating the environment does not by itself trigger the command substitution.

The attacker generally needs a way to influence the environment destination or interpreter path used during launcher generation. They also need the resulting launcher to be executed by a user or automated process.

Use tooling that safely handles interpreter paths without shell interpretation, apply the relevant remediation, and regenerate launchers that were created under vulnerable conditions.

Treat filesystem paths as untrusted data, avoid constructing shell commands when direct execution is possible, enforce trusted ownership for environment directories, and test generated scripts with hostile path values.

Find out what's already
exploitable in your codebase.