CVE-2026-113723
Bash injection via crafted virtualenv prompt before activation (fixed in 21.14.9).
- CVSS 7.1
- CWE-78
- Input Validation and Sanitization
- Local
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, caller-supplied prompt text can become executable syntax in the bash activation prompt. An attacker must influence the value passed to virtualenv, and a user must subsequently activate the environment and draw the prompt. This vulnerability is fixed in 21.14.9.
- CWE
- CWE-78
- CVSS base score
- 7.1
- Published
- 2026-10-20
- 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.14.9 or later.
Vulnerable code sample
import os
import subprocess
def create_virtualenv(path: str, prompt: str):
"""
Create a virtualenv at ``path`` and write a Bash activation script
that sets the prompt using the user‑supplied ``prompt``.
"""
# Create the directory structure (simplified)
os.makedirs(os.path.join(path, "bin"), exist_ok=True)
# VULNERABLE: user‑controlled prompt is interpolated into Bash code without sanitization
activate_script = f"""#!/usr/bin/env bash
# This file is generated by virtualenv
VIRTUAL_ENV="{path}"
export VIRTUAL_ENV
# Set prompt
export PS1="({prompt}) $PS1"
"""
activate_path = os.path.join(path, "bin", "activate")
with open(activate_path, "w", encoding="utf-8") as f:
f.write(activate_script)
os.chmod(activate_path, 0o755)
# Simulate virtualenv's post‑creation steps
subprocess.run([activate_path], shell=True, check=False)Patched code sample
import os
import subprocess
import shlex
def create_virtualenv(path: str, prompt: str):
"""
Create a virtualenv at ``path`` and write a Bash activation script
that sets the prompt using the user‑supplied ``prompt``.
"""
# Create the directory structure (simplified)
os.makedirs(os.path.join(path, "bin"), exist_ok=True)
# FIX: escape the prompt to prevent injection in the generated Bash code
safe_prompt = shlex.quote(prompt)
activate_script = f"""#!/usr/bin/env bash
# This file is generated by virtualenv
VIRTUAL_ENV="{path}"
export VIRTUAL_ENV
# Set prompt
export PS1=({safe_prompt})\\ $PS1
"""
activate_path = os.path.join(path, "bin", "activate")
with open(activate_path, "w", encoding="utf-8") as f:
f.write(activate_script)
os.chmod(activate_path, 0o755)
# Simulate virtualenv's post‑creation steps
subprocess.run([activate_path], shell=True, check=False)Cite this entry
@misc{vaitp:cve2026113723,
title = {{Bash injection via crafted virtualenv prompt before activation (fixed in 21.14.9).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113723},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113723/}}
}
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 ::
