Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory
CVE-2026-12345Published 29 Sep 2026, 17:46 UTC
Real-world risk
1.3/ 10Low
Routine
If the vulnerable configuration applies to you: 3.0
PreliminaryFrom the CVSS vector only · confidence low
CVSS
5.9
scored by the vendor (CNA), CVSS 4.0
In plain words
No plain-language summary yet. The original description is below.
Original description (from PSF)
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.
Am I affected?
| Product | Affected versions (from the sources) | Fixed in |
|---|---|---|
| CPythonUbiquitous | < 3.12.15; >= 3.13.0, < 3.13.18; >= 3.14.0, < 3.14.9; >= 3.15.0a1, < 3.15.0rc3 | 3.12.15, 3.13.18, 3.14.9, 3.15.0rc3 |
What to do
Update to a fixed version: 3.12.15, 3.13.18, 3.14.9, 3.15.0rc3.
Why this score
| Factor | Value | Evidence | × |
|---|---|---|---|
| Impact | Major data tamperingWrites or changes important data without gaining execution | From the CVSS vector | 0.70 |
| Attacker position | LocalMust already run code or have a shell on the machine | From the CVSS vector | 0.50 |
| Privileges needed | NoneNo account | From the CVSS vector | 1.00 |
| Victim interaction | NoneNothing | From the CVSS vector | 1.00 |
| Configuration | UncommonNeeds a non-default feature that a minority enables | From the CVSS vector | 0.45 |
| Reliability | ReliableDeterministic: injection, logic bug, path traversal | From the CVSS vector | 1.00 |
Threat level T1: Nothing known (× 0.85)
The default for a new disclosure
EPSS 0.4% chance of exploitation in 30 days (percentile 31), as of 2026-12-03.
The arithmetic
- Prerequisites multiplied together0.225
- Threat T1: Nothing known0.850
- 10 × impact 0.7 × prerequisites 0.225 × threat 0.851.339
- Rounded to one decimal between 0.1 and 101.3
Exploitation and evidence timeline
- 29 Sep 2026 Published
- 3 Dec 2026 Risk 1.3 (cvss fallback)
Weakness
CWE-59
References
- https://github.com/python/cpython/pull/157580patch
- https://github.com/python/cpython/issues/157579issue-tracking
- https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538dpatch
- https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420patch
- https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993patch
- https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970patch
- https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74patch
- https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aapatch
- https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58patch
- https://github.com/python/cpython/commit/aa17c688d2c160969f2c8963f4454cdd139808e7patch
- https://github.com/python/cpython/commit/8fa0152f7dbd65b6341a7b00a56227127dc2ec99patch
- https://github.com/python/cpython/commit/ac0487e42060a39ce648e40f0a63e37391b2d816patch
- https://github.com/python/cpython/commit/e82a65ade532d4204e9c507e462dbcce8815fb93patch
- http://www.openwall.com/lists/oss-security/2026/09/29/40
- CVE-2026-12345 on CVE.org