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.
Published: 2026-09-01
Score: n/a
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

A vulnerability in the Hugging Face Transformers library allows an attacker to write arbitrary Python files to a local cache before the user consents to load remote code. The malicious file is fetched via GenerativePreTrainedModel.load_custom_generate(), cached in the ~/.cache/huggingface/modules directory, and can persist across future sessions. Because execution of the cached module is still gated by trust_remote_code checks, the file is not immediately executed, but its presence can enable stale cache collisions that lead to later execution when a trusted model load occurs. This results in persistent, unauthorized code on disk and the potential for malicious code to run in future sessions.

Affected Systems

Vulnerable versions of the Hugging Face Transformers library include 4.49.0 and all releases up to and including 5.8.1. The vulnerability affects users who employ GenerativePreTrainedModel.load_custom_generate() to inject remote code into the model pipeline. It does not impact other typical Hugging Face loading paths such as AutoConfig, AutoModel, or AutoTokenizer.

Risk and Exploitability

The vulnerability carries a high risk to confidentiality and integrity of local environments where the Transformers library is used. Although no CVSS score is publicly published, the flaw permits an attacker to leave malicious files in a well‑known cache location, potentially enabling later execution when trusted code loads. EPSS is not available and the flaw is not listed in CISA’s KEV catalog, indicating a lower publicly known exploitation probability, but the attack model requires the attacker to supply or force the loading of a remote module through load_custom_generate(). The attack can be performed remotely by hosting a malicious script and using the API call to pull it, or locally by manipulating local mirror sources. The lack of reversible writes means once the file is cached it remains until the cache is cleared, creating a persistence vector.

Generated by OpenCVE AI on September 1, 2026 at 15:23 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Transformers library to the latest release that removes the pre-consent file write.
  • When using load_custom_generate(), set trust_remote_code=True only after manually reviewing the remote module and ensure that the source is trusted; if the module cannot be verified, use trust_remote_code=False to block loading.
  • Configure the environment variable HUGGINGFACE_HUB_DISABLE_CACHE=1 or clear the ~/.cache/huggingface/modules directory regularly to prevent caching of potentially malicious modules.

Generated by OpenCVE AI on September 1, 2026 at 15:23 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

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-01T14:08:14.152Z

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

Link: CVE-2026-80047

cve-icon Vulnrichment

No data.

cve-icon NVD

Status : Received

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

Modified: 2026-09-01T15:17:29.883

Link: CVE-2026-80047

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-01T14:45:03Z

Weaknesses

No weakness.