Skip to content
CVE-2026-115586

CVE-2026-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value

Execution Privilege Escalation Last updated:

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.

Vulnerability Intelligence

Public PoC

CVSS

7.1
High (7.0–8.9)

What is CVE-2026-115586 CVE-2026-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value?

CVE-2026-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value (CVE-2026-115586) maps to the Execution and Privilege Escalation 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-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value, covering the data sources and telemetry it touches: Microsoft Defender for Endpoint. 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 Privilege Escalation
Microsoft Sentinel / Defender
kusto
// df00tech DF00-1029f90171 · https://df00tech.com/detections/CVE-2026-115586 · licence: https://df00tech.com/detections/licence
// CVE-2026-115586 — virtualenv bin/activate command injection
// Detects sourcing of a virtualenv activate script followed by anomalous child process execution
let activateSourcing = DeviceProcessEvents
| where Timestamp > ago(7d)
| where ProcessCommandLine has_any ("bin/activate", "source ", ". ")
| where ProcessCommandLine has "activate"
| where ProcessCommandLine matches regex @"(source|\.)\s+.*(bin/activate)"
| project Timestamp, DeviceId, DeviceName, AccountName, ActivateCmd=ProcessCommandLine, ActivatePID=ProcessId;
let suspChildren = DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessCommandLine has "activate"
| where FileName in~ ("bash","sh","dash","python","python3","curl","wget","nc","ncat","perl","ruby")
| where ProcessCommandLine has_any ("-c", "/dev/tcp", "http://", "https://", "base64", "eval")
| project Timestamp, DeviceId, DeviceName, AccountName, ChildCmd=ProcessCommandLine, ChildFile=FileName, InitiatingProcessCommandLine;
union
(suspChildren),
(DeviceProcessEvents
| where Timestamp > ago(7d)
| where ProcessCommandLine has "virtualenv" and ProcessCommandLine matches regex @"21\.14\.(9|1[0-2])\b"
| project Timestamp, DeviceId, DeviceName, AccountName, ChildCmd=ProcessCommandLine, ChildFile=FileName, InitiatingProcessCommandLine=ProcessCommandLine)
| order by Timestamp desc

Finds processes sourcing a virtualenv bin/activate script that spawn shells, interpreters, or network utilities with command-injection indicators, plus virtualenv invocations reporting a vulnerable version string.

high severity medium confidence

Data Sources

Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives

  • Legitimate developer workflows that run build or test commands immediately after activating a virtual environment
  • CI/CD runners that source activate and then invoke python/pip for packaging
  • Custom activation wrappers that call curl/wget to fetch dependencies as part of normal provisioning

Query fingerprint DF00-1029f90171 · licence

Sigma logsource & community rules

The detection logic for CVE-2026-115586: virtualenv bash bin/activate OS Command Injection via Attacker-Controlled --prompt Value (CVE-2026-115586) 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:


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 Simulate vulnerable virtualenv version invocation

    Expected signal: Process execution event containing the string 'virtualenv 21.14.11'

  2. 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

  3. 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

  1. Identify the host and user that sourced the virtualenv bin/activate script, and capture the full command line and parent process chain.
  2. 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.
  3. 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.
  4. 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

  1. Isolate the affected host from the network if a suspicious child process (reverse shell, network beacon) is confirmed.
  2. Quarantine or delete the affected virtual environment directory and revoke any credentials that may have been exposed in the developer session.

Evidence Collection

  1. Preserve the full bin/activate script, the pyvenv.cfg, the virtualenv directory, and shell history for the affected user.
  2. 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.

Hunting — KQL
kql
// 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
Hunting — SPL
spl
``` 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

Test 1 Simulate vulnerable virtualenv version invocation
linux

Runs a command string that reports a vulnerable virtualenv version to validate version-based detection logic.

Command

bash
echo "virtualenv 21.14.11 from /usr/lib/python3/dist-packages/virtualenv/__init__.py"

Cleanup

bash
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.

Test 2 Source an activate script with an injected command
linux

Creates a mock virtualenv activate script containing an injected command and sources it to simulate command injection via bin/activate.

Command

bash
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

bash
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.

Test 3 Activate then spawn reverse-shell style child
linux

Sources a mock activate script that launches a bash command with /dev/tcp to emulate a reverse shell injected via activation.

Command

bash
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

bash
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.

Related Detections

Browse by tactic

Full ATT&CK matrix Search all detections