CVE-2023-2800: transformers has Insecure Temporary File
Hugging Face transformers 4.29.2 and earlier create a temporary file insecurely (CWE-377). The fix in pull request 23372 swaps tempfile.mktemp for tempfile.mkstemp in src/transformers/utils/hub.py. A local user on the same machine may be able to interfere with the file. Upgrade to transformers 4.30.0.
Published May 18, 2023 · Updated Nov 22, 2024 · Analysis Nov 2, 2026
What an attacker can do
Python's tempfile.mktemp only returns a file name. It does not create the file. Between choosing the name and opening it, another local process can create a file or symlink at that name. That is the classic race behind CWE-377. The fix replaces it with mkstemp, which creates the file atomically with safe permissions.
The advisory text is thin. The pull request does not describe the exact exploit, and the sources do not say which download path was hit. The CVSS vector is local access, high attack complexity, low privileges, and only an availability impact. So the realistic risk is a local user disrupting a victim's download or model-cache operation on a shared host, for example a multi-user server or CI machine.
It is not remotely exploitable and does not give code execution by itself, according to the scoring. Treat it as low urgency unless you run transformers on shared machines.
Who is affected
pip package transformers 4.29.2 and earlier, meaning anything before 4.30.0. Check:
pip show transformersSingle-user laptops and isolated containers have little exposure, since the attack needs another local account on the same host.
transformers
- Ecosystem
- PyPI
- Affected
- < 4.30.0
- Fixed in
- 4.30.0
- Check
pip show transformers
How to fix it
Upgrade to transformers 4.30.0 or later:
pip install --upgrade "transformers>=4.30.0"The fix is commit 80ca92470938bbcc348e2d9cf4734c7c25cb1c43, from pull request 23372. No workaround is named in the sources. On shared hosts, set a private temporary directory for the process, for example through the TMPDIR environment variable, until you upgrade.
How to tell if you were hit
There is no specific log line. On shared hosts, look in the temp directory for unexpected symlinks or files owned by other users with names that match transformers downloads. Check that your code base and lock files pin transformers at 4.30.0 or later.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Insecure Temporary File in GitHub repository huggingface/transformers 4.29.2 and prior. A fix is available at commit 80ca92470938bbcc348e2d9cf4734c7c25cb1c43 and has been released as part of version 4.30.0.
Credited to sfblackl-intel.
Questions
- Is CVE-2023-2800 remotely exploitable?
No. The CVSS vector is local. The attacker needs a low-privilege account on the same machine and must win a race.
- Which transformers release fixes it?
4.30.0. The affected range is 4.29.2 and earlier.
- What code changed?
The pull request changes a tempfile.mktemp call to tempfile.mkstemp in src/transformers/utils/hub.py. The mktemp function is deprecated because of the race it allows.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Transformers vulnerabilities
All Transformers entriesCVE-2026-80047
Hugging Face Transformers downloads custom generation code before trust consent
high7.8No fixSep 1, 2026CVE-2026-9856
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
high7.1Aug 2, 2026CVE-2026-5241
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
high8.0Jun 3, 2026CVE-2026-4372
HuggingFace transformers vulnerable to remote code execution
high7.8May 26, 2026CVE-2026-1839
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
medium6.5Apr 7, 2026CVE-2025-6921
Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer
medium5.3Sep 23, 2025
