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.
Published: 2026-09-01
Score: 7.8 High
EPSS: < 1% Very Low
KEV: No
Impact: Persistent Unauthorized Local File Write
Action: Patch Now
AI Analysis

Impact

A flaw in Hugging Face Transformers between versions 4.57.0 and 5.16.1 lets an attacker upload arbitrary Python files to a user‑owned local cache before any trust consent check occurs. When GenerativePreTrainedModel.load_custom_generate() is called, it fetches and stores a remote module file in ~/.cache/huggingface/modules, ignoring the trust_remote_code prompt even if the user declines consent. The library blocks execution in the current session, but the unconditional write leaves malicious code on disk, persisting across sessions and potentially being executed later when the same module is loaded under a trusted flag. This creates a persistent vector for future exploitation and for tampering with the cache.

Affected Systems

The issue affects all releases of the Hugging Face Transformers library from version 4.57.0 through 5.16.1 inclusive. Users who employ GenerativePreTrainedModel.load_custom_generate() for custom generation or packaging of models are exposed, while other typical loading paths such as AutoConfig, AutoModel, or AutoTokenizer remain unaffected.

Risk and Exploitability

Based on the description, it is inferred that the attack can be carried out remotely by hosting a malicious script and invoking load_custom_generate() or locally by manipulating mirror sources. The unconditional file write before user consent creates a persistence vector. The CVSS score is 7.8, the EPSS score is < 1%, and the vulnerability is not listed in the CISA KEV catalog. The lack of publicly known exploitation coupled with the need for a valid model path suggests that the likelihood of widespread exploitation is moderate, but the potential impact includes persistent unauthorized files and the risk of future execution.

Generated by OpenCVE AI on September 23, 2026 at 18:53 UTC.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade to the latest version of the Hugging Face Transformers library, or to any release beyond version 5.16.1 where the issue has been fixed; consult the official security advisory to confirm the fix.
  • If an upgrade cannot be performed immediately, clear or disable the Hugging Face module cache by removing the ~/.cache/huggingface/modules directory or by setting the environment variable HUGGINGFACE_HUB_DISABLE_CACHE=1 to prevent untrusted code from being written to disk.
  • When using load_custom_generate(), set trust_remote_code=False or manually verify and inspect the downloaded module before loading; the current path ignores the consent prompt regardless of the flag.

Generated by OpenCVE AI on September 23, 2026 at 18:53 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-x9r9-c232-4q39 Hugging Face Transformers downloads custom generation code before trust consent
History

Wed, 23 Sep 2026 17:30:00 +0000

Type Values Removed Values Added
Description A vulnerability in Hugging Face Transformers (versions >= 4.49.0 and <= 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. 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.

Thu, 03 Sep 2026 15:30:00 +0000

Type Values Removed Values Added
Weaknesses CWE-273
CWE-367
CWE-494
Metrics cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'}

ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Wed, 02 Sep 2026 03:00:00 +0000

Type Values Removed Values Added
Weaknesses CWE-755
CWE-94

Tue, 01 Sep 2026 22:00:00 +0000

Type Values Removed Values Added
Description 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. A vulnerability in Hugging Face Transformers (versions >= 4.49.0 and <= 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.
Weaknesses CWE-755
CWE-94

Tue, 01 Sep 2026 15:30:00 +0000

Type Values Removed Values Added
References

Tue, 01 Sep 2026 15:00:00 +0000

Type Values Removed Values Added
First Time appeared Huggingface
Huggingface transformers
Vendors & Products Huggingface
Huggingface transformers

Tue, 01 Sep 2026 13:45:00 +0000

Type Values Removed Values Added
Description 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.
Title Hugging Face Transformers library writes remote code to disk prior to consent check
References

Subscriptions

Huggingface Transformers
cve-icon MITRE

Status: PUBLISHED

Assigner: certcc

Published:

Updated: 2026-09-23T17:24:14.772Z

Reserved: 2026-08-25T17:29:08.429Z

Link: CVE-2026-80047

cve-icon Vulnrichment

Updated: 2026-09-01T14:08:14.152Z

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-09-01T14:17:41.943

Modified: 2026-09-23T18:17:08.843

Link: CVE-2026-80047

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-23T19:00:08Z

Weaknesses
  • CWE-273

    Improper Check for Dropped Privileges

  • CWE-367

    Time-of-check Time-of-use (TOCTOU) Race Condition

  • CWE-494

    Download of Code Without Integrity Check