python / python/cpython

Race condition in the cleanup of `tempfile.TemporaryDirectory`

Open
#157,579 0 comments 0 reactions 1 assignee View on GitHub

@StanFromIreland is already working on this.

Since Sep 15, 2026.

3.10 3.11 3.12 3.13 3.14 3.16 stdlib type-security
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

When working around file system permission errors, files are removed after resolving their path again, this means that by replacing a directory of the tree with a symbolic link, an attacker can make the cleanup delete files outside of the temporary directory.

Linked PRs
  • gh-157580

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.