---
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.12.15
  - CPython >= 3.15.0a1 < 3.15.0rc3
patched:
  - hardened_images
published: '2026-09-29'
updated: '2026-10-10'
sourceUpdated: '2026-10-10T01:16:37.850'
source: NVD
sourceUrl: 'https://nvd.nist.gov/vuln/detail/CVE-2026-12345'
references:
  - url: >-
      https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970
    label: cna@python.org
  - url: >-
      https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420
    label: cna@python.org
  - url: >-
      https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74
    label: cna@python.org
  - url: >-
      https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538d
    label: cna@python.org
  - url: >-
      https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993
    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
  - url: 'http://www.openwall.com/lists/oss-security/2026/09/29/40'
    label: af854a3a-2127-422b-91ae-364da2661108
  - url: >-
      https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-12345.json
  - url: 'https://access.redhat.com/security/cve/CVE-2026-12345'
  - url: 'https://bugzilla.redhat.com/show_bug.cgi?id=2543492'
  - url: 'https://www.cve.org/CVERecord?id=CVE-2026-12345'
  - url: 'https://nvd.nist.gov/vuln/detail/CVE-2026-12345'
  - url: 'https://access.redhat.com/errata/RHSA-2026:74922'
  - url: 'https://access.redhat.com/errata/RHSA-2026:74870'
  - url: 'https://access.redhat.com/errata/RHSA-2026:75119'
  - url: >-
      https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aa
  - url: >-
      https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58
  - url: 'https://access.redhat.com/errata/RHSA-2026:85239'
  - url: 'https://access.redhat.com/errata/RHSA-2026:89742'
tags:
  - nvd
  - exploit-available
  - cve.org
  - csaf
  - vex
  - red-hat
epss: 0.00344
epssPercentile: 0.2775
exploits:
  github: 1
  githubRepos:
    - 'https://github.com/zahidec0de/CVE-2026-12345-poc'
  checkedAt: '2026-10-27T16:59:26.498Z'
exploitAvailable: true
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: partial
  timestamp: '2026-09-29T18:38:00.590353Z'
cvssSource: cna
scores:
  cna: 5.9
  vendor: 6.3
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.

## Vendor advisories

- **Red Hat VEX** · Moderate · affected: Red Hat Enterprise Linux 10, Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8, Red Hat Enterprise Linux 9, Red Hat Enterprise Linux AI (RHEL AI) 3, … · no fix planned: Red Hat Enterprise Linux 6, Red Hat Hardened Images, Red Hat Enterprise Linux 10, Red Hat Enterprise Linux 7, … · updated 2026-10-26 · [vex](https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-12345.json)
- **RHSA-2026:74922** · Red Hat · fixed in: Red Hat Hardened Images · released 2026-10-02 · [advisory](https://access.redhat.com/errata/RHSA-2026:74922)
- **RHSA-2026:74870** · Red Hat · fixed in: Red Hat Hardened Images · released 2026-10-02 · [advisory](https://access.redhat.com/errata/RHSA-2026:74870)
- **RHSA-2026:75119** · Red Hat · fixed in: Red Hat Hardened Images · released 2026-10-03 · [advisory](https://access.redhat.com/errata/RHSA-2026:75119)
- **RHSA-2026:85239** · Red Hat · fixed in: Red Hat Enterprise Linux AppStream (v. 8), Red Hat Enterprise Linux BaseOS (v. 8) · released 2026-10-19 · [advisory](https://access.redhat.com/errata/RHSA-2026:85239)
- **RHSA-2026:89742** · Red Hat · fixed in: Red Hat Enterprise Linux AppStream (v. 9), Red Hat Enterprise Linux BaseOS (v. 9), Red Hat Enterprise Linux CodeReady Linux Builder (v. 9) · released 2026-10-26 · [advisory](https://access.redhat.com/errata/RHSA-2026:89742)
