CVE-2026-113722
Improper quoting in virtualenv scripts allows command injection via crafted interpreter paths.
- CVSS 7.8
- CWE-78
- Input Validation and Sanitization
- Local
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, virtualenv's ScriptMakerCustom and pip pass an incompletely quoted interpreter path to distlib ScriptMaker when generating POSIX console scripts. When the path contains a space or produces a shebang longer than 127 bytes, distlib emits a /bin/sh wrapper whose double-quoted interpreter path still expands command substitutions and backticks. An attacker who influences the environment destination can therefore execute commands with the user's privileges when the user later runs a generated launcher; environment creation and activation do not trigger the command. Existing launchers are not repaired by upgrading virtualenv alone and must be regenerated, while a later independent pip installation or upgrade can reintroduce an affected launcher because pip's vendored distlib is unchanged. The virtualenv fix is released in version 21.14.9.
- CWE
- CWE-78
- CVSS base score
- 7.8
- Published
- 2026-10-20
- OWASP
- A03 Injection
- Orthogonal defect classification
- Build/Package/Merge
- Code defect classification
- Building Issues
- 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 ≥ 21.14.9.
Vulnerable code sample
import os
from distlib.scripts import ScriptMaker
def create_launcher(dest_dir, interpreter_path):
"""
Generate a console script wrapper in ``dest_dir`` using ``interpreter_path``.
"""
# VULNERABLE: interpreter_path is inserted without proper quoting
maker = ScriptMaker(dest_dir, interpreter=interpreter_path)
maker.make_script('mycmd', 'my_pkg.cli:main')Patched code sample
import os
import shlex
from distlib.scripts import ScriptMaker
def create_launcher(dest_dir, interpreter_path):
"""
Generate a console script wrapper in ``dest_dir`` using ``interpreter_path``.
"""
# FIX: properly quote interpreter_path to prevent command injection
safe_interp = shlex.quote(interpreter_path)
maker = ScriptMaker(dest_dir, interpreter=safe_interp)
maker.make_script('mycmd', 'my_pkg.cli:main')Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- 🐛 fix(seed): preserve interpreter paths in console scripts (#3417) (pypa/virtualenv)
src/virtualenv/seed/embed/pip_invoke.py,src/virtualenv/seed/embed/pip_invoke.py · PipInvoke.run,src/virtualenv/seed/embed/via_app_data/pip_install/base.py,src/virtualenv/seed/embed/via_app_data/pip_install/base.py · ScriptMakerCustom.__init__
Cite this entry
@misc{vaitp:cve2026113722,
title = {{Improper quoting in virtualenv scripts allows command injection via crafted interpreter paths.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113722},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113722/}}
}
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 ::
