Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
ReconAttacker uploads malicious generate.py to controlled model repo
-
DeliveryVictim calls load_custom_generate() on attacker-controlled model
-
ExploitLibrary fetches remote file before trust_remote_code check
-
InstallMalicious Python written unconditionally to ~/.cache/huggingface/modules/
-
C2User declines trust prompt but file persists on disk
-
ExecuteFuture trusted model load resolves poisoned cache entry
-
ImpactAttacker code executes in victim Python environment
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V8 - Authorization Privilege drop verification
|
| Exploitation Conditions | The user must explicitly call GenerativePreTrainedModel.load_custom_generate() on a model repository controlled by the attacker - this function is not invoked automatically by standard model loading via AutoModel or AutoTokenizer, so users of standard loading paths are unaffected. The attacker must control or compromise a Hugging Face Hub model repository and place a malicious custom_generate/generate.py within it. Immediate arbitrary code execution is limited by the trust_remote_code gate that correctly fires after the file write; actual execution of the cached malicious module requires a subsequent model load that resolves against the poisoned cache entry without triggering a fresh consent check. Users who do not call load_custom_generate(), who only load models from verified repositories, or who routinely clear ~/.cache/huggingface/modules/ face negligible residual risk. |
| Impact | The provided CVSS 7.8 with AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H overstates the impact in several dimensions. The attack vector is arguably AV:N, not AV:L: the attacker controls a remote model repository, and the victim fetches from it - however, user interaction is required (UI:R). C:H and A:H reflect the secondary, conditional threat of eventual code execution via cache poisoning rather than the confirmed direct impact, which is an unauthorized file write (I:H); the description explicitly states execution is correctly gated. EPSS of 0.11% at the 1st percentile confirms very low current exploitation probability. There is no CISA KEV listing and no public PoC. Real-world risk is moderate and largely confined to ML developers and researchers who call load_custom_generate() against third-party or untrusted model repositories. The cache-collision execution path requires a specific sequence - a poisoned cache entry surviving into a future trusted model load - which is plausible but not automatic. CVSS vector metric AV:L appears inconsistent with the described remote-repository attack scenario; verify with vendor. |
| Exploit ScenarioDerived | An attacker publishes a malicious Hugging Face model repository containing a weaponized custom_generate/generate.py. A developer calls load_custom_generate() on this model; Transformers silently fetches and writes the malicious Python file to ~/.cache/huggingface/modules/ before presenting the trust prompt. Even if the user declines, the file persists and may be silently loaded in a future session when a trusted model triggers module cache resolution against the poisoned entry. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Sep 03, 2026
Write-before-consent in Hugging Face Transformers' GenerativePreTrainedModel.load_custom_generate() allows attacker-controlled Python files to be silently written to ~/.cache/huggingface/modules/ even when the user declines the trust prompt. Affected versions span 4.49.0 through 5.8.1. While immediate execution is blocked by the trust gate, the persisted cache file creates a stale-cache collision risk: subsequent loads of unrelated trusted models may inadvertently execute the previously cached, attacker-supplied Python code. No public exploit has been identified at time of analysis.
RemediationAI
Upgrade Hugging Face Transformers to a version beyond 5.8.1 when a patched release is published; monitor https://github.com/huggingface/transformers for a fix targeting dynamic_module_utils.py. No vendor-released patch version has been independently confirmed at time of analysis - the fix version is unknown and should not be assumed. As an immediate compensating control, avoid calling GenerativePreTrainedModel.load_custom_generate() with models from repositories you do not own or have not independently verified; this eliminates the attack surface entirely since the vulnerable code path is not triggered by standard AutoModel/AutoTokenizer loading. Additionally, periodically clear ~/.cache/huggingface/modules/ to remove any stale or potentially unauthorized cached Python modules, directly mitigating the cache-collision execution risk (trade-off: cache re-population on next load). Restrict trust_remote_code use to model repositories under organizational control. See CERT/CC VU#456290 for additional guidance.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Hugging Face Transformers is a widely deployed Python ML library for loading and using pre-trained models. The affected code path lives in dynamic_module_utils.py, which handles dynamic loading of Python modules from remote model repositories. The function load_custom_generate() inside GenerativePreTrainedModel fetches and unconditionally writes the remote custom_generate/generate.py to the local HuggingFace module cache before invoking the trust_remote_code consent check - inverting the security model used by all other loaders (AutoConfig, AutoModel, AutoTokenizer), which gate the file write behind user consent. CWE-273 (Improper Check for Dropped Privileges) captures the pattern: a security-relevant operation (file write to a Python module directory) proceeds before verifying the required authorization (user consent), meaning the authorization decision is rendered moot for the file persistence effect even when enforced for execution. CPE: cpe:2.3:a:hugging_face:transformers:*:*:*:*:*:*:*:*.
Know when Transformers gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Attacker is remote (controls model repo, UI:R for victim action); confirmed impact is unauthorized file write (I:H); code execution is conditional on cache collision (C:L, A:N).
Primary rating from Vendor (certcc).
CVSS VectorVendor: certcc
Lifecycle Timeline
3DescriptionCVE.org
A vulnerability in Hugging Face Transformers (versions 4.49.0, <= 5.8.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.
Blast Radius
ecosystem impact- 66 pypi packages depend on transformers (61 direct, 5 indirect)
Ecosystem-wide dependent count for version 4.49.0.
Executive ViewAI
Hugging Face Transformers (versions 4.49.0-5.8.1) contains a cache-poisoning vulnerability allowing attackers to persist malicious Python code in user caches despite explicit trust rejection. This creates supply-chain risk where subsequent model loads may unknowingly execute persisted attacker payloads. Organizations deploying Hugging Face for ML inference lack immediate patch mitigation, creating undetected code-execution exposure in production AI pipelines.
Clear and isolate model cache directories (~/.cache/huggingface/modules/); restrict model loading to curated internal sources only; implement model provenance logging and validation; disable dynamic model downloads in production environments; consider network-level restrictions on Hugging Face Hub access where feasible.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Authentication bypass attacks exploit flaws in the verification mechanisms that control access to systems and applications.
More in Transformers
View allThe huggingface/transformers library is vulnerable to arbitrary code execution through deserialization of untrusted data
Deserialization of Untrusted Data in GitHub repository huggingface/transformers prior to 4.36. Rated high severity (CVSS
Deserialization of Untrusted Data in GitHub repository huggingface/transformers prior to 4.36. Rated high severity (CVSS
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the huggingface/transformers repository,
The huggingface/transformers library, versions prior to 4.53.0, is vulnerable to Regular Expression Denial of Service (R
A Regular Expression Denial of Service (ReDoS) vulnerability was identified in the huggingface/transformers library, spe
Remote code execution in Hugging Face Transformers 5.2.0 allows a malicious model repository to bypass the user's explic
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, sp
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, sp
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, sp
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, sp
Hugging Face Transformers Trax Model Deserialization of Untrusted Data Remote Code Execution Vulnerability. Rated high s
EUVD-2026-69144
GHSA-x9r9-c232-4q39
NVD
CVE.org
EPSS
Vulnrichment
VulDB
Exploit-DB