CVE-2026-12345: Python tempfile.TemporaryDirectory race condition in cleanup

CVE-2026-12345 · Severity: info · Published 2026-09-29

Python's tempfile.TemporaryDirectory module has a race condition during cleanup where an attacker who can modify the file system tree can replace a directory with a symbolic link. This allows the cleanup process to delete files outside the temporary directory or reset their permissions and file flags, potentially causing data loss or security degradation when cleanup runs with elevated privileges.

Technologies: Python CPython. Vendors: Python.

Quick answers

Is CVE-2026-12345 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-12345 being exploited in the wild.
How severe is CVE-2026-12345?
Informational severity, published 29 September 2026.
Which products and versions are affected?
Python CPython 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.16.
Is there a fix for CVE-2026-12345?
A patch was published on 2026-09-29. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-12345 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-12345?
Check whether you run Python CPython at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

Technical details

The vulnerability exists in tempfile.TemporaryDirectory's cleanup logic: when resolving paths to handle permission errors, files are removed after path resolution, enabling a time-of-check-time-of-use (TOCTOU) race. An attacker with local file system access can swap a directory within the tree with a symlink to target files outside the temporary directory. On systems where shutil.rmtree.avoids_symlink_attacks is false, this results in arbitrary file deletion; on all systems, file permissions and flags can be reset outside the intended tree. The attack requires local access and runs with the cleanup process's privileges.

Affected products

  • Python CPython 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.16

Timeline

  • 2026-09-15: disclosed
  • 2026-09-29: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.