CVE-2026-102925
Improper quoting in virtualenv activation scripts leads to code injection.
- CVSS 7.8
- CWE-78
- Input Validation and Sanitization
- Local
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.7.13, the generated activate (bash and zsh) and activate.fish scripts place values already escaped by shlex.quote inside an additional quoted context. In the bash and zsh script, a crafted virtual environment path reaches __VIRTUAL_ENV__ when a relocated environment's recorded directory is absent; in the fish script, crafted Tcl or Tk library paths reach __TCL_LIBRARY__ or __TK_LIBRARY__. The surplus quotes can terminate the data-only quoted run and leave shell metacharacters parsed as commands when a user sources the activation script, allowing code execution with that user's privileges. This issue is fixed in version 21.7.13.
- CWE
- CWE-78
- CVSS base score
- 7.8
- Published
- 2026-09-29
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- virtualenv
- Fixed by upgrading
- Yes
Solution
Upgrade virtualenv to version 21.7.13 or newer.
Vulnerable code sample
import shlex
def generate_activate(env_path: str) -> str:
"""
Generate a bash activate script for a virtualenv.
The path is quoted twice, leading to command injection.
"""
# VULNERABLE: double‑quoting allows injected shell metacharacters
quoted = shlex.quote(env_path)
script = f"""#!/usr/bin/env bash
# This file is auto‑generated by virtualenv
VIRTUAL_ENV='{quoted}'
export VIRTUAL_ENV
PATH="{quoted}/bin:$PATH"
export PATH
"""
return scriptPatched code sample
import shlex
def generate_activate(env_path: str) -> str:
"""
Generate a bash activate script for a virtualenv.
The path is quoted only once, preventing injection.
"""
# FIX: single quoting of a safely escaped path
quoted = shlex.quote(env_path)
script = f"""#!/usr/bin/env bash
# This file is auto‑generated by virtualenv
VIRTUAL_ENV={quoted}
export VIRTUAL_ENV
PATH={quoted}/bin:$PATH
export PATH
"""
return scriptCite this entry
@misc{vaitp:cve2026102925,
title = {{Improper quoting in virtualenv activation scripts leads to code injection.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102925},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102925/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
