Skip to main content

CPython EUVDEUVD-2026-89183

| CVE-2026-12345 MEDIUM
Improper Link Resolution Before File Access (CWE-59)
2026-09-29 PSF
5.9
CVSS 4.0 · Vendor: PSF
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Gain local write access to temp tree
  2. Delivery
    Wait for privileged cleanup to start
  3. Exploit
    Swap directory for symlink mid-cleanup
  4. Execution
    rmtree follows link outside tree
  5. Impact
    Files deleted or permissions/flags reset with process privileges

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Symlink resolution safety
Exploitation Conditions

Requires local ability to modify the directory tree while it is being removed by tempfile.TemporaryDirectory cleanup (which calls shutil.rmtree). The attacker must win a race to replace a directory with a symbolic link during cleanup, and the damage occurs with the privileges of the process performing the cleanup - so the meaningful case is a higher-privileged process cleaning a tree a lower-privileged attacker can write into. Symlink-driven deletion of files outside the tree is limited to platforms where shutil.rmtree.avoids_symlink_attacks is false; however, resetting of file flags outside the tree can occur on all platforms. Limiting factors: local access only (no remote vector), a race window that must be won (AT:P / AC:H), and no impact against configurations where the cleanup process holds no more privilege than the attacker.

Impact

The provided CVSS 4.0 vector (AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H) scores 5.9 (medium) and is internally coherent with the description: exploitation is local (AV:L), requires no privileges or user interaction, but carries an Attack Requirement (AT:P) reflecting the TOCTOU race window that must be won, and delivers high integrity and availability impact (arbitrary file deletion / permission and flag resets) with zero confidentiality impact (VC:N). There is no EPSS score, no CISA KEV listing, and no public exploit code referenced, so this is 'no public exploit identified at time of analysis' - the only exploitation evidence is the vendor's own bug report and fix. The signals are consistent (medium severity, local vector, race-gated), so this is a genuine but bounded defense-in-depth issue rather than a mass-exploitation priority: real risk concentrates on systems where a higher-privileged process (e.g. root or a service) cleans up a temporary tree that a lower-privileged local user can also modify. Two data conflicts should be flagged: the CWE is listed as N/A even though the description unambiguously describes a symlink-following TOCTOU race (CWE-59 / CWE-367), and the 'Information Disclosure' tag contradicts the CVSS vector, which sets VC:N - the actual impact is integrity and availability, not disclosure. The PR:N choice is also debatable: the attacker must already be able to write into the tree during cleanup, which in practice implies some local foothold.

Exploit ScenarioDerived

A privileged process (for example a root-owned service or a setuid tool) uses tempfile.TemporaryDirectory, and a local unprivileged attacker who can write into that tree waits for cleanup to begin. During the removal, the attacker replaces a subdirectory with a symbolic link pointing outside the tree, so shutil.rmtree follows it and deletes or resets permissions/flags on files owned by the privileged process. No public exploit code is referenced; success depends on winning the cleanup race (AT:P), and platforms where shutil.rmtree.avoids_symlink_attacks is false are most exposed, though file-flag resets can occur on all platforms.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Sep 29, 2026

Race condition in CPython's tempfile.TemporaryDirectory cleanup can be exploited by a local attacker who can write into the directory tree while it is being removed, allowing files outside the temporary directory to be deleted or to have their permissions and file flags reset with the privileges of the cleaning process. The attack is a TOCTOU race: the attacker must swap a directory for a symbolic link (or otherwise mutate the tree) during the rmtree walk, so exploitation is local, timing-dependent, and only meaningful when the cleanup runs with higher privilege than the attacker. Deletion outside the tree is restricted to platforms where shutil.rmtree.avoids_symlink_attacks is False, while permission/flag resets outside the tree can occur on all platforms; no public exploit code was identified at time of analysis, and the upstream fix exists as a PR/commit rather than a confirmed released patched version.

RemediationAI

Apply the upstream fix: pull the change from CPython PR https://github.com/python/cpython/pull/157580 (commit 5c20517a4fc56683efe63a7751020db9573f538d), which makes rmtree/tempfile cleanup operate relative to open directory descriptors with O_NOFOLLOW and follow_symlinks=False where the platform supports it. Upstream fix available (PR/commit); released patched version not independently confirmed - confirm through your distribution or the CPython release notes before treating a given build as fixed, and note the patch itself documents that flag resets (os.chflags) remain name-based on all platforms. Until a patched build is deployed, the strongest compensating control is privilege separation: never let a higher-privileged process clean a TemporaryDirectory whose tree is writable by a lower-privileged user - create the temporary directory somewhere only the cleaning user can write (e.g., a private 0700 parent), so the race cannot be won; the trade-off is loss of shared scratch space. Secondarily, where the application can tolerate it, use ignore_errors=True on cleanup (or avoid attaching error-resetting callbacks) so the onexc permission/flag-reset path is not exercised, but this silently suppresses cleanup errors and can leave stale files on disk. On platforms where shutil.rmtree.avoids_symlink_attacks is False, no configuration avoids the symlink-deletion vector, so isolate the cleanup process so it cannot reach files outside the tree (container/mount namespace, chroot, or a dedicated unprivileged cleanup user); these techniques add deployment complexity and can break paths if the tree is expected to span mount points. Also consider filesystem-level restrictions and audit of any code that cleans directories in attacker-writable locations.

Affected VersionsENISA

CPython 0 <3.15.0

Affected Packages

euvd cpython fix: 3.15.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The root cause is a time-of-check-to-time-of-use (TOCTOU) flaw in the deletion path shared by tempfile.TemporaryDirectory and shutil.rmtree. cleanup() invokes an internal _rmtree() implementation that walks the tree, and when an operation fails it calls an error callback (onexc) that resets permissions and file flags via _resetperms() on the path and its parent. Because those paths are re-resolved by name after the check, an attacker who controls a writable subtree can replace a directory entry with a symbolic link between the check and the use; the subsequent chmod/unlink/chflags then acts on the symlink target rather than the intended in-tree object. The confirmed upstream patch hardens this by threading directory file descriptors through rmtree (dir_fd support), adding _resetperms_fd()/_resetperms_at() variants that operate relative to an open directory descriptor using os.chmod(..., dir_fd=..., follow_symlinks=False) or an O_NOFOLLOW open, and by passing direntry and dir_fd metadata into the onexc callback so the reset applies to the exact directory entry that was reached rather than a re-resolved pathname. The patch also adds a documented warning that cleanup is not robust against concurrent tree modification, and notes that os.chflags() has no dir_fd or descriptor support, so flag resets remain path-based on all platforms. The underlying weakness class is the classic symlink-following/TOCTOU pattern (link following during recursive deletion, CWE-59/CWE-367 family); the input did not assign an explicit CWE. The affected component is reachable purely through Python's standard library, so any application, daemon, or installer that creates a TemporaryDirectory in a location writable by a less-privileged user inherits the exposure.

Know when Cpython gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (PSF) PRIMARY 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
vuln.today AI 7.5 HIGH

Local race (AV:L, AC:H); attacker needs local write access to the tree (PR:L); cleanup runs with higher privilege affecting other files, so scope change (S:C); deletion/permission reset gives I:H/A:H, no disclosure (C:N).

3.1 AV:L/AC:H/PR:L/UI:N/S:C/C:N/I:H/A:H
4.0 AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N
Red Hat 6.3 MEDIUM

Primary rating from Vendor (PSF).

CVSS VectorVendor: PSF

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

DescriptionCVE.org

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.

Threat Intelligence Overview

EPSS Score
0.2%
Top 93% exploitable
Prevalence
Ubiquitous
CPython is the reference Python interpreter, present in nearly all environments
Social Media
9
Sightings
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment MSRC Vendor CIRCL GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Defer
Exploitation
None
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0
CVE-2026-17084 MEDIUM POC
6.0 Aug 18

Integrity bypass in CPython's stringprep module causes divergent domain name normalization when processing international

CVE-2026-19445 CRITICAL
9.2 Sep 30

A use-after-free in CPython's ssl module lets a remote, unauthenticated TLS client crash a Python TLS server process - o

CVE-2026-6100 CRITICAL
9.1 Apr 13

CPython decompression modules (lzma, bz2, gzip) allow memory corruption via use-after-free when decompressor instances a

CVE-2026-3298 HIGH
8.8 Apr 21

Out-of-bounds buffer write in CPython's asyncio.ProactorEventLoop (Windows only) allows remote attackers to trigger memo

CVE-2026-11972 HIGH
8.2 Jun 23

Denial of service in CPython's tarfile module allows remote attackers to trigger an infinite loop by supplying a crafted

CVE-2026-9669 HIGH
8.2 Jun 08

Stack-based buffer overflow in CPython's bz2.BZ2Decompressor allows remote attackers to crash Python applications by sen

CVE-2026-11940 HIGH
7.8 Jun 23

Path traversal in CPython's tarfile module allows a crafted tar archive to bypass the 'data' and 'tar' extraction filter

CVE-2026-19553 HIGH
7.6 Sep 30

Certificate hostname verification is silently skipped in CPython's TLS stack when an application enables SSLContext.chec

CVE-2026-4786 HIGH
7.0 Apr 13

Command injection in CPython's webbrowser.open() API bypasses previous CVE-2026-4519 mitigation via specially crafted UR

CVE-2026-4519 HIGH
7.0 Mar 20

The webbrowser.open() API in CPython accepts URLs with leading dashes, which certain web browsers interpret as command-l

CVE-2026-7774 MEDIUM
6.9 Jun 04

Path traversal in CPython's tarfile module allows malicious tar archives to bypass the data_filter safety mechanism and

CVE-2026-19672 MEDIUM
6.3 Aug 19

CPython's tarfile module on POSIX platforms creates empty directories outside the intended extraction destination when p

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy