Skip to main content
Vulnerability Database/CVE-2026-113720

CVE-2026-113720: virtualenv Privilege Escalation Vulnerability

CVE-2026-113720 is a privilege escalation vulnerability in virtualenv that allows local attackers to modify package files through improper file permissions. This post covers technical details, affected versions, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-113720 Overview

CVE-2026-113720 affects virtualenv, a widely used tool for creating isolated Python environments. Versions prior to 21.14.9 contain an insecure permission inheritance flaw in the app-data copy seeder. The seeder uses shutil.copy() to transfer cached package files into new environments, which preserves the source file modes rather than applying the current process umask. When the cache is populated under a permissive umask, later environments created in a traversable path can expose Python package files such as pip/__init__.py to other local users. A second local account that is writable on those files can modify package code that the environment owner subsequently executes. The weakness is categorized as [CWE-732: Incorrect Permission Assignment for Critical Resource].

Critical Impact

A local attacker with write access to over-permissive cached files can modify Python package code and achieve code execution in the context of the virtualenv owner.

Affected Products

  • virtualenv versions prior to 21.14.9
  • Python environments seeded via the app-data copy seeder
  • Multi-user systems where virtualenv caches are shared or traversable

Discovery Timeline

  • 2026-10-20 - CVE-2026-113720 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-113720

Vulnerability Analysis

The app-data copy seeder in virtualenv populates new environments by copying previously cached interpreter and seed-package files. The copy routine in src/virtualenv/util/path/_sync.py relied on shutil.copy(), which preserves source file modes. The current process umask is not applied during this operation. If an earlier virtualenv run populated the cache under a permissive umask such as 0000 or 0002, the cached files retain group- or world-writable bits.

Any later environment seeded from that cache inherits those permissive modes. On systems where the destination parent directory is traversable by other local users, a second account can overwrite files such as pip/__init__.py. The environment owner then executes attacker-controlled code the next time they invoke pip or an affected package.

Root Cause

The root cause is the use of shutil.copy() for seeded file placement without masking inherited mode bits. The function copies source file permissions verbatim, bypassing the protective effect of the current umask. The design assumed cached modes were trusted, but the cache can be populated by any prior run under any umask.

Attack Vector

Exploitation is local and requires several preconditions. An earlier virtualenv invocation must have populated the app-data cache under a permissive umask. The destination parent directory of the later environment must be traversable by the attacking local account. The attacker cannot force the earlier umask and cannot act when the destination parent denies traversal. Given these constraints, user interaction and specific environmental conditions are required for a successful attack.

python
 import os
 import shutil
 import sys
-from stat import S_IWUSR
-from typing import TYPE_CHECKING
+from pathlib import Path
+from stat import S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR
+from typing import TYPE_CHECKING, Final
 
 if TYPE_CHECKING:
     from collections.abc import Callable
-    from pathlib import Path
     from types import TracebackType
 
     _ExcInfo = BaseException | tuple[type[BaseException], BaseException, TracebackType]

Source: GitHub Commit 35f0b33

Detection Methods for CVE-2026-113720

Indicators of Compromise

  • Files inside a virtualenv environment with group- or world-writable mode bits, especially within site-packages/pip/ and other seeded packages.
  • Modification timestamps on pip/__init__.py or other seed package files that do not match the environment creation time.
  • Shared or traversable virtualenv app-data cache directories (default under ~/.local/share/virtualenv/ on Linux) populated under a loose umask.

Detection Strategies

  • Audit installed virtualenv versions across build hosts and developer workstations; flag any instance below 21.14.9.
  • Scan Python environments for seeded files whose permission bits exceed 0644 for data files or 0755 for executables.
  • Review process execution telemetry for unexpected writes to files inside site-packages by accounts other than the environment owner.

Monitoring Recommendations

  • Monitor file integrity on virtualenv-managed site-packages directories on shared and multi-tenant hosts.
  • Alert on cross-user write events targeting Python package files, which can indicate seeded-file tampering.
  • Track virtualenv package upgrades in CI/CD and developer tooling inventories to confirm remediation coverage.

How to Mitigate CVE-2026-113720

Immediate Actions Required

  • Upgrade virtualenv to version 21.14.9 or later across all build systems, CI/CD runners, container images, and developer workstations.
  • Purge existing app-data caches populated by vulnerable versions, for example by removing the virtualenv cache directory and recreating environments.
  • Review file permissions on existing shared Python environments and tighten any seeded files that are group- or world-writable.

Patch Information

The fix is implemented in GitHub Pull Request #3425 and shipped in GitHub Release 21.14.9. The patch stops preserving source modes during seeded copies. Data files start from 0644 and executable files from 0755 before the current umask is applied. Full details are available in GitHub Security Advisory GHSA-fc2g-4w5p-6whm.

Workarounds

  • Set a restrictive umask such as 0077 before invoking virtualenv so cached files are not group- or world-accessible.
  • Create virtual environments under directories whose parents deny traversal to other local accounts, which blocks cross-user access.
  • Avoid sharing the virtualenv app-data cache across users on multi-tenant systems; isolate caches per account.
bash
# Upgrade virtualenv and reset the shared app-data cache
python -m pip install --upgrade 'virtualenv>=21.14.9'

# Remove caches populated by vulnerable versions (Linux default path)
rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/virtualenv"

# Harden umask before creating new environments
umask 0077
virtualenv /path/to/project/.venv

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.