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.
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 the Hugging Face Transformers library allows an attacker to write arbitrary Python files to the user’s local cache before a trust consent check is performed. The load_custom_generate() function downloads and stores a remote module file in the ~/.cache/huggingface/modules directory, bypassing the trust_remote_code prompt even when the user declines consent. While the library still prevents execution of the downloaded code in that session, the unconditional write leaves malicious files on disk permanently and can lead to stale cache collisions when the same module is later loaded under a trusted flag. This persistence creates a potential vector for later execution and for covering tracks by defacing the cache.

Affected Systems

The issue affects all releases of the Hugging Face Transformers library from version 4.49.0 through 5.8.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 3, 2026 at 16:47 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Transformers library to version 5.8.2 or later, where the pre-consent file write path has been removed.
  • If you must use load_custom_generate(), use trust_remote_code=True only after verifying the source and reviewing the downloaded module; otherwise set trust_remote_code=False to prevent loading.
  • Clear or disable the Hugging Face module cache by removing the ~/.cache/huggingface/modules directory or setting the environment variable HUGGINGFACE_HUB_DISABLE_CACHE=1 to stop caching of untrusted modules.

Generated by OpenCVE AI on September 3, 2026 at 16:47 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

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-15T18:20:04.348Z

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-03T17:53:32.027

Link: CVE-2026-80047

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-03T17:00:06Z

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