Skip to content
CVE-2026-113723 Elastic Security · Elastic

Detect CVE-2026-113723: virtualenv Prompt Text Command Injection via bash activate Script in Elastic Security

Detects exploitation of CVE-2026-113723, an OS command injection vulnerability (CWE-78) in the pypa/virtualenv tool affecting versions >= 20.0.0 and < 21.14.9. When a virtual environment is created with a caller-supplied prompt string, that prompt text is embedded into the generated bash 'activate' script. An attacker who controls the prompt value (for example via the --prompt CLI flag or a project automation file that feeds attacker-influenced data into virtualenv creation) can inject shell syntax so that sourcing the activate script executes commands when the prompt is drawn. This detection surfaces virtualenv invocations with suspicious --prompt values, generated activate scripts containing shell command-substitution or metacharacter payloads, and the child process execution that results when such an activate script is sourced.

MITRE ATT&CK

Tactic
Execution Privilege Escalation

Elastic Detection Query

Elastic Security (Elastic)
eql
// df00tech DF00-f8328d1cdf · https://df00tech.com/detections/CVE-2026-113723 · licence: https://df00tech.com/detections/licence
process where event.type == "start" and
  (process.name in ("virtualenv", "python", "python3")) and
  process.command_line like~ "*--prompt*" and
  (process.command_line : "*$(*" or process.command_line : "*`*" or
   process.command_line : "*;*" or process.command_line : "*&&*" or
   process.command_line : "*||*")
high severity medium confidence

Elastic EQL rule matching virtualenv creation commands where the --prompt argument carries shell injection metacharacters (CVE-2026-113723).

Data Sources

Elastic Defend / Auditbeat

Required Tables

logs-endpoint.events.process-*

False Positives & Tuning

  • Cosmetic prompt strings containing special characters
  • CI systems generating dynamic prompt names
  • Deliberate PoC testing in a controlled environment

Other platforms for CVE-2026-113723


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.

  1. Test 1 virtualenv --prompt command substitution injection

    Expected signal: Process-creation event for virtualenv with a --prompt argument containing $(...), followed by a child process (touch) spawned when the activate script is sourced.

  2. Test 2 virtualenv --prompt backtick injection

    Expected signal: virtualenv process event with a backtick-containing --prompt argument and a subsequent id command execution on activation.

  3. Test 3 VIRTUAL_ENV_PROMPT environment variable injection

    Expected signal: virtualenv invocation where the --prompt value contains command substitution, plus a child touch process at activation.


Response Playbook

Triage

  1. Extract the full --prompt value from the flagged virtualenv command line and decode any shell command-substitution ($(...), backticks) or chaining (;, &&, ||, |) it contains to determine the intended injected command.
  2. Identify the source of the prompt value: was it supplied via the --prompt CLI flag or a project/automation file (e.g. tox.ini, Makefile, CI config)? Trace how attacker-influenced data reached it.
  3. Check the installed virtualenv version on the host (`virtualenv --version` or `pip show virtualenv`) and confirm whether it is in the affected range >= 20.0.0 and < 21.14.9.
  4. Locate the generated activate script (typically <venv>/bin/activate) and inspect the PS1/prompt assignment lines for injected executable syntax rather than a plain quoted string.

Containment

  1. Delete or quarantine any virtual environment whose activate script contains injected shell syntax, and prevent it from being sourced by any shell, cron job, or CI runner.
  2. Upgrade virtualenv to 21.14.9 or later across affected hosts and CI images, and block creation of new environments with the vulnerable version via package pinning.
  3. Terminate any suspicious child processes spawned when a booby-trapped activate script was sourced and isolate the host if command execution is confirmed.

Evidence Collection

  1. Preserve the complete process-creation record (command line, parent process, user, timestamp) for the virtualenv invocation and any child processes that followed activation.
  2. Copy the malicious activate script and the full virtual environment directory for forensic analysis before deletion.
  3. Collect shell history, environment variable dumps (VIRTUAL_ENV_PROMPT), and the relevant CI/automation configuration files that may have carried the attacker-controlled prompt.

Escalation Criteria

  • !Escalate to incident response if the injected prompt payload resulted in observed child-process execution (network callbacks, credential access, or persistence).
  • !Escalate if the attacker-controlled prompt value originated from a shared CI/CD pipeline or a repository many developers clone, indicating potential supply-chain scale impact.
  • !Escalate if the affected host handles sensitive data or privileged credentials given the vulnerability's high confidentiality, integrity, and availability impact.

Investigation Guide

Forensic Artifacts

  • >The generated <venv>/bin/activate script containing an unsanitized prompt assignment with shell metacharacters.
  • >Process-creation telemetry for the virtualenv invocation and subsequent child processes spawned at activation time.
  • >Shell history and VIRTUAL_ENV_PROMPT environment variable values captured from the affected session.

Tuning Guidance

Baseline the normal --prompt values used by your development teams and CI systems; many legitimately contain parentheses or project names. Allow-list known-good prompt patterns and CI-generated names to reduce noise, then focus alerting on command-substitution syntax ($(...), backticks) and command chaining (;, &&, ||) which have no legitimate purpose in a cosmetic shell prompt. Correlate with virtualenv version inventory to prioritise hosts still running < 21.14.9.


Hunting Queries

Hunts for child processes spawned shortly after a virtualenv activate script is sourced, where the command line contains command-substitution or network-download indicators suggesting injected prompt payload execution.

Hunting — KQL
kql
// df00tech DF00-f8328d1cdf · https://df00tech.com/detections/CVE-2026-113723 · licence: https://df00tech.com/detections/licence
DeviceProcessEvents | where Timestamp > ago(90d) | where ProcessCommandLine has "activate" and InitiatingProcessCommandLine has_any ("source", ". ") | where ProcessCommandLine has_any ("$(", "`", "curl", "wget", "bash -c") | project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessCommandLine
Hunting — SPL
spl
``` df00tech DF00-f8328d1cdf · https://df00tech.com/detections/CVE-2026-113723 · licence: https://df00tech.com/detections/licence ```
index=* (sourcetype="linux:process") (process="*activate*" OR parent_process="*activate*") (process="*$(*" OR process="*`*" OR process="*curl*" OR process="*wget*" OR process="*bash -c*") | table _time, host, user, process, parent_process

Atomic Red Team Tests

Test 1 virtualenv --prompt command substitution injection
linux

Creates a virtual environment with a --prompt value containing shell command substitution to demonstrate injection into the generated activate script.

Command

bash
virtualenv --prompt '$(touch /tmp/cve_2026_113723_poc)' /tmp/vuln_venv && . /tmp/vuln_venv/bin/activate

Cleanup

bash
deactivate 2>/dev/null; rm -rf /tmp/vuln_venv /tmp/cve_2026_113723_poc

Expected Telemetry

Process-creation event for virtualenv with a --prompt argument containing $(...), followed by a child process (touch) spawned when the activate script is sourced.

Expected Detection

The KQL/SPL rules flag the virtualenv --prompt invocation containing command-substitution syntax.

Test 2 virtualenv --prompt backtick injection
linux

Uses backtick command substitution in the --prompt value to inject a command into the bash activate script.

Command

bash
virtualenv --prompt '`id > /tmp/cve_2026_113723_id`' /tmp/vuln_venv2 && . /tmp/vuln_venv2/bin/activate

Cleanup

bash
deactivate 2>/dev/null; rm -rf /tmp/vuln_venv2 /tmp/cve_2026_113723_id

Expected Telemetry

virtualenv process event with a backtick-containing --prompt argument and a subsequent id command execution on activation.

Expected Detection

Detection rules match the backtick metacharacter in the --prompt value.

Test 3 VIRTUAL_ENV_PROMPT environment variable injection
macos

Supplies the malicious prompt via an environment variable that is then passed to the --prompt flag, to simulate automation-driven exploitation.

Command

bash
VIRTUAL_ENV_PROMPT='$(touch /tmp/cve_2026_113723_env)' virtualenv --prompt "$VIRTUAL_ENV_PROMPT" /tmp/vuln_venv3 && . /tmp/vuln_venv3/bin/activate

Cleanup

bash
deactivate 2>/dev/null; rm -rf /tmp/vuln_venv3 /tmp/cve_2026_113723_env

Expected Telemetry

virtualenv invocation where the --prompt value contains command substitution, plus a child touch process at activation.

Expected Detection

Rules flag the command-substitution syntax passed through to the --prompt argument.

Related Detections