Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessGain local write access to temp tree
-
DeliveryWait for privileged cleanup to start
-
ExploitSwap directory for symlink mid-cleanup
-
Executionrmtree follows link outside tree
-
ImpactFiles 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. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – 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
Affected Packages
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
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
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).
Primary rating from Vendor (PSF).
CVSS VectorVendor: PSF
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
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.
What every action level means
SSVC AssessmentENISA
Priority Score
Integrity bypass in CPython's stringprep module causes divergent domain name normalization when processing international
A use-after-free in CPython's ssl module lets a remote, unauthenticated TLS client crash a Python TLS server process - o
CPython decompression modules (lzma, bz2, gzip) allow memory corruption via use-after-free when decompressor instances a
Out-of-bounds buffer write in CPython's asyncio.ProactorEventLoop (Windows only) allows remote attackers to trigger memo
Denial of service in CPython's tarfile module allows remote attackers to trigger an infinite loop by supplying a crafted
Stack-based buffer overflow in CPython's bz2.BZ2Decompressor allows remote attackers to crash Python applications by sen
Path traversal in CPython's tarfile module allows a crafted tar archive to bypass the 'data' and 'tar' extraction filter
Certificate hostname verification is silently skipped in CPython's TLS stack when an application enables SSLContext.chec
Command injection in CPython's webbrowser.open() API bypasses previous CVE-2026-4519 mitigation via specially crafted UR
The webbrowser.open() API in CPython accepts URLs with leading dashes, which certain web browsers interpret as command-l
Path traversal in CPython's tarfile module allows malicious tar archives to bypass the data_filter safety mechanism and
CPython's tarfile module on POSIX platforms creates empty directories outside the intended extraction destination when p
EUVD-2026-89183
NVD
CVE.org
EPSS
Vulnrichment
GitHub
VulDB
Exploit-DB