# CVE-2026-12345: Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory

- Severity: Medium 5.9 (CVSS:4.0, scored by PSF) `CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.36%, higher than 31% of CVEs (2026-12-01)
- Published: 2026-09-29T17:46:01.811Z
- Modified: 2026-12-01T00:34:01.395Z
- Also known as: PSF-2026-42, BIT-LIBPYTHON-2026-12345, BIT-PYTHON-2026-12345, BIT-PYTHON-MIN-2026-12345
- Weaknesses: CWE-59
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: PSF

## 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.

(As written by CVE List.)

## Affected

- Python Software Foundation CPython: before 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.0rc3
- https://github.com/python/cpython: before 5c20517a4fc56683efe63a7751020db9573f538d; before 458e7134a5af7f86aee9d21b51cf499b41aa4420; before e1f3590f155c6d66007e958c98c9d69316551993; before 06ef3d43fdaf4da97af12fa694b4886092c4b970; before 58ed0259cae509a19138795df302fe60b544dc74; before 0478b52788117db4b831b3efd648f56b777628aa; before c39b52d00b42200aaadff679e2fe3f1006d57c58
- libpython (Bitnami): before 3.12.16; from 3.13.0 before 3.13.18; from 3.14.0 before 3.14.9
- python (Bitnami): before 3.12.16; from 3.13.0 before 3.13.18; from 3.14.0 before 3.14.9
- python-min (Bitnami): before 3.12.16; from 3.13.0 before 3.13.18; from 3.14.0 before 3.14.9

## Every score

- PSF: CVSS:4.0 5.9 Medium `CVSS: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 Database: rating Medium

## References

- <https://github.com/python/cpython/pull/157580> (patch, web)
- <https://github.com/python/cpython/issues/157579> (issue-tracking, report, web)
- <https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538d> (fix, patch, web)
- <https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420> (fix, patch, web)
- <https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993> (fix, patch, web)
- <https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970> (fix, patch, web)
- <https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74> (fix, patch, web)
- <https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aa> (fix, patch, web)
- <https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58> (fix, patch, web)
- <https://github.com/python/cpython/commit/aa17c688d2c160969f2c8963f4454cdd139808e7> (patch, web)
- <https://github.com/python/cpython/commit/8fa0152f7dbd65b6341a7b00a56227127dc2ec99> (patch)
- <https://github.com/python/cpython/commit/ac0487e42060a39ce648e40f0a63e37391b2d816> (patch)
- <https://github.com/python/cpython/commit/e82a65ade532d4204e9c507e462dbcce8815fb93> (patch)
- <http://www.openwall.com/lists/oss-security/2026/09/29/40> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-12345> (web)

## Sources

- CVE List: [CVE-2026-12345](https://www.cve.org/CVERecord?id=CVE-2026-12345), CVE Terms of Use, modified 2026-12-01
- Python Software Foundation: [PSF-2026-42](https://osv.dev/vulnerability/PSF-2026-42), CC-BY-4.0, modified 2026-10-26
- NVD: [CVE-2026-12345](https://nvd.nist.gov/vuln/detail/CVE-2026-12345), Public domain, modified 2026-11-19
- Bitnami Vulnerability Database: [BIT-LIBPYTHON-2026-12345](https://osv.dev/vulnerability/BIT-LIBPYTHON-2026-12345), Apache-2.0, modified 2026-11-27
- Bitnami Vulnerability Database: [BIT-PYTHON-2026-12345](https://osv.dev/vulnerability/BIT-PYTHON-2026-12345), Apache-2.0, modified 2026-11-27
- Bitnami Vulnerability Database: [BIT-PYTHON-MIN-2026-12345](https://osv.dev/vulnerability/BIT-PYTHON-MIN-2026-12345), Apache-2.0, modified 2026-11-27

---

Page: https://cve.day/CVE-2026-12345 · Whole record: https://cve.day/CVE-2026-12345.json · Rebuilt by cve.day 2026-12-01T00:47:09.820Z
