search menu icon-carat-right cmu-wordmark

CERT Coordination Center

Hugging Face Transformers library writes remote code to disk prior to consent check

Vulnerability Note VU#456290

Original Release Date: 2026-09-01 | Last Revised: 2026-09-24

Overview

A vulnerability in the Hugging Face Transformers library (versions 4.57.0 to 5.16.1) allows remote, attacker‑controlled Python files to be written to the local disk without user authorization. The library performs a remote module fetch and local cache write before evaluating the trust_remote_code consent prompt, violating the security contract enforced across other dynamic module-loading paths in the library.

Description

Hugging Face Transformers serves as a primary framework for defining and operating modern machine learning models including NLP, computer vision, audio, video, and multimodal systems, for both training and inference. As detailed in CVE‑2026‑80047, affected versions (4.57.0 to 5.16.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 by resolve_trust_remote_code(). Although execution of the module is correctly gated, the initial file write is unconditional. As a result, remote code from a repository’s custom_generate/generate.py is copied into ~/.cache/huggingface/modules regardless of whether the user ultimately approves or declines the trust prompt. This behavior differs from other remote code-loading mechanisms in the Transformers library (including AutoConfig, AutoModel, AutoTokenizer, and AutoImageProcessor), all of which perform trust_remote_code verification before fetching or writing any remote Python content. The root cause is an unconditional file copy operation in dynamic_module_utils.py that occurs prior to consent evaluation and cannot be rolled back. An attacker may publish a model repository containing a malicious custom_generate/generate.py file. Any downstream user who loads the model reference triggers the file‑write behavior without requiring elevated privileges or additional interaction beyond the initial load attempt.

Impact

The vulnerability results in persistent unauthorized Python files being written to the user’s local module cache. This content remains on the disk even if the user declines the trust prompt. In environments where cache paths are reused, previously written attacker files may be served later during trusted model loads, which could enable unintended execution of cached code.

Solution

This vulnerability has been fixed in version 5.17.0. It is recommended that all users update to the latest version of the Hugging Face Transformers library.

Acknowledgements

Thank you to Prasanna Dabi for reporting this vulnerability. This document was written by Bob Kemerer.

Vendor Information

456290
 

Hugging Face Affected

Notified:  2026-08-04 Updated: 2026-09-24

Statement Date:   September 24, 2026

CVE-2026-80047 Affected

Vendor Statement

Vendor status: Affected. Fixed in transformers 5.17.0 (released 2026-09-09). Assessed severity: Low (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N, 4.3).

Hugging Face confirms the behavior in VU#456290: load_custom_generate() fetched a repository's custom_generate/generate.py into the local dynamic module cache before the trust_remote_code consent check. Consent still governed execution, which remained gated, so a user who declined did not run the code. The defect was that the file was written before consent was evaluated. The file originates from a repository the caller named explicitly. This is resolved in 5.17.0 (PR #48620, commit cbc1651).

This is a client library issue. No Hugging Face hosted service executes this path; exposure is limited to machines running transformers.

The affected range is 4.57.0 through 5.16.1. load_custom_generate() does not exist before 4.52, and 4.52 through 4.56.2 perform the consent check before fetching. The ordering was inverted in 4.57.0. In 4.57.0 through 4.57.6 a plain from_pretrained() call on a repository containing custom_generate/generate.py was enough to trigger the write; from 5.0.0 it required an explicit custom_generate argument.

We do not agree with the CVSS 3.1 vector added by CISA-ADP and carried in NVD and GHSA-x9r9-c232-4q39 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H, 7.8). A vector asserting complete confidentiality, integrity and availability impact describes code execution, which the advisory's own description states is correctly gated. Our assessment is CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N, 4.3 Low: the artifact is a file written to a cache directory, sourced from a repository the caller named explicitly, and it is not executed without consent.

We also do not support one impact stated in the advisory, that stale cache collisions may cause cached code to be executed during later trusted model loads. For a Hub repository, both the cache path and the resulting Python module name include the resolved 40-character commit hash of the source repository, so two repositories, or two revisions of one repository, cannot share a cached path. We would welcome a proof of concept if the reporter has one.

For users who cannot upgrade immediately: do not pass custom_generate for repositories you have not reviewed, and on 4.57.x do not call from_pretrained() on unreviewed repositories that contain custom_generate/generate.py; clear cached modules with rm -rf ~/.cache/huggingface/modules, which is rebuilt on demand and does not require clearing the weight cache at ~/.cache/huggingface/hub; set HF_HUB_OFFLINE=1 on runtimes working from pre-fetched weights.

We thank Prasanna Dabi for the report and CERT/CC for coordinating disclosure.

References


Other Information

CVE IDs: CVE-2026-80047
API URL: VINCE JSON | CSAF
Date Public: 2026-09-01
Date First Published: 2026-09-01
Date Last Updated: 2026-09-24 15:30 UTC
Document Revision: 4

Sponsored by CISA.