---
id: CVE-2026-80047
title: >-
  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()
summary: >-
  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 ca…
severity: high
cvss: 7.8
cvssVector: 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'
cwe:
  - CWE-273
  - CWE-367
  - CWE-494
vendor: Hugging Face
product: Transformers
affected:
  - Transformers >= 4.57.0 <= 5.16.1
published: '2026-09-01'
updated: '2026-09-23'
sourceUpdated: '2026-09-23T18:17:08.843'
source: NVD
sourceUrl: 'https://nvd.nist.gov/vuln/detail/CVE-2026-80047'
references:
  - url: 'https://github.com/huggingface/transformers'
    label: cret@cert.org
  - url: 'https://kb.cert.org/vuls/id/456290'
    label: cret@cert.org
  - url: 'https://www.kb.cert.org/vuls/id/456290'
    label: af854a3a-2127-422b-91ae-364da2661108
tags:
  - nvd
  - cve.org
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: total
  timestamp: '2026-09-03T13:52:40.495489Z'
epss: 0.00099
epssPercentile: 0.00759
ingestedAt: '2026-09-15T18:41:59.181Z'
---

## Overview

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.

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.
