CVE-2026-113718
UTF-8 trail byte exploits xonsh activation script to run attacker code.
- CVSS 7.1
- CWE-94
- Input Validation and Sanitization
- Local
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, POSIX xonsh activation quote() uses repr() to write printable non-ASCII prompt or destination data into UTF-8 activate.xsh, while xonsh can read that script using $XONSH_ENCODING. Under a legacy multibyte codec such as GBK or Big5, a UTF-8 trail byte can consume the backslash before an adjacent quote, allowing the literal to close and attacker-influenced statements to execute when the user sources the generated script. This issue is fixed in version 21.14.9.
- CWE
- CWE-94
- CVSS base score
- 7.1
- Published
- 2026-10-20
- OWASP
- A03 Injection
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- 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 newer.
Vulnerable code sample
import os
def write_activate_xsh(prompt: str, destination: str):
"""
Generate a xonsh activation script that sets the prompt.
"""
# VULNERABLE: using repr() allows crafted Unicode to break quoting under multibyte encodings
line = f'export PROMPT={repr(prompt)}\n'
with open(os.path.join(destination, "activate.xsh"), "w", encoding="utf-8") as f:
f.write(line)Patched code sample
import os
def write_activate_xsh(prompt: str, destination: str):
"""
Generate a xonsh activation script that sets the prompt.
"""
# FIX: use unicode_escape to safely encode non‑ASCII characters
escaped = prompt.encode("unicode_escape").decode("ascii")
line = f'export PROMPT={escaped}\n'
with open(os.path.join(destination, "activate.xsh"), "w", encoding="utf-8") as f:
f.write(line)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(xonsh): preserve literals across source encodings (#3432) (pypa/virtualenv)
src/virtualenv/activation/xonsh/__init__.py · XonshActivator.quote
Cite this entry
@misc{vaitp:cve2026113718,
title = {{UTF-8 trail byte exploits xonsh activation script to run attacker code.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113718},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113718/}}
}
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 ::
