All vulnerabilities
CVE-2026-12345

CPython: Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory

Python Software Foundation CPythonRuntimes & languages
CVSS
5.9Medium
ExploitationNo known exploitationNot in CISA KEV, which does not prove it is unexploitedCISA KEV
Exploit odds (EPSS)0.18%Chance of exploitation activity in the next 30 days, higher than 7% of CVEs. Scored 23 Oct 2026FIRST EPSS
Fixed in3.12.15Also 3.14.9, 3.15.0rc3CVE List
Published29 Sep 2026Updated 22 Oct 2026CVE List

What fixes it

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

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.

Text from CVE List

Affected versions 3

  • CPythonaffected: all versions before 3.12.15CVE List
  • CPythonaffected: 3.14.0 before 3.14.9CVE List
  • CPythonaffected: 3.15.0a1 before 3.15.0rc3CVE List

References 7