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-113716 Overview
CVE-2026-113716 affects virtualenv, the widely used tool for creating isolated Python environments. Versions prior to 21.14.9 allow a local attacker to redirect file writes outside the requested destination directory through planted symbolic links. The builtin creator calls ensure_dir() for executable, library, and package directories, and that function accepts an existing symlink because the underlying exists() check follows it. Interpreter creation, seed installation, and activation script generation then write through the linked parent into attacker-chosen locations. The flaw is tracked under CWE-59: Improper Link Resolution Before File Access and is resolved in version 21.14.9.
Critical Impact
A local account that pre-stages symlinks in a path accessible to the invoking user can cause virtualenv to write interpreter, library, and activation files outside the intended environment directory.
Affected Products
- virtualenv versions prior to 21.14.9
- Python environments created with the builtin creator on multi-user Linux, macOS, and Windows hosts
- CI/CD runners and shared build hosts where multiple local accounts share writable paths
Discovery Timeline
- 2026-10-20 - CVE-2026-113716 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-113716
Vulnerability Analysis
The vulnerability lives in the builtin creator path of virtualenv. During environment setup, the creator invokes ensure_dir() for the executable, library, and package directories inside the target destination. ensure_dir() relies on exists(), which follows symlinks. If a prior local user placed a symlink at any of those expected paths pointing to a directory outside the destination, the creator accepts it and proceeds to write through it.
Subsequent interpreter copying, seed package installation, and activation script generation all write into the linked parent rather than the intended environment root. The attacker does not control the file contents written, so this is not an arbitrary write of attacker bytes. However, the ability to place virtualenv-generated files into attacker-selected directories can be chained for denial of service, overwriting of configuration data, or staging for further local attacks.
The --clear option removes the planted tree before creation and therefore avoids the issue; ordinary environment creation does not.
Root Cause
The root cause is unsafe link resolution during directory preparation. ensure_dir() treated an existing symlink-to-directory as a valid pre-existing destination. The function performed no containment check verifying that the resolved target remained within the requested environment root. On Windows, directory junctions produce the equivalent redirection.
Attack Vector
Exploitation requires local access and the ability to create files in a path the victim will later use as a virtualenv destination. This is realistic on shared build servers, multi-tenant developer hosts, and CI runners where multiple local principals share writable directories such as /tmp or shared project trees. No user interaction beyond the normal virtualenv invocation is needed.
# Patch excerpt: src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py
ExePathRefToDest,
RefWhen,
)
-from virtualenv.util.path import ensure_dir
+from virtualenv.util.path import ensure_within
from .builtin_way import VirtualenvBuiltin
Source: pypa/virtualenv commit 554d9f9
The fix replaces ensure_dir with ensure_within, which replaces pre-existing directory symlinks and Windows junctions in the executable and library paths before creating files, logs replaced links, and rejects non-directory entries encountered during replacement.
Detection Methods for CVE-2026-113716
Indicators of Compromise
- Symbolic links or Windows junctions found at expected virtualenv subpaths such as bin/, Scripts/, lib/, or lib/pythonX.Y/site-packages/ immediately before environment creation.
- virtualenv log entries from version 21.14.9 or later reporting replaced links or junctions during environment creation.
- Unexpected Python interpreter copies, activation scripts, or seed packages appearing outside intended environment roots on shared hosts.
Detection Strategies
- Audit shared writable directories, especially world-writable or group-writable project trees, for symlinks owned by accounts other than the invoking user.
- Instrument CI/CD pipelines to run virtualenv --version and enforce a minimum of 21.14.9 before proceeding with environment setup.
- Enable filesystem telemetry (auditd on Linux, Sysmon on Windows) to log symlink and junction creation inside directories later consumed by build jobs.
Monitoring Recommendations
- Alert on new symlinks created by one local user inside directories subsequently accessed by another user's python -m virtualenv or virtualenv process.
- Monitor process creation chains for virtualenv invocations where the destination path is under a shared or multi-user directory.
- Correlate virtualenv creation events with downstream unexpected file writes outside the declared destination path.
How to Mitigate CVE-2026-113716
Immediate Actions Required
- Upgrade virtualenv to version 21.14.9 or later across developer workstations, build servers, and container base images.
- Pin virtualenv>=21.14.9 in requirements.txt, pyproject.toml, and CI tool bootstrap scripts.
- Audit shared build hosts and CI runners for existing symlinks inside directories commonly used as virtualenv destinations.
Patch Information
The fix is published in virtualenv 21.14.9. See GitHub Release v21.14.9, Pull Request #3429, and GHSA-cw65-gx24-rc82. The patch replaces ensure_dir with ensure_within, which proactively replaces pre-existing directory symlinks and Windows junctions in executable and library paths and rejects non-directory entries during replacement.
Workarounds
- Pass the --clear flag to virtualenv, which removes any planted tree before creation.
- Create environments only in directories owned exclusively by the invoking user with mode 0700.
- Avoid creating virtual environments in world-writable paths such as /tmp or shared project roots on multi-user hosts.
# Upgrade and enforce safe invocation
python -m pip install --upgrade 'virtualenv>=21.14.9'
# Workaround for unpatched hosts: clear any pre-existing tree first
virtualenv --clear /path/to/env
# Preferred: create environments in a user-private directory
install -d -m 0700 "$HOME/.venvs"
virtualenv "$HOME/.venvs/project"
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

