Race condition in the cleanup of `tempfile.TemporaryDirectory`
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.