# CVE-2026-12345: Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory

> Attackers can exploit a race condition in tempfile cleanup to delete files or reset permissions outside the temporary directory via symlink attacks.

- **Severity:** Medium 5.9 (`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`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 29 Sep 2026
- **Updated:** 26 Oct 2026
- **Also known as:** ALPINE-CVE-2026-12345, AZL-105684, AZL-105912, BELL-CVE-2026-12345, BIT-libpython-2026-12345, BIT-python-2026-12345, BIT-python-min-2026-12345, CLSA-2026-1791359868, CLSA-2026-1792794952, DEBIAN-CVE-2026-12345, ECHO-1804-7ef4-53eb, MINI-cg9g-4346-48pp, PSF-2026-42, RHSA-2026:74870, RHSA-2026:74922, RHSA-2026:75119, UBUNTU-CVE-2026-12345

## What is CVE-2026-12345?

CVE-2026-12345 is a medium-severity vulnerability in CPython, published on 29 Sep 2026. It can only be exploited from the same machine or local network, with no action from the victim.

### Official 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.

Weakness: CWE-59 (Improper Link Resolution Before File Access)

## Which versions are affected by CVE-2026-12345?

3 open source packages ship an affected version, including libpython, python and python-min.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libpython` | Bitnami | All versions | 3.12.16, 3.13.18, 3.14.9 |
| `python` | Bitnami | All versions | 3.12.16, 3.13.18, 3.14.9 |
| `python-min` | Bitnami | All versions | 3.12.16, 3.13.18, 3.14.9 |
| `python-unversioned-command` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-debug` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-devel` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-idle` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-libs` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-test` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3-tkinter` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.12` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-debug` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-devel` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-idle` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-libs` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-test` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.12-tkinter` | Red Hat:hummingbird:1 | All versions | 0:3.12.15-1.hum1 |
| `python3.13` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-debug` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-devel` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-freethreading` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-freethreading-debug` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-idle` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-libs` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-test` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.13-tkinter` | Red Hat:hummingbird:1 | All versions | 0:3.13.16-1.hum1 |
| `python3.14` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-debug` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-devel` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-idle` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-libs` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-test` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |
| `python3.14-freethreading-tkinter` | Red Hat:hummingbird:1 | All versions | 0:3.14.8-1.hum1 |

## How do I fix CVE-2026-12345?

Upgrade libpython to a fixed version for your release line: 3.12.16, 3.13.18 or 3.14.9.

## Is CVE-2026-12345 being exploited?

There is no known exploitation of CVE-2026-12345 in the wild and no public exploit code.

Public exploit code:

- Proof of Concept (PoC) for CVE-2026-64638, a reflected XSS in WordPress Core < 7.0.3. (github_poc): https://github.com/zahidec0de/CVE-2026-12345-poc

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-12345 and fix it if it is affected.

What it is: CVE-2026-12345 is a medium-severity vulnerability in CPython, published on 29 Sep 2026. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-12345 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected all versions; fixed in 3.12.16, 3.13.18, 3.14.9
- python (Bitnami): affected all versions; fixed in 3.12.16, 3.13.18, 3.14.9
- python-min (Bitnami): affected all versions; fixed in 3.12.16, 3.13.18, 3.14.9

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-12345/ (Markdown: https://insights.sbomify.com/CVE-2026-12345/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-12345
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-12345
- OSV: https://osv.dev/vulnerability/CVE-2026-12345

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-12345/
Summaries are generated and may contain mistakes; the official description above is the record.
