VAITP Dataset

← Back to the dataset

CVE-2026-113714

Virtualenv may cache unverified wheels, allowing malicious index injection.

  • CVSS 2.3
  • CWE-354
  • Input Validation and Sanitization
  • Remote

virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, download_wheel() writes package-index downloads directly into the reusable wheel/house cache before selecting a verification target from pip's textual Saved output. With default-index digest comparison enabled, a controlled package index can inject a misleading Saved line through a discarded link's data-requires-python attribute; this forged-line variant also requires knowledge of an absolute path to the genuine bundled wheel. The wrong path can then be hashed, while a digest mismatch leaves the rejected archive in the cache for later selection without verification. A separate rejected-cache-file variant requires control over downloaded data or archive selection but not the forged-line prerequisites. Explicit custom-index exceptions are outside the promised PyPI comparison, and the issue does not independently bypass TLS or establish control of default PyPI. This issue is fixed in version 21.14.9.

CVSS base score
2.3
Published
2026-10-20
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
virtualenv
Fixed by upgrading
Yes

Solution

Upgrade virtualenv to version 21.14.9 or later.

Vulnerable code sample

import hashlib, os, urllib.request, tempfile

def download_wheel(url, cache_dir, expected_digest):
    # VULNERABLE: writes file to cache before verifying digest, allowing forged index lines to poison cache
    tmp_path = os.path.join(cache_dir, os.path.basename(url))
    urllib.request.urlretrieve(url, tmp_path)  # download unverified
    # later, verification is performed but the unverified file is already cached
    with open(tmp_path, 'rb') as f:
        data = f.read()
    actual_digest = hashlib.sha256(data).hexdigest()
    if actual_digest != expected_digest:
        # digest mismatch; file remains in cache for later reuse
        pass
    return tmp_path

Patched code sample

import hashlib, os, urllib.request, tempfile

def download_wheel(url, cache_dir, expected_digest):
    # FIX: verify digest before writing to cache, preventing unverified files from being stored
    with urllib.request.urlopen(url) as resp:
        data = resp.read()
    actual_digest = hashlib.sha256(data).hexdigest()
    if actual_digest != expected_digest:
        raise ValueError("Digest mismatch")
    tmp_path = os.path.join(cache_dir, os.path.basename(url))
    with open(tmp_path, 'wb') as f:
        f.write(data)
    return tmp_path

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(seed): verify wheels before caching (#3430) (pypa/virtualenv)
    src/virtualenv/seed/embed/pip_invoke.py, src/virtualenv/seed/embed/pip_invoke.py · PipInvoke.get_pip_install_cmd, src/virtualenv/seed/wheels/acquire.py, src/virtualenv/seed/wheels/acquire.py · download_wheel

Cite this entry

@misc{vaitp:cve2026113714,
  title        = {{Virtualenv may cache unverified wheels, allowing malicious index injection.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-113714},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113714/}}
}

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.