{"id":"CVE-2026-22702","aliases":["CVE-2026-22702","GHSA-597g-3phw-6986","BIT-VIRTUALENV-2026-22702","PYSEC-2026-2009"],"related":[],"kind":"vulnerability","state":"published","title":"virtualenv Has TOCTOU Vulnerabilities in Directory Creation","summary":"virtualenv is a tool for creating isolated virtual python environments. Prior to version 20.36.1, TOCTOU (Time-of-Check-Time-of-Use) vulnerabilities in virtualenv allow local attackers to perform symlink-based attacks on directory creation operations. An attacker with local access can exploit a race condition between directory existence checks and creation to redirect virtualenv's app_data and lock file operations to attacker-controlled locations. This issue has been patched in version 20.36.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"virtualenv is a tool for creating isolated virtual python environments. Prior to version 20.36.1, TOCTOU (Time-of-Check-Time-of-Use) vulnerabilities in virtualenv allow local attackers to perform symlink-based attacks on directory creation operations. An attacker with local access can exploit a race condition between directory existence checks and creation to redirect virtualenv's app_data and lock file operations to attacker-controlled locations. This issue has been patched in version 20.36.1.","source":"cvelist"},{"lang":"en","text":"## Impact\n\nTOCTOU (Time-of-Check-Time-of-Use) vulnerabilities in `virtualenv` allow local attackers to perform symlink-based attacks on directory creation operations. An attacker with local access can exploit a race condition between directory existence checks and creation to redirect virtualenv's app_data and lock file operations to attacker-controlled locations.\n\n**Affected versions:** All versions up to and including 20.36.1\n\n**Affected users:** Any user running `virtualenv` on multi-user systems where untrusted local users have filesystem access to shared temporary directories or where `VIRTUALENV_OVERRIDE_APP_DATA` points to a user-writable location.\n\n**Attack scenarios:**\n- Cache poisoning: Attacker corrupts wheels or Python metadata in the cache\n- Information disclosure: Attacker reads sensitive cached data or metadata\n- Lock bypass: Attacker controls lock file semantics to cause concurrent access violations\n- Denial of service: Lock starvation preventing virtualenv operations\n\n## Patches\n\nThe vulnerability has been patched by replacing check-then-act patterns with atomic `os.makedirs(..., exist_ok=True)` operations.\n\n**Fixed in:** PR #3013\n\n**Versions with the fix:** 20.36.2 and later\n\nUsers should upgrade to version 20.36.2 or later.\n\n## Workarounds\n\nIf you cannot upgrade immediately:\n\n1. Ensure `VIRTUALENV_OVERRIDE_APP_DATA` points to a directory owned by the current user with restricted permissions (mode 0700)\n2. Avoid running `virtualenv` in shared temporary directories where other users have write access\n3. Use separate user accounts for different projects to isolate app_data directories\n\n## References\n\n- GitHub PR: https://github.com/pypa/virtualenv/pull/3013\n- Vulnerability reported by: @tsigouris007\n- CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization (TOCTOU)\n- CWE-59: Improper Link Resolution Before File Access","format":"markdown","source":"ghsa"},{"lang":"es","text":"virtualenv es una herramienta para crear entornos virtuales de Python aislados. Antes de la versión 20.36.1, las vulnerabilidades TOCTOU (Time-of-Check-Time-of-Use) en virtualenv permiten a atacantes locales realizar ataques basados en enlaces simbólicos en operaciones de creación de directorios. Un atacante con acceso local puede explotar una condición de carrera entre las comprobaciones de existencia de directorios y su creación para redirigir las operaciones de los archivos app_data y de bloqueo de virtualenv a ubicaciones controladas por el atacante. Este problema ha sido parcheado en la versión 20.36.1.","source":"nvd"}],"published":"2026-01-10T06:05:53.281Z","modified":"2026-09-10T03:50:32.732Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L","score":4.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L","score":4.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L","score":4.5,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L","score":4.5,"rating":"MEDIUM"},{"scorer":"Bitnami Vulnerability Database","scheme":"rating","rating":"MEDIUM"}],"cwes":["CWE-59","CWE-362"],"affected":[{"ranges":[{"version":"< 20.36.1","status":"affected"}],"vendor":"pypa","product":"virtualenv","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"20.36.1"}],"ecosystem":"PyPI","package":"virtualenv","purl":"pkg:pypi/virtualenv","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"20.36.1"}],"vendor":"virtualenv","product":"virtualenv","cpe":"cpe:2.3:a:virtualenv:virtualenv:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"20.36.1"}],"ecosystem":"PyPI","package":"virtualenv","purl":"pkg:pypi/virtualenv","source":"pysec"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"20.36.1"}],"ecosystem":"Bitnami","package":"virtualenv","purl":"pkg:bitnami/virtualenv","source":"bitnami"}],"references":[{"url":"https://github.com/pypa/virtualenv/security/advisories/GHSA-597g-3phw-6986","tags":["advisory","mitigation","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec","bitnami"]},{"url":"https://github.com/pypa/virtualenv/pull/3013","tags":["fix","issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec","bitnami"]},{"url":"https://github.com/pypa/virtualenv/commit/dec4cec5d16edaf83a00a658f32d1e032661cebc","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec","bitnami"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22702","tags":["advisory","web"],"sources":["ghsa","pysec","bitnami"]},{"url":"https://github.com/pypa/virtualenv","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/virtualenv","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-597g-3phw-6986","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-01-12T16:44:05.659Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-22702","url":"https://www.cve.org/CVERecord?id=CVE-2026-22702","licence":"CVE Terms of Use","modified":"2026-01-12T16:44:12.734Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-597g-3phw-6986","url":"https://github.com/advisories/GHSA-597g-3phw-6986","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:32.732Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-22702","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22702","licence":"Public domain","modified":"2026-06-17T10:20:15.777Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2009","url":"https://osv.dev/vulnerability/PYSEC-2026-2009","licence":"CC-BY-4.0","modified":"2026-07-07T17:57:28.238Z"},{"source":"bitnami","name":"Bitnami Vulnerability Database","id":"BIT-VIRTUALENV-2026-22702","url":"https://osv.dev/vulnerability/BIT-VIRTUALENV-2026-22702","licence":"Apache-2.0","modified":"2026-09-08T08:48:21.502Z"}],"updatedAt":"2026-11-25T22:59:12.720Z","epss":{"score":0.00097,"percentile":0.00758,"date":"2026-12-01T12:00:22.000Z"}}