Detect CVE-2026-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value in Elastic Security
Detects activity related to CVE-2026-115586, a CWE-78 OS command injection in the pypa virtualenv tool (versions >= 21.14.9 and < 21.14.13). In affected versions the bash bin/activate script copies an attacker-controlled --prompt value into PS1 without escaping dollar signs or backticks when both promptvars and POSIX mode are disabled at activation. Re-enabling promptvars, running set -o posix, or starting an interactive child bash that inherits the exported PS1 then expands the stored value and runs commands as the user who activated the environment. The --prompt value may come from project metadata the user did not write. Detection focuses on virtualenv creation by vulnerable package versions, sourcing of bin/activate scripts, and child process spawning (shell, interpreter, or network tooling) linked to an activate script. CVSS 7.1. Exploit status: public PoC available.
MITRE ATT&CK
- Tactic
- Execution Privilege Escalation
Elastic Detection Query
// df00tech DF00-1029f90171 · https://df00tech.com/detections/CVE-2026-115586 · licence: https://df00tech.com/detections/licence
sequence by host.id with maxspan=30s
[ process where event.type == "start" and
process.command_line regex~ """.*(source|\.)\s+.*bin/activate.*""" ]
[ process where event.type == "start" and
process.name in ("bash","sh","dash","python","python3","curl","wget","nc","ncat","perl","ruby") and
process.command_line : ("*-c*","*/dev/tcp*","*base64*","*eval*","*http://*","*https://*") ] Correlates a process sourcing a virtualenv bin/activate script with an immediate suspicious child interpreter or network command on the same host.
Data Sources
Required Tables
False Positives & Tuning
- Build commands launched automatically post-activation
- CI runners invoking python after sourcing activate
- Legitimate dependency fetches via curl/wget following activation
Other platforms for CVE-2026-115586
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 Simulate vulnerable virtualenv version invocation
Expected signal: Process execution event containing the string 'virtualenv 21.14.11'
- Test 2 Source an activate script with an injected command
Expected signal: Process event for the source of bin/activate followed by a curl child process within seconds
- Test 3 Activate then spawn reverse-shell style child
Expected signal: Activate source event with a child bash -c process referencing /dev/tcp
Response Playbook
Triage
- Identify the host and user that sourced the virtualenv bin/activate script, and capture the full command line and parent process chain.
- Determine the installed virtualenv version on the host (pip show virtualenv) and confirm whether it falls within the affected range >= 21.14.9 and < 21.14.13.
- Inspect the bin/activate script and the VIRTUAL_ENV_PROMPT value (and pyvenv.cfg) of the referenced environment for a --prompt value containing command substitution, backticks, or a backslash to confirm whether a malicious prompt was stored.
- Correlate the timestamp with any suspicious child processes (shells, interpreters, curl/wget, netcat) spawned within seconds of activation or of a later prompt redraw.
Containment
- Isolate the affected host from the network if a suspicious child process (reverse shell, network beacon) is confirmed.
- Quarantine or delete the affected virtual environment directory and revoke any credentials that may have been exposed in the developer session.
Evidence Collection
- Preserve the full bin/activate script, the pyvenv.cfg, the virtualenv directory, and shell history for the affected user.
- Capture process execution logs (auditd/EDR) for the parent activate process and all descendants, including command lines and network connections.
Escalation Criteria
- !Escalate to incident response if a malicious --prompt value executed, or if outbound C2 / reverse-shell activity is observed.
- !Escalate if the affected account has elevated privileges or access to source repositories / build infrastructure, indicating potential supply-chain impact.
Investigation Guide
Forensic Artifacts
- >
The bin/activate bash script and the stored VIRTUAL_ENV_PROMPT value within the virtual environment directory - >
Shell history (~/.bash_history) showing the source/activation command - >
auditd/EDR process ancestry records linking activation to child command execution
Tuning Guidance
Baseline the normal developer and CI activation patterns on build/dev hosts, then suppress known-good post-activation commands (pip, python test runners, build tools). Prioritize alerts where the activate parent spawns network utilities or decodes/eval content, and where the host runs a confirmed vulnerable virtualenv version (21.14.9-21.14.12). Exclude dedicated CI runner hosts from the broad activate-sourcing signal while keeping the suspicious-child correlation enabled everywhere.
Hunting Queries
Hunts for virtualenv activate sourcing events that are closely followed by shell or network utility execution, indicating possible command injection.
// df00tech DF00-1029f90171 · https://df00tech.com/detections/CVE-2026-115586 · licence: https://df00tech.com/detections/licence
DeviceProcessEvents | where ProcessCommandLine has "bin/activate" | join kind=inner (DeviceProcessEvents | where FileName in~ ("bash","sh","curl","wget","nc")) on $left.ProcessId == $right.InitiatingProcessId | project Timestamp, DeviceName, AccountName, ActivateCmd=ProcessCommandLine, ChildCmd=ProcessCommandLine1 ``` df00tech DF00-1029f90171 · https://df00tech.com/detections/CVE-2026-115586 · licence: https://df00tech.com/detections/licence ```
index=* (cmd="*bin/activate*") | transaction host maxspan=30s | search cmd="*/dev/tcp*" OR cmd="*base64*" OR cmd="*curl *" | table _time host user cmd Atomic Red Team Tests
Runs a command string that reports a vulnerable virtualenv version to validate version-based detection logic.
Command
echo "virtualenv 21.14.11 from /usr/lib/python3/dist-packages/virtualenv/__init__.py" Cleanup
echo 'no cleanup required' Expected Telemetry
Process execution event containing the string 'virtualenv 21.14.11'
Expected Detection
Version-string branch of the detection matches the vulnerable range 21.14.9-21.14.12.
Creates a mock virtualenv activate script containing an injected command and sources it to simulate command injection via bin/activate.
Command
mkdir -p /tmp/cve115586/bin && printf '#!/bin/bash\nVIRTUAL_ENV=/tmp/cve115586\ncurl -s http://127.0.0.1:8080/x >/dev/null 2>&1\n' > /tmp/cve115586/bin/activate && source /tmp/cve115586/bin/activate Cleanup
rm -rf /tmp/cve115586 Expected Telemetry
Process event for the source of bin/activate followed by a curl child process within seconds
Expected Detection
Activate-sourcing plus suspicious-child (curl) correlation fires.
Sources a mock activate script that launches a bash command with /dev/tcp to emulate a reverse shell injected via activation.
Command
mkdir -p /tmp/cve115586b/bin && printf '#!/bin/bash\nbash -c ":>/dev/tcp/127.0.0.1/4444" 2>/dev/null\n' > /tmp/cve115586b/bin/activate && source /tmp/cve115586b/bin/activate Cleanup
rm -rf /tmp/cve115586b Expected Telemetry
Activate source event with a child bash -c process referencing /dev/tcp
Expected Detection
Suspicious-child branch matches on /dev/tcp descending from an activate parent.