{"vuln_id":"CVE-2026-113721","aliases":["GHSA-558c-9hv2-4prj"],"description":"virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when Path.exists() is true, allowing a dangling symlink to survive and redirect generated activation content, while PyEnvCfg.write() opens pyvenv.cfg without first replacing an existing symbolic or hard link. Another local account that prepares final entries inside the destination can therefore cause environment creation to create or overwrite files outside the requested tree with constrained virtualenv-generated content and the invoking user's permissions. The destination parent must remain controlled by the environment owner during creation; concurrent parent-directory replacement is a separate concern. This issue is fixed in version 21.14.9.","published_at":"2026-10-20T20:17:18.653000Z","modified_at":"2026-11-18T12:10:56.790021Z","first_seen_at":"2026-11-21T19:15:47.086376Z","severity":"medium","severity_source":"nvd","cvss_score":4.5,"cvss_vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L","cwe":["CWE-59"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00196,"epss_percentile":0.09334,"nvd_status":"Analyzed","enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-113721"},"matched_alias":null,"items":[{"id":10755,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-558c-9hv2-4prj: virtualenv: Generated files can follow existing destination links","summary":"virtualenv: Generated files can follow existing destination links\n\n## Summary\n\nGenerated activation files and pyvenv.cfg can follow existing links and write outside the requested environment. The\ntemplate writer tests exists() before unlinking, which misses dangling symlinks; the configuration writer opens the\nexisting path directly.\n\nAnthropic's OSS Scanner reported this as `ANT-2026-XBEOCBS1` in `virtualenv-20261015-005`, received on 15 October 2026.\n\n## Affected area\n\nFinal file entries written during environment creation and seeding.\n\n## Attacker-controlled input\n\nAnother account must be able to prepare file links in the destination before creation. The invoking user must have write\npermission at the linked target. The destination parent must remain controlled during creation; concurrent\nparent-directory replacement is a separate concern.\n\n## Affected code\n\nThe relevant 21.14.8 source is in\n[template writer](https://github.com/pypa/virtualenv/blob/a795ab116356afde11039cf2763d77e8a06da738/src/virtualenv/activation/via_template.py),\n[configuration writer](https://github.com/pypa/virtualenv/blob/a795ab116356afde11039cf2763d77e8a06da738/src/virtualenv/create/pyenv_cfg.py).\n\n## Mechanism\n\n`ViaTemplateActivator._generate()` removes an existing output only when `Path.exists()` is true. A dangling symlink\ntherefore survives, and `write_bytes()` creates its target outside the environment. Other generated files have related\nfinal-entry behavior. `PyEnvCfg.write()` opens `pyvenv.cfg` without first replacing an existing link; a symlink or hard\nlink there can overwrite an existing target. These paths require a prepared destination tree and the invoking user's\npermission to write the linked target.\n\n## Reproduction and evidence\n\nThe scanner's project tree contains `venv/bin/activate -> ../../../.bash_aliases` and an executable `venv/bin/basename`.\nBefore creation, a new interactive bash does not create the marker. A plain `virtualenv venv` writes the activation\nscript through the dangling link, creating `~/.bash_aliases` as a regular file. Debian's stock `.bashrc` sources that\nfile; the next interactive bash adds `venv/bin` to `PATH` and the planted `basename` writes the marker. The reproducer\nchecks that the link remains, `~/.bash_aliases` appears, and the second shell executes the planted file. A separate\nmanual check links `pyvenv.cfg` to `~/.bashrc` and observes the latter replaced with generated configuration text.\n\nThe link lets creation write outside the requested environment. The attacker chooses the target path but the generated\nbytes come from virtualenv. The executable in the example was already in the prepared tree; this finding is not\narbitrary code injection into an otherwise trusted destination. The scanner traces the template behavior to #1454, first\nreleased in 20.0.0b1. [PR #3431](https://github.com/pypa/virtualenv/pull/3431) replaces pre-existing output links and\nuses exclusive creation for generated text. It does not make a destination safe if another account can replace parent\ndirectories during creat\n\nAffected: PyPI:virtualenv\n\nFixed in: 21.14.9\n\nReferences:\nhttps://github.com/pypa/virtualenv/security/advisories/GHSA-558c-9hv2-4prj\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-113721\nhttps://github.com/pypa/virtualenv/pull/3431\nhttps://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd\nhttps://github.com/pypa/virtualenv\nhttps://github.com/pypa/virtualenv/releases/tag/21.14.9","url":"https://osv.dev/vulnerability/GHSA-558c-9hv2-4prj","published_at":"2026-10-22T17:03:12Z","updated_at":"2026-11-18T12:10:56.790021Z","fetched_at":"2026-11-21T19:15:55.946153Z","severity":"medium","cvss_score":4.5,"epss":0.00196,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"virtualenv","vuln_id":"CVE-2026-113721","vuln_ids":["CVE-2026-113721","BIT-VIRTUALENV-2026-113721","GHSA-558C-9HV2-4PRJ","PYSEC-2026-4380"],"tags":["osv","pypi","fix-available"],"cluster_id":4105,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10755","html":"https://vulnwatch.ve1ve2.com/item/10755"}},{"id":11326,"source":{"id":"osv","name":"OSV.dev"},"title":"DEBIAN-CVE-2026-113721: virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when…","summary":"virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when Path.exists() is true, allowing a dangling symlink to survive and redirect generated activation content, while PyEnvCfg.write() opens pyvenv.cfg without first replacing an existing symbolic or hard link. Another local account that prepares final entries inside the destination can therefore cause environment creation to create or overwrite files outside the requested tree with constrained virtualenv-generated content and the invoking user's permissions. The destination parent must remain controlled by the environment owner during creation; concurrent parent-directory replacement is a separate concern. This issue is fixed in version 21.14.9.\n\nAffected: Debian:12:python-virtualenv, Debian:13:python-virtualenv, Debian:14:python-virtualenv\n\nNo fixed version published yet\n\nReferences:\nhttps://security-tracker.debian.org/tracker/CVE-2026-113721","url":"https://osv.dev/vulnerability/DEBIAN-CVE-2026-113721","published_at":"2026-10-20T20:17:18.653000Z","updated_at":"2026-11-18T12:01:33.340052Z","fetched_at":"2026-11-21T19:23:21.853703Z","severity":"medium","cvss_score":4.5,"epss":0.00196,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"debian","product":"12:python-virtualenv","vuln_id":"CVE-2026-113721","vuln_ids":["CVE-2026-113721","DEBIAN-CVE-2026-113721","GHSA-558C-9HV2-4PRJ"],"tags":["osv","debian","no-fix-yet"],"cluster_id":4104,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/11326","html":"https://vulnwatch.ve1ve2.com/item/11326"}},{"id":10756,"source":{"id":"osv","name":"OSV.dev"},"title":"PYSEC-2026-4380: virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when…","summary":"virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when Path.exists() is true, allowing a dangling symlink to survive and redirect generated activation content, while PyEnvCfg.write() opens pyvenv.cfg without first replacing an existing symbolic or hard link. Another local account that prepares final entries inside the destination can therefore cause environment creation to create or overwrite files outside the requested tree with constrained virtualenv-generated content and the invoking user's permissions. The destination parent must remain controlled by the environment owner during creation; concurrent parent-directory replacement is a separate concern. This issue is fixed in version 21.14.9.\n\nAffected: PyPI:virtualenv\n\nFixed in: 21.14.9\n\nReferences:\nhttps://github.com/pypa/virtualenv/releases/tag/21.14.9\nhttps://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd\nhttps://github.com/pypa/virtualenv/pull/3431\nhttps://github.com/pypa/virtualenv/security/advisories/GHSA-558c-9hv2-4prj","url":"https://osv.dev/vulnerability/PYSEC-2026-4380","published_at":"2026-10-20T20:17:18.653000Z","updated_at":"2026-11-18T12:10:56.790021Z","fetched_at":"2026-11-21T19:15:55.946154Z","severity":"medium","cvss_score":4.5,"epss":0.00196,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"virtualenv","vuln_id":"CVE-2026-113721","vuln_ids":["CVE-2026-113721","BIT-VIRTUALENV-2026-113721","GHSA-558C-9HV2-4PRJ","PYSEC-2026-4380"],"tags":["osv","pypi","fix-available"],"cluster_id":4104,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10756","html":"https://vulnwatch.ve1ve2.com/item/10756"}},{"id":3765,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-113721: virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when…","summary":"virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.9, ViaTemplateActivator._generate() removes an existing output only when Path.exists() is true, allowing a dangling symlink to survive and redirect generated activation content, while PyEnvCfg.write() opens pyvenv.cfg without first replacing an existing symbolic or hard link. Another local account that prepares final entries inside the destination can therefore cause environment creation to create or overwrite files outside the requested tree with constrained virtualenv-generated content and the invoking user's permissions. The destination parent must remain controlled by the environment owner during creation; concurrent parent-directory replacement is a separate concern. This issue is fixed in version 21.14.9.\n\nReferences:\nhttps://github.com/pypa/virtualenv/commit/d25f28699eefb1fc34a251e5adf2b5de844c36cd\nhttps://github.com/pypa/virtualenv/pull/3431\nhttps://github.com/pypa/virtualenv/releases/tag/21.14.9\nhttps://github.com/pypa/virtualenv/security/advisories/GHSA-558c-9hv2-4prj","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-113721","published_at":"2026-10-20T20:17:18.653000Z","updated_at":"2026-11-17T17:33:41.990000Z","fetched_at":"2026-11-21T19:15:31.479289Z","severity":"medium","cvss_score":4.5,"epss":0.00196,"is_kev":false,"has_exploit":true,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-113721","vuln_ids":["CVE-2026-113721","GHSA-558C-9HV2-4PRJ"],"tags":["CWE-59"],"cluster_id":4104,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/3765","html":"https://vulnwatch.ve1ve2.com/item/3765"}}]}