CVE-2026-12345
JSON

5.9medium

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

Severity
5.9medium CVSS:4.0 by PSF
Exploit likelihood
0.36% (higher than 31% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
PSF
Also known as
PSF-2026-42BIT-LIBPYTHON-2026-12345BIT-PYTHON-2026-12345BIT-PYTHON-MIN-2026-12345

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.

Affected

Product or packageVersionsReported by
Python Software Foundation CPythonbefore 3.12.15, from 3.13.0 before 3.13.18, from 3.14.0 before 3.14.9, from 3.15.0a1 before 3.15.0rc3CVE List
https://github.com/python/cpythonbefore 5c20517a4fc56683efe63a7751020db9573f538d, before 458e7134a5af7f86aee9d21b51cf499b41aa4420, before e1f3590f155c6d66007e958c98c9d69316551993, before 06ef3d43fdaf4da97af12fa694b4886092c4b970, before 58ed0259cae509a19138795df302fe60b544dc74, before 0478b52788117db4b831b3efd648f56b777628aa, before c39b52d00b42200aaadff679e2fe3f1006d57c58Python Software Foundation
libpython (Bitnami)before 3.12.16, from 3.13.0 before 3.13.18, from 3.14.0 before 3.14.9Bitnami Vulnerability Database
python (Bitnami)before 3.12.16, from 3.13.0 before 3.13.18, from 3.14.0 before 3.14.9Bitnami Vulnerability Database
python-min (Bitnami)before 3.12.16, from 3.13.0 before 3.13.18, from 3.14.0 before 3.14.9Bitnami Vulnerability Database

All scores

PSF5.9medium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N
Bitnami Vulnerability Databasemedium rating

Classification

CWE-59

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

References

https://github.com/python/cpython/pull/157580patch, web
https://github.com/python/cpython/issues/157579issue-tracking, report, web
https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538dfix, patch, web
https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420fix, patch, web
https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993fix, patch, web
https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970fix, patch, web
https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74fix, patch, web
https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aafix, patch, web
https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58fix, patch, web
https://github.com/python/cpython/commit/aa17c688d2c160969f2c8963f4454cdd139808e7patch, web
https://github.com/python/cpython/commit/8fa0152f7dbd65b6341a7b00a56227127dc2ec99patch
https://github.com/python/cpython/commit/ac0487e42060a39ce648e40f0a63e37391b2d816patch

Sources

SourceRecordLicence
CVE ListCVE-2026-12345 changed 2026-12-01CVE Terms of Use
Python Software FoundationPSF-2026-42 changed 2026-10-26CC-BY-4.0
NVDCVE-2026-12345 changed 2026-11-19Public domain
Bitnami Vulnerability DatabaseBIT-LIBPYTHON-2026-12345 changed 2026-11-27Apache-2.0
Bitnami Vulnerability DatabaseBIT-PYTHON-2026-12345 changed 2026-11-27Apache-2.0
Bitnami Vulnerability DatabaseBIT-PYTHON-MIN-2026-12345 changed 2026-11-27Apache-2.0