VAITP Dataset

← Back to the dataset

CVE-2026-113721

Symlink race allows overwriting files outside the virtualenv during creation.

  • 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, ViaTemplateActivator._generate() removes an existing output only when Path.exists() is true, allowing a dangling symlink to survive and redirect generated activation content, while PyEnvCfg.write() opens pyvenv.cfg without first replacing an existing symbolic or hard link. Another local account that prepares final entries inside the destination can therefore cause environment creation to create or overwrite files outside the requested tree with constrained virtualenv-generated content and the invoking user's permissions. The destination parent must remain controlled by the environment owner during creation; concurrent parent-directory replacement is a separate concern. This issue is fixed in version 21.14.9.

CVSS base score
4.5
Published
2026-10-20
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Assignment
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Local
Impact
Privilege Escalation
Affected component
virtualenv
Fixed by upgrading
Yes

Solution

Upgrade virtualenv to version 21.14.9 or later.

Vulnerable code sample

import pathlib

class ViaTemplateActivator:
    def _generate(self, dest: pathlib.Path, content: str) -> None:
        # VULNERABLE: does not remove dangling symlink, allowing path traversal
        if dest.exists():
            dest.unlink()
        dest.write_text(content)

def create_env(root: pathlib.Path) -> None:
    activator = ViaTemplateActivator()
    activation_path = root / "bin" / "activate"
    activator._generate(activation_path, "# activation script")

Patched code sample

import pathlib

class ViaTemplateActivator:
    def _generate(self, dest: pathlib.Path, content: str) -> None:
        # FIX: ensure any existing symlink (dangling or not) is removed before writing
        if dest.is_symlink() or dest.exists():
            dest.unlink()
        dest.write_text(content)

def create_env(root: pathlib.Path) -> None:
    activator = ViaTemplateActivator()
    activation_path = root / "bin" / "activate"
    activator._generate(activation_path, "# 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 generated file links (#3431) (pypa/virtualenv)
    src/virtualenv/activation/via_template.py, src/virtualenv/activation/via_template.py · ViaTemplateActivator._generate, src/virtualenv/create/creator.py, src/virtualenv/create/creator.py · Creator.add_cachedir_tag, src/virtualenv/create/creator.py · Creator.setup_ignore_vcs, src/virtualenv/create/pyenv_cfg.py, src/virtualenv/create/pyenv_cfg.py · PyEnvCfg.write, src/virtualenv/create/via_global_ref/api.py, src/virtualenv/create/via_global_ref/api.py · ViaGlobalRefApi.install_patch, src/virtualenv/create/via_global_ref/venv.py, src/virtualenv/create/via_global_ref/venv.py · Venv.create, src/virtualenv/seed/embed/via_app_data/pip_install/base.py · ScriptMakerCustom._write_script and 2 more

Cite this entry

@misc{vaitp:cve2026113721,
  title        = {{Symlink race allows overwriting files outside the virtualenv during creation.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-113721},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113721/}}
}

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.