Detect CVE-2026-113720: virtualenv app-data Copy Seeder Insecure Cached Package File Permissions (CWE-732) in Elastic Security
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
Elastic Detection Query
// df00tech DF00-7f1da49b28 · https://df00tech.com/detections/CVE-2026-113720 · licence: https://df00tech.com/detections/licence
sequence by host.id with maxspan=10m
[ process where process.name in ("python", "python3", "virtualenv") and process.command_line like~ "*virtualenv*" ]
[ file where file.path like~ "*/.local/share/virtualenv/*" and file.path like~ ("*wheel*", "*.whl", "*pip*", "*app-data*") ] Correlates a virtualenv process invocation with subsequent file creation under the app-data cache, the code path affected by CVE-2026-113720.
Data Sources
Required Tables
False Positives & Tuning
- Routine CI pipelines creating virtualenvs on build agents
- Patched virtualenv installations
- tox/nox automated environment rebuilds
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.
- 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.
- 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.
- Test 3 Detect world-readable/writable cached package files
Expected signal: Filesystem read/stat activity enumerating cache file permissions.
Response Playbook
Triage
- 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.
- 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.
- 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.
- 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
- Upgrade virtualenv to 21.14.9 or later on all affected hosts (`pip install --upgrade 'virtualenv>=21.14.9'`).
- 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.
- 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
- 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.
- Collect virtualenv/pip version information and the modification timestamps of cached wheels to establish whether tampering preceded environment creation.
- 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.
// 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 ``` 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
Install a virtualenv version within the affected range to reproduce the vulnerable copy-seeder behavior in a lab.
Command
python3 -m pip install 'virtualenv==20.25.0' && python3 -m virtualenv --version Cleanup
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.
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
python3 -m virtualenv --copies /tmp/argus-venv-test && ls -la ~/.local/share/virtualenv/wheel/*/image/*/*/ 2>/dev/null Cleanup
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.
Inspect the app-data cache for files with overly permissive permissions representing the CVE-2026-113720 condition.
Command
find ~/.local/share/virtualenv -type f \( -perm -0002 -o -perm -0004 \) -ls 2>/dev/null Cleanup
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.