Skip to content
CVE-2026-113720 Microsoft Sentinel · KQL

Detect CVE-2026-113720: virtualenv app-data Copy Seeder Insecure Cached Package File Permissions (CWE-732) in Microsoft Sentinel

Detects the presence and exploitation potential of CVE-2026-113720, an incorrect-permission-assignment (CWE-732) flaw in the pypa virtualenv app-data copy seeder. Prior to version 21.14.9, the copy seeder uses shutil.copy() to copy cached wheel/package files from the user's app-data cache into newly created virtual environments. shutil.copy() preserves the source file's mode bits instead of applying the current umask, so a cache populated under a permissive umask can produce environment files writable by another local account, letting that account modify cached package code such as pip/__init__.py and have it run as the environment owner. This detection surfaces vulnerable virtualenv installations, creation of virtual environments by affected versions, and world-writable/world-readable files appearing under the virtualenv app-data directory (~/.local/share/virtualenv or the platform appdata path).

Based on GHSA-fc2g-4w5p-6whm, virtualenv app-data copy seeder insecure permissions

MITRE ATT&CK

Tactic
Privilege Escalation Initial Access

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
// df00tech DF00-7f1da49b28 · https://df00tech.com/detections/CVE-2026-113720 · licence: https://df00tech.com/detections/licence
// Detect vulnerable virtualenv versions and world-writable app-data cache files on monitored hosts
let VulnFloor = "20.0.0";
let FixedVersion = "21.14.9";
union isfuzzy=true
(
    DeviceProcessEvents
    | where FileName in~ ("python", "python3", "virtualenv", "pip", "pip3")
    | where ProcessCommandLine has_any ("virtualenv", "-m virtualenv")
    | where ProcessCommandLine has_any ("--copies", "--always-copy", "copies") or ProcessCommandLine has "virtualenv"
    | project Timestamp, DeviceId, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessAccountName
    | extend Signal = "virtualenv-invocation"
),
(
    DeviceFileEvents
    | where FolderPath has_any ("/.local/share/virtualenv", "\\virtualenv\\", "/Library/Application Support/virtualenv")
    | where FolderPath has_any ("wheel", "pip", "setuptools", "app-data", ".whl")
    | project Timestamp, DeviceId, DeviceName, AccountName, FolderPath, FileName, ActionType, InitiatingProcessCommandLine
    | extend Signal = "virtualenv-appdata-file"
)
| order by Timestamp desc
high severity medium confidence

Surfaces virtualenv environment-creation invocations and file writes under the virtualenv app-data cache directory where CVE-2026-113720 (insecure copy-seeder permissions) manifests. Correlate with inventory of installed virtualenv versions < 21.14.9.

Data Sources

Microsoft Defender for EndpointDeviceProcessEventsDeviceFileEvents

Required Tables

DeviceProcessEventsDeviceFileEvents

False Positives & Tuning

  • Legitimate CI/CD or developer workflows that create virtualenvs with --copies on single-user build agents
  • Patched virtualenv (>= 21.14.9) still writing to the app-data cache with corrected permissions
  • Automated tooling (tox, nox, pre-commit) that rebuilds virtual environments frequently

Other platforms for CVE-2026-113720


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 Install affected virtualenv version

    Expected signal: Process creation events for pip install and virtualenv version check; package metadata showing virtualenv 20.25.0.

  2. Test 2 Create virtualenv with copy seeder populating app-data cache

    Expected signal: File creation events under ~/.local/share/virtualenv and /tmp/argus-venv-test; virtualenv process launch.

  3. Test 3 Detect world-readable/writable cached package files

    Expected signal: Filesystem read/stat activity enumerating cache file permissions.


Response Playbook

Triage

  1. Identify the installed virtualenv version on the affected host(s): run `python -m virtualenv --version` or `pip show virtualenv`; confirm whether it falls in the affected range >= 20.0.0 and < 21.14.9.
  2. Enumerate the virtualenv app-data cache directory (typically ~/.local/share/virtualenv on Linux, %LOCALAPPDATA%\virtualenv on Windows, ~/Library/Application Support/virtualenv on macOS) and inspect permissions of cached wheel/package files for world-readable or world-writable bits.
  3. Determine whether the host is multi-user or shared (CI runner, jump host, build server); single-user developer machines carry materially lower risk than shared systems.
  4. Review whether any virtual environments were seeded from the cache by other users and whether cached package files could have been modified by an unprivileged local account.

Containment

  1. Upgrade virtualenv to 21.14.9 or later on all affected hosts (`pip install --upgrade 'virtualenv>=21.14.9'`).
  2. Tighten permissions on the existing app-data cache directory and its contents (e.g. `chmod -R go-rwx ~/.local/share/virtualenv`) and recreate any virtual environments that were seeded from a potentially tampered cache.
  3. On shared/multi-user hosts, restrict the app-data location to per-user paths and audit who can write to shared cache directories.

Evidence Collection

  1. Capture the output of `ls -la` (or `icacls`) for the app-data cache directory and all cached package files, recording owner, group and mode bits.
  2. Collect virtualenv/pip version information and the modification timestamps of cached wheels to establish whether tampering preceded environment creation.
  3. Preserve process creation and file write telemetry (EDR) showing virtualenv invocations and cache file writes for the investigation window.

Escalation Criteria

  • !Escalate if cached package files on a shared/multi-user host are found world-writable AND were modified by an account other than the cache owner, indicating possible package tampering.
  • !Escalate if any virtual environment seeded from the affected cache was subsequently used to run privileged or service processes, raising the likelihood of local privilege escalation or code execution.

Investigation Guide

Forensic Artifacts

  • >Permission/mode bits and ownership of files under the virtualenv app-data cache directory
  • >Modification timestamps of cached .whl/package files vs. the time virtual environments were created
  • >virtualenv/pip version metadata (dist-info, RECORD files) in seeded environments

Tuning Guidance

Scope the file-event portion to shared or multi-user hosts (CI runners, jump boxes, build servers) to reduce noise from single-user developer laptops, where permissive cache permissions carry minimal cross-user risk. Suppress hosts confirmed to be running virtualenv >= 21.14.9. Prioritize alerts where the file owner differs from the account that created the environment.


Hunting Queries

Enumerate cached virtualenv wheel files and their permissions across the fleet to locate world-writable caches.

Hunting — KQL
kql
// df00tech DF00-7f1da49b28 · https://df00tech.com/detections/CVE-2026-113720 · licence: https://df00tech.com/detections/licence
DeviceFileEvents | where FolderPath has "/.local/share/virtualenv" and FileName endswith ".whl" | summarize count() by DeviceName, AccountName, FolderPath
Hunting — SPL
spl
``` df00tech DF00-7f1da49b28 · https://df00tech.com/detections/CVE-2026-113720 · licence: https://df00tech.com/detections/licence ```
sourcetype=osquery:results path="*/.local/share/virtualenv/*" | stats values(file_mode) as modes by host, path

Atomic Red Team Tests

Test 1 Install affected virtualenv version
linux

Install a virtualenv version within the affected range to reproduce the vulnerable copy-seeder behavior in a lab.

Command

bash
python3 -m pip install 'virtualenv==20.25.0' && python3 -m virtualenv --version

Cleanup

bash
python3 -m pip install --upgrade 'virtualenv>=21.14.9'

Expected Telemetry

Process creation events for pip install and virtualenv version check; package metadata showing virtualenv 20.25.0.

Expected Detection

Inventory/version check flags virtualenv in affected range >= 20.0.0 and < 21.14.9.

Test 2 Create virtualenv with copy seeder populating app-data cache
linux

Create a virtual environment using the copy seeder, which populates the app-data cache via shutil.copy() and seeds wheels into the new environment.

Command

bash
python3 -m virtualenv --copies /tmp/argus-venv-test && ls -la ~/.local/share/virtualenv/wheel/*/image/*/*/ 2>/dev/null

Cleanup

bash
rm -rf /tmp/argus-venv-test

Expected Telemetry

File creation events under ~/.local/share/virtualenv and /tmp/argus-venv-test; virtualenv process launch.

Expected Detection

virtualenv invocation and app-data cache file-write signals fire; permission inspection reveals seeder-created files.

Test 3 Detect world-readable/writable cached package files
linux

Inspect the app-data cache for files with overly permissive permissions representing the CVE-2026-113720 condition.

Command

bash
find ~/.local/share/virtualenv -type f \( -perm -0002 -o -perm -0004 \) -ls 2>/dev/null

Cleanup

bash
chmod -R go-rwx ~/.local/share/virtualenv 2>/dev/null || true

Expected Telemetry

Filesystem read/stat activity enumerating cache file permissions.

Expected Detection

World-writable/world-readable cache files flagged by the file-permission portion of the detection.

Related Detections