AI analysis
CPython's tempfile.TemporaryDirectory cleanup has a local race condition (CWE-59) during removal of the temporary tree. An attacker who can change that tree while cleanup runs can swap a directory for a symbolic link so that files outside the temporary directory are deleted or have their permissions and file flags reset, using the privileges of the process doing the cleanup. Platforms where shutil.rmtree.avoids_symlink_attacks is false stay affected by out-of-tree deletion, and file flags can still be reset outside the tree on all platforms. Any application or service that uses TemporaryDirectory and can be influenced by a local attacker during cleanup is in scope; exact affected version ranges are not stated. CVSS 4.0 is 5.9 (medium), it is not on the CISA KEV list, and no public proof-of-concept is known.
What to do: Track the CPython security advisory for this CVE and upgrade to a fixed release as soon as one is published; no fixed version range is stated in the current data. Until then, avoid running untrusted local code that can alter a TemporaryDirectory tree while cleanup is in progress, and treat platforms where shutil.rmtree.avoids_symlink_attacks is false as still exposed to deletion outside the tree. Review processes that clean temporary directories with elevated privileges, because file deletion, permission changes, and file-flag resets occur with the privileges of the cleaning process.
Affected
| Python Software Foundation CPython | — |
Estimated exposure
massHundreds of millions of CPython installations (order of magnitude; vulnerable version range not stated) — CPython is the reference Python runtime and is shipped on a very large share of servers, desktops, containers, and CI systems; public language-adoption figures put active Python environments well into the hundreds of millions, though this…
Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.
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.