VAITP Dataset

← Back to the dataset

CVE-2026-113720

Improper file mode handling in virtualenv seeder may expose writable files.

  • CVSS 4.4
  • CWE-732
  • Configuration Issues
  • Local

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, the app-data copy seeder uses shutil.copy() to copy cached package files into later environments, causing cached source modes to override the current run's umask. A cache populated under a permissive umask can therefore produce files writable by another local account in a later traversable environment, allowing package code such as pip/__init__.py to be modified and executed by the environment owner. The attacker cannot force the earlier umask, and a private destination parent prevents access. This issue is fixed in version 21.14.9.

CVSS base score
4.4
Published
2026-10-20
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Configuration Issues
Subcategory
Local File Inclusion (LFI)
Accessibility scope
Local
Impact
Privilege Escalation
Affected component
virtualenv
Fixed by upgrading
Yes

Solution

Upgrade virtualenv to version 21.14.9 or newer.

Vulnerable code sample

import os, shutil, pathlib

def seed_app_data(cache_dir: str, env_dir: str) -> None:
    """
    Copy cached package files from ``cache_dir`` into a new virtualenv
    located at ``env_dir``.
    """
    src = pathlib.Path(cache_dir)
    dst = pathlib.Path(env_dir) / "app-data"
    dst.mkdir(parents=True, exist_ok=True)

    for pkg_file in src.iterdir():
        # VULNERABLE: uses shutil.copy preserving source mode, allowing insecure permissions
        shutil.copy(pkg_file, dst / pkg_file.name)

Patched code sample

import os, shutil, pathlib

def seed_app_data(cache_dir: str, env_dir: str) -> None:
    """
    Copy cached package files from ``cache_dir`` into a new virtualenv
    located at ``env_dir``.
    """
    src = pathlib.Path(cache_dir)
    dst = pathlib.Path(env_dir) / "app-data"
    dst.mkdir(parents=True, exist_ok=True)

    for pkg_file in src.iterdir():
        # FIX: copy file then enforce safe permissions (rw-------)
        dest = dst / pkg_file.name
        shutil.copyfile(pkg_file, dest)
        os.chmod(dest, 0o600)

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.

Cite this entry

@misc{vaitp:cve2026113720,
  title        = {{Improper file mode handling in virtualenv seeder may expose writable files.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-113720},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113720/}}
}

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.