// Security Advisory Triage

Race condition in tempfile.TemporaryDirectory allows file deletion outside temp directory

Python security announcements · published 2026-09-30 21:57 UTC
ACTION NEEDED VERIFY_EXPOSURE SECURITYAPI
WHAT CHANGEDCVE-2026-12345 disclosed on 29 September 2026. CPython's tempfile.TemporaryDirectory cleanup is vulnerable to a race condition where an attacker can replace a directory with a symlink during cleanup, causing files outside the temporary directory to be deleted or have permissions reset with the privileges of the cleanup process. Rated MEDIUM severity. Platforms where shutil.rmtree.avoids_symlink_attacks is false remain affected.
WHY IT MATTERSAny service using TemporaryDirectory that runs with elevated privileges or processes untrusted input can be exploited to delete arbitrary files on the system with the service's permissions. The race window exists between directory traversal and deletion, making it exploitable by local attackers or through timing attacks in containerized environments.
WHAT TO DOCheck https://www.cve.org/CVERecord?id=CVE-2026-12345 for the list of affected Python versions and whether your deployed versions are listed. If affected, review services using tempfile.TemporaryDirectory and assess whether they process untrusted input or run with privileges that would make file deletion consequential.
Model-reported confidence 85% (not measured accuracy) Primary source ↗ written by anthropic/claude-sonnet-4.5
Show the reasoning — raw diff, triage verdict, confidence
RAW DIFF
+## [Security-announce][CVE-2026-12345] Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory
+https://mail.python.org/archives/list/security-announce@python.org/message/WBHGJXKKLB7X3ZJF7NYE6M65DCUWW6QT/
+Tue, 29 Sep 2026 17:28:51 +0000
+
+There is a MEDIUM severity vulnerability affecting CPython.
+
+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.
+
+Please see the linked CVE ID for the latest information on affected
+versions:
+
+* https://www.cve.org/CVERecord?id=CVE-2026-12345
+* https://github.com/python/cpython/pull/157580
HOW IT WAS JUDGED
Triage signals below are model-reported assertions, preserved verbatim; they are not independent arithmetic verification.
triage verdictMATERIAL at 0.92, needed 0.5
triage reasoningRace condition in Python's tempfile.TemporaryDirectory allows privilege escalation via symlink replacement during cleanup.
signalsaffects Python runtime (CPython) · race condition in standard library tempfile module · privilege escalation potential via symlink attack · affects cleanup behavior in widely-used API · CVE assigned with severity rating · affects dependency tree of normal services
suppression—
triage modelanthropic/claude-haiku-4.5 ($0.00000)
writer modelanthropic/claude-sonnet-4.5 ($0.00000)