VAITP Dataset

← Back to the dataset

CVE-2026-113716

Symlink traversal in virtualenv allows writing outside target directory.

  • CVSS 4.5
  • CWE-59
  • Input Validation and Sanitization
  • Local

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, the builtin creator calls ensure_dir() for executable, library, and package directories, and ensure_dir() accepts an existing symlink to a directory because exists() follows it. Interpreter creation, seed installation, and activation generation then write through the linked parent outside the requested destination when another local account prepared the tree and the invoking user can access the target. The –clear option removes the planted tree first, while ordinary creation reaches it; arbitrary attacker-selected output bytes are not established. This issue is fixed in version 21.14.9.

CVSS base score
4.5
Published
2026-10-20
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Local
Impact
Unauthorized Access
Affected component
virtualenv
Fixed by upgrading
Yes

Solution

Upgrade virtualenv to version 21.14.9 or later.

Vulnerable code sample

import os
from pathlib import Path

def ensure_dir(p: Path):
    # VULNERABLE: follows symlink, allowing directory traversal
    os.makedirs(p, exist_ok=True)

def create_virtualenv(env_dir: str):
    root = Path(env_dir)
    # create standard subdirs
    for sub in ("bin", "lib", "lib/python3.11/site-packages"):
        ensure_dir(root / sub)
    # seed activation script (simplified)
    (root / "bin" / "activate").write_text("# activation script")

Patched code sample

import os
from pathlib import Path

def ensure_dir(p: Path):
    # FIX: reject existing symlinks to directories
    if p.is_symlink():
        raise OSError(f"Refusing to create directory over symlink: {p}")
    os.makedirs(p, exist_ok=True)

def create_virtualenv(env_dir: str):
    root = Path(env_dir)
    for sub in ("bin", "lib", "lib/python3.11/site-packages"):
        ensure_dir(root / sub)
    (root / "bin" / "activate").write_text("# activation script")

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • 🐛 fix(create): replace linked output directories (#3429) (pypa/virtualenv)
    src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py, src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py · ViaGlobalRefVirtualenvBuiltin.create, src/virtualenv/create/via_global_ref/venv.py, src/virtualenv/create/via_global_ref/venv.py · Venv.create

Cite this entry

@misc{vaitp:cve2026113716,
  title        = {{Symlink traversal in virtualenv allows writing outside target directory.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-113716},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113716/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.