CVE-2026-113718: virtualenv xonsh Activation Script Code Injection via repr() Quoting
Detects potential exploitation of CVE-2026-113718, a code injection vulnerability (CWE-94) in the Python virtualenv tool prior to 21.14.9. The POSIX xonsh activation script generator uses a quote() helper that relies on repr(), which leaves printable non-ASCII characters in the generated UTF-8 activate.xsh file. xonsh reads that file using the codec named by $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, so a Python string literal can close early and attacker-influenced statements can run when the user sources the script. The attacker must influence the prompt or destination value passed to virtualenv, and the user must later source the generated script. Affected: virtualenv >= 21.3.0, < 21.14.9. CVSS 7.1. A reproducer is included in the published advisory; the xonsh code-execution path was confirmed by maintainer review rather than rerun.
Vulnerability Intelligence
Public PoCAffected Software
- Vendor
- virtualenv
- Product
- virtualenv
- Versions
- >= 21.3.0, < 21.14.9
Weakness (CWE)
Timeline
- Disclosed
- October 20, 2026
CVSS
What is CVE-2026-113718 CVE-2026-113718: virtualenv xonsh Activation Script Code Injection via repr() Quoting?
CVE-2026-113718: virtualenv xonsh Activation Script Code Injection via repr() Quoting (CVE-2026-113718) maps to the Execution and Initial Access tactics — the adversary is trying to run malicious code or instructions on a system in MITRE ATT&CK.
This page provides production-ready detection logic for CVE-2026-113718: virtualenv xonsh Activation Script Code Injection via repr() Quoting, covering the data sources and telemetry it touches: Microsoft Defender for Endpoint, DeviceProcessEvents, DeviceFileEvents. The queries below are rated high severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.
MITRE ATT&CK
- Tactic
- Execution Initial Access
// df00tech DF00-319ab8aa8d · https://df00tech.com/detections/CVE-2026-113718 · licence: https://df00tech.com/detections/licence
// Detect creation of xonsh activation scripts and suspicious virtualenv invocations (CVE-2026-113718)
let suspiciousPaths = dynamic(["\"", "'", "$(", "`", ";", "\n", "\\x"]);
union
(
DeviceProcessEvents
| where ProcessCommandLine has_any ("virtualenv", "-m venv", "python -m virtualenv")
| where ProcessCommandLine has_any (suspiciousPaths)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, Signal="virtualenv-suspicious-path"
),
(
DeviceFileEvents
| where FileName =~ "activate.xsh"
| where ActionType == "FileCreated"
| project Timestamp, DeviceName, AccountName, FileName, FolderPath, InitiatingProcessCommandLine, Signal="activate-xsh-created"
),
(
DeviceProcessEvents
| where FileName in~ ("xonsh")
| where ProcessCommandLine has "activate.xsh"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, Signal="activate-xsh-sourced"
)
| sort by Timestamp desc Surfaces virtualenv creations into paths containing shell metacharacters, creation of activate.xsh files, and xonsh sourcing activate.xsh, the exploitation chain for CVE-2026-113718.
Data Sources
Required Tables
False Positives
- Legitimate developers creating virtualenvs in paths that happen to contain quote characters.
- CI/CD systems that routinely create and source xonsh activation scripts.
- Security researchers testing the PoC in a sandbox.
Query fingerprint DF00-319ab8aa8d · licence
Sigma logsource & community rules
The detection logic for CVE-2026-113718: virtualenv xonsh Activation Script Code Injection via repr() Quoting (CVE-2026-113718) above is provided in a vendor-neutral
form so you can deploy it on any SIEM. The same logic is shipped here as native
KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the
following logsource:
logsource:
category: process_creation
product: windows Browse the community-maintained Sigma rules for this technique:
Platform-specific guides for CVE-2026-113718
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.
- Test 1 Create virtualenv in path with embedded quote metacharacters
Expected signal: Process creation event for python3 -m virtualenv with quote metacharacters in command line; file creation event for activate.xsh.
- Test 2 Source a crafted activate.xsh in xonsh
Expected signal: xonsh process launch with activate.xsh on the command line; child process execution of injected marker.
- Test 3 Create xonsh activation script with non-ASCII path
Expected signal: File creation of activate.xsh containing repr()-written non-ASCII path values.
Response Playbook
Triage
- Confirm the installed virtualenv version on the affected host (`pip show virtualenv` / `virtualenv --version`); versions >= 21.3.0 and < 21.14.9 are vulnerable.
- Inspect the full path and prompt value used in the flagged virtualenv creation command for shell metacharacters, non-ASCII, or embedded quote/subshell sequences.
- Open the generated activate.xsh file and review the quoted variable assignments (VIRTUAL_ENV, PATH, prompt) for injected xonsh/Python code produced via repr().
- Determine whether the activate.xsh was actually sourced by a xonsh shell and by which user/service account.
Containment
- Quarantine or delete any activate.xsh created in an untrusted or metacharacter-containing path and prevent it from being sourced.
- Upgrade virtualenv to >= 21.14.9 on all affected hosts and rebuild any virtual environments created by the vulnerable version in suspicious paths.
Evidence Collection
- Preserve the activate.xsh file, the creating process command line, and the parent process tree.
- Collect xonsh shell history and any child processes spawned after activate.xsh was sourced.
Escalation Criteria
- ! Escalate to IR if sourcing activate.xsh resulted in execution of unexpected commands or outbound network connections.
- ! Escalate if the virtualenv prompt or path was influenced by externally controlled input (e.g., CI job parameters, web-facing automation).
Investigation Guide
Forensic Artifacts
- >
activate.xsh contents and modification timestamp - >
virtualenv/pip process command lines - >
xonsh shell history (~/.local/share/xonsh/history_*) - >
Parent/child process lineage around activation
Tuning Guidance
Baseline the legitimate paths where your developers and CI systems create virtualenvs; exclude known-good base directories. Tighten the metacharacter regex to the specific repr()-emitted escape patterns (\x, \u, embedded quotes) if command-line noise is high. Prioritize alerts where the virtualenv prompt or base path derives from untrusted input.
Hunting Queries
Enumerate all activate.xsh scripts and their creation context across the fleet to identify ones written to suspicious paths.
// df00tech DF00-319ab8aa8d · https://df00tech.com/detections/CVE-2026-113718 · licence: https://df00tech.com/detections/licence
DeviceFileEvents | where FileName =~ "activate.xsh" | join kind=inner (DeviceFileEvents | where FileName =~ "activate.xsh") on DeviceId | project Timestamp, DeviceName, FolderPath, InitiatingProcessCommandLine ``` df00tech DF00-319ab8aa8d · https://df00tech.com/detections/CVE-2026-113718 · licence: https://df00tech.com/detections/licence ```
index=* name="*activate.xsh" | stats count values(path) by host, user Atomic Red Team Tests
Simulates creating a virtual environment in a directory whose name contains quote characters that exercise the vulnerable repr()-based quoting in activate.xsh.
Command
mkdir -p "/tmp/poc_$(printf 'ev\x27il')" && python3 -m virtualenv "/tmp/poc_$(printf 'ev\x27il')/venv" 2>/dev/null; cat "/tmp/poc_$(printf 'ev\x27il')/venv/bin/activate.xsh" Cleanup
rm -rf "/tmp/poc_$(printf 'ev\x27il')" Expected Telemetry
Process creation event for python3 -m virtualenv with quote metacharacters in command line; file creation event for activate.xsh.
Expected Detection
kql virtualenv-suspicious-path and activate-xsh-created signals fire.
Sources an activation script in a xonsh shell to observe xonsh executing activate.xsh (where injected code would run).
Command
python3 -m pip install xonsh 2>/dev/null; echo 'echo INJECTED_MARKER' >> /tmp/venv/bin/activate.xsh 2>/dev/null; xonsh -c 'source /tmp/venv/bin/activate.xsh' 2>/dev/null Cleanup
rm -rf /tmp/venv Expected Telemetry
xonsh process launch with activate.xsh on the command line; child process execution of injected marker.
Expected Detection
activate-xsh-sourced signal fires in kql/spl/cql queries.
Creates a virtualenv in a path containing non-ASCII characters, which repr() leaves in the generated activate.xsh via the vulnerable quote() helper.
Command
mkdir -p '/tmp/poc_café' && python3 -m virtualenv '/tmp/poc_café/venv' 2>/dev/null; grep -n 'VIRTUAL_ENV' '/tmp/poc_café/venv/bin/activate.xsh' Cleanup
rm -rf '/tmp/poc_café' Expected Telemetry
File creation of activate.xsh containing repr()-written non-ASCII path values.
Expected Detection
activate-xsh-created / activate-xsh-file signals fire.
Related Detections
Tactic Hubs
Related Techniques
Same Tactic: Execution
Browse by tactic
- Reconnaissance TA0043
- Resource Development TA0042
- Initial Access TA0001
- Execution TA0002
- Persistence TA0003
- Privilege Escalation TA0004
- Stealth TA0005
- Defense Impairment TA0112
- Credential Access TA0006
- Discovery TA0007
- Lateral Movement TA0008
- Collection TA0009
- Command and Control TA0011
- Exfiltration TA0010
- Impact TA0040