# CVE-2026-80047: Hugging Face Transformers library writes remote code to disk prior to consent check

> Attackers can write malicious Python files to disk before consent checks, potentially leading to persistent unauthorized files and future code execution.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 1 Sep 2026
- **Updated:** 23 Sep 2026
- **Also known as:** CLSA-2026-1790831175, ECHO-604e-0a83-9b07, GHSA-x9r9-c232-4q39, MINI-433r-h2fr-55qr, MINI-h9gm-47rv-25hg, MINI-rf48-896p-j5f2, PYSEC-2026-4174

## What is CVE-2026-80047?

CVE-2026-80047 is a high-severity path traversal vulnerability in Hugging Face Transformers, published on 1 Sep 2026. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A vulnerability in Hugging Face Transformers (versions 4.57.0 to 5.16.1) allows remote Python files to be written to local disk without user consent when using GenerativePreTrainedModel.load_custom_generate(). The function fetches and caches a remote module file before performing the required trust_remote_code consent check, inverting the security model enforced by other code-loading paths (such as AutoConfig, AutoModel, and AutoTokenizer). As a result, attacker‑controlled Python code from custom_generate/generate.py is copied into the user’s ~/.cache/huggingface/modules directory even if the user declines the trust prompt. Although execution is correctly gated, the file write is not reversible and can persist across sessions. This can lead to persistent, unauthorized files on disk and stale cache collisions where cached attacker code may later be executed during trusted model loads. The issue stems from an unconditional file write in dynamic_module_utils.py prior to any trust verification.

Weakness: CWE-494 (Download of Code Without Integrity Check), CWE-367 (Time-of-check Time-of-use (TOCTOU) Race Condition), CWE-273 (Improper Check for Dropped Privileges)

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

3 open source packages ship an affected version, including transformers.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `transformers` | PyPI | From 4.49.0 to 5.8.1 | None |
| `transformers` | PyPI | From 4.49.0 to 5.8.1 | None |
| `transformers` | PyPI | From 4.49.0 to 5.8.1 | None |

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

Apply the vendor's patch.

## Is CVE-2026-80047 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2026-80047 is a high-severity path traversal vulnerability in Hugging Face Transformers, published on 1 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-80047 in the wild and no public exploit code.

Affected packages and fixed versions:
- transformers (PyPI): affected from 4.49.0 up to 5.8.1; no fix listed
- transformers (PyPI): affected from 4.49.0 up to 5.8.1; no fix listed
- transformers (PyPI): affected from 4.49.0 up to 5.8.1; no fix listed

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-80047/ (Markdown: https://insights.sbomify.com/CVE-2026-80047/index.md)
```

## Sources

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

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