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.
Published: 2026-09-29
Score: 5.9 Medium
EPSS: n/a
KEV: No
Impact: Inappropriate Deletion of Files
Action: Update Python
AI Analysis

Impact

The race condition, identified as a CWE-59 weakness, occurs during the cleanup of a TemporaryDirectory object in CPython's tempfile module. An attacker who can alter the directory tree while the cleanup routine is running may replace a real directory or file with a symbolic link pointing elsewhere. When the cleanup removes the TemporaryDirectory, it follows that symlink and deletes or changes metadata of files outside the intended temporary space. The result is unintended deletion or permission changes of arbitrary files owned by the process, which can corrupt data or disrupt services.

Affected Systems

CPython, the standard Python implementation maintained by the Python Software Foundation, is affected. All versions that have not yet incorporated the patch referenced in commit 5c20517a4fc56683efe63a7751020db9573f538d are vulnerable. The issue specifically involves the tempfile.TemporaryDirectory cleanup routine and the shutil.rmtree behavior that does not always prevent symlink attacks.

Risk and Exploitability

The CVSS score of 5.9 indicates moderate severity, and the EPSS score is not available, so the precise exploitation probability is uncertain. The vulnerability requires that an attacker be able to modify the target directory tree while the cleanup is executing, which typically means local execution or influence over the temporary directory content. Because the cleanup runs with the privileges of the Python process, the consequences can include unintended deletion of files that the process is allowed to modify. The absence of a KEV listing suggests no widespread exploitation yet.

Generated by OpenCVE AI on September 29, 2026 at 22:38 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade CPython to a version that includes the fix, such as the release following commit 5c20517a4fc56683efe63a7751020db9573f538d.
  • Ensure that any temporary directories used by your applications are not writable by untrusted code and avoid modifying them during cleanup.
  • Verify that the environment variable or setting controlling shutil.rmtree.avoids_symlink_attacks is enabled; if available set it to True to prevent symlink exploitation during recursive removal.

Generated by OpenCVE AI on September 29, 2026 at 22:38 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Wed, 30 Sep 2026 00:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

cvssV3_1

{'score': 6.3, 'vector': 'CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H'}

threat_severity

Moderate


Tue, 29 Sep 2026 22:30:00 +0000

Type Values Removed Values Added
References

Tue, 29 Sep 2026 22:00:00 +0000

Type Values Removed Values Added
First Time appeared Python
Python cpython
Vendors & Products Python
Python cpython

Tue, 29 Sep 2026 19:30:00 +0000

Type Values Removed Values Added
Weaknesses CWE-59
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Tue, 29 Sep 2026 18:15:00 +0000


Tue, 29 Sep 2026 18:00:00 +0000

Type Values Removed Values Added
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.
Title Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory
References
Metrics cvssV4_0

{'score': 5.9, 'vector': '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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: PSF

Published:

Updated: 2026-09-29T21:07:55.567Z

Reserved: 2026-06-15T19:08:01.497Z

Link: CVE-2026-12345

cve-icon Vulnrichment

Updated: 2026-09-29T21:07:55.567Z

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-09-29T18:17:14.707

Modified: 2026-09-29T22:17:08.853

Link: CVE-2026-12345

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-09-29T17:46:01Z

Links: CVE-2026-12345 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-09-29T22:45:18Z

Weaknesses
  • CWE-59

    Improper Link Resolution Before File Access ('Link Following')