{"vuid":"VU#456290","idnumber":"456290","name":"Hugging Face Transformers library writes remote code to disk prior to consent check","keywords":null,"overview":"### Overview\r\nA vulnerability in the Hugging Face Transformers library (versions 4.49.0 through 5.8.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.\r\n\r\n### Description\r\nHugging 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.49.0 through 5.8.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.\r\n\r\n### Impact\r\nThe 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.\r\n\r\n### Solution\r\nAt the time of writing, no vendor-provided patch or advisory is available. Users should avoid invoking `load_custom_generate()` with untrusted model repositories and periodically inspect or clear the Hugging Face module cache (`~/.cache/huggingface/modules`) to remove unexpected content. Implementations should ensure that `trust_remote_code` checks occur prior to any remote content retrieval or local file writes.\r\n\r\n### Acknowledgements\r\nThank you to Prasanna Dabi for reporting this vulnerability. This document was written by Bob Kemerer.","clean_desc":null,"impact":null,"resolution":null,"workarounds":null,"sysaffected":null,"thanks":null,"author":null,"public":["https://github.com/huggingface/transformers"],"cveids":["CVE-2026-80047"],"certadvisory":null,"uscerttechnicalalert":null,"datecreated":"2026-09-01T13:35:43.271683Z","publicdate":"2026-09-01T13:35:43.148962Z","datefirstpublished":"2026-09-01T13:35:43.290043Z","dateupdated":"2026-09-01T13:35:43.148958Z","revision":1,"vrda_d1_directreport":null,"vrda_d1_population":null,"vrda_d1_impact":null,"cam_widelyknown":null,"cam_exploitation":null,"cam_internetinfrastructure":null,"cam_population":null,"cam_impact":null,"cam_easeofexploitation":null,"cam_attackeraccessrequired":null,"cam_scorecurrent":null,"cam_scorecurrentwidelyknown":null,"cam_scorecurrentwidelyknownexploited":null,"ipprotocol":null,"cvss_accessvector":null,"cvss_accesscomplexity":null,"cvss_authentication":null,"cvss_confidentialityimpact":null,"cvss_integrityimpact":null,"cvss_availabilityimpact":null,"cvss_exploitablity":null,"cvss_remediationlevel":null,"cvss_reportconfidence":null,"cvss_collateraldamagepotential":null,"cvss_targetdistribution":null,"cvss_securityrequirementscr":null,"cvss_securityrequirementsir":null,"cvss_securityrequirementsar":null,"cvss_basescore":null,"cvss_basevector":null,"cvss_temporalscore":null,"cvss_environmentalscore":null,"cvss_environmentalvector":null,"metric":null,"vulnote":239}