CVE-2026-80047: Hugging Face Transformers Write-Before-Consent Vulnerability Enables Malicious Model RCE
Date: 2026-09-02
Tags: supply-chain, model-poisoning
Executive Summary
A newly disclosed vulnerability in Hugging Face Transformers (CVE-2026-80047) affecting versions 4.49.0 through 5.8.1 allows malicious AI model repositories to place attacker-controlled Python files on a user's system before the user approves remote code execution; the flaw lies in the library's custom generation-loading process and can allow remote Python code to be written to the local Hugging Face module cache without authorization. CERT/CC published the vulnerability record on September 1, 2026.
Campaign Summary
| Field | Detail |
|---|---|
| Campaign / Malware | Hugging Face Transformers Malicious Model Supply Chain Attack Vector |
| Attribution | Unknown (vulnerability disclosure only; no active campaign reported yet) (confidence: low) |
| Target | Developers and ML engineers using Hugging Face Transformers to load custom models from Hugging Face Hub |
| Vector | Malicious model repository containing crafted custom_generate/generate.py file that exploits load_custom_generate() function |
| Status | active |
| First Observed | 2026-09-01 |
Detailed Findings
Affected versions (4.49.0 through 5.8.1) implement GenerativePreTrainedModel.load_custom_generate() such that the library fetches and caches a remote Python module via get_cached_module_file() before evaluating user consent via resolve_trust_remote_code(); although execution of the module is correctly gated, the initial file write is unconditional, resulting in remote code from a repository's custom_generate/generate.py being copied into ~/.cache/huggingface/modules regardless of whether the user ultimately approves or declines the trust prompt. The file write is not reversible and can persist across sessions, leading to persistent, unauthorized files on disk and stale cache collisions where cached attacker code may later be executed during trusted model loads. Hugging Face Transformers is widely used to train, deploy, and run machine learning models for natural language processing, computer vision, audio, video, and multimodal AI tasks, and because the framework is commonly integrated into developer workstations, research environments, cloud notebooks, and production ML pipelines, the vulnerability could expose a broad range of users to untrusted content from model repositories.
MITRE ATT&CK Mapping
| Technique | ID | Context |
|---|---|---|
| Supply Chain Compromise | T1195.001 | Attacker compromises third-party model repository on Hugging Face Hub to distribute trojanized models containing malicious custom_generate.py |
| Execution through API | T1059.006 | Malicious Python code is automatically downloaded and cached without explicit user consent, enabling code execution through the Transformers library API |
IOCs
Domains
huggingface.co
Full URL Paths
_Vulnerability disclosed by security researcher Prasanna Dabi; no active exploit code published at time of disclosure per CERT/CC record_
Splunk Format
"huggingface.co"
Package Indicators
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
pypi:[email protected]
Affected Platforms
Python development environments
ML/AI workstations
CI/CD pipelines
Cloud notebooks
Detection Recommendations
Organizations using Hugging Face Transformers should immediately upgrade to patched versions (5.8.2 or later). Defenders should audit ~/.cache/huggingface/modules directories on developer workstations for unexpected Python files and monitor for creation of new files in cache directories during model loading operations. Implement file integrity monitoring on cache directories and alert on modifications to custom_generate/generate.py paths. Restrict model downloads to trusted, internally-cached models where feasible. Enable audit logging for all Hugging Face model loading calls and correlate suspicious file creation with model load operations. Red teamers should test whether stale cached files from declined trust prompts can be executed during subsequent trusted model loads (cache collision attack).
References
- [Cyber Security News] Hugging Face Flaw Lets Malicious AI Models Plant Python Code on User Systems (2026-09-02) — https://cybersecuritynews.com/hugging-face-flaw/
- [CERT/CC] VU#456290 - Hugging Face Transformers library writes remote code to disk prior to consent check (2026-09-01) — https://kb.cert.org/vuls/id/456290
- [OffSeq Threat Radar] CVE-2026-80047: CWE-273 Improper Check for Dropped Privileges in Hugging Face Transformers (2026-09-01) — https://radar.offseq.com/threat/cve-2026-80047-cwe-273-improper-check-for-dropped-privileges-in-hugging-face-transformers-1300485eb12bdaff
- [Vista Net, Inc.] VU#456290: Hugging Face Transformers library writes remote code to disk prior to consent check (2026-09-01) — https://www.vistanetinc.com/vu456290-hugging-face-transformers-library-writes-remote-code-to-disk-prior-to-consent-check