---
id: CVE-2026-12345
title: The cleanup of tempfile.TemporaryDirectory is vulnerable to a race condition
summary: >-
  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…
severity: medium
cvss: 5.9
cvssVector: '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'
cwe:
  - CWE-59
vendor: Python Software Foundation
product: CPython
affected:
  - CPython < 3.15.0
published: '2026-09-29'
updated: '2026-09-29'
sourceUpdated: '2026-09-29T19:17:25.867'
source: NVD
sourceUrl: 'https://nvd.nist.gov/vuln/detail/CVE-2026-12345'
references:
  - url: >-
      https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538d
    label: cna@python.org
  - url: 'https://github.com/python/cpython/issues/157579'
    label: cna@python.org
  - url: 'https://github.com/python/cpython/pull/157580'
    label: cna@python.org
tags:
  - nvd
  - cve.org
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: partial
  timestamp: '2026-09-29T18:38:00.590353Z'
cvssSource: cna
ingestedAt: '2026-09-29T18:42:35.820Z'
---

## Overview

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.

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.
