Hugging Face Transformers downloads custom generation code before trust consentGHSA-x9r9-c232-4q39
HIGHFix: huggingface/transformers#48620GHSA-x9r9-c232-4q39 is a high-severity (CVSS 7.8) CWE-273 vulnerability in transformers. No vendor fix is recorded yet; mitigation options are listed below.
Exploitation Status
No confirmed exploitation observed yet
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-x9r9-c232-4q39.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
GHSA-x9r9-c232-4q39 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
transformersReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | transformers | ≥ 4.49.0 | No fix |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for transformers, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Remediation status
No patched version of transformers has shipped for GHSA-x9r9-c232-4q39 yet. Where your build allows, override or pin the dependency away from the vulnerable range, and apply any maintainer-recommended mitigation.
Mitigate without a patch
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
Red Hat Product Security has determined that this issue affects Red Hat OpenShift AI, Red Hat Enterprise Linux AI, Ansible Automation Platform Lightspeed, and OpenShift Lightspeed products that bundle the Hugging Face Transformers library (versions 4.49.0 through 5.8.1). The vulnerability allows remote Python files to…
Until a fix is available, users should only load models from trusted repositories. Avoid using the GenerativePreTrainedModel.load_custom_generate() function with models from untrusted or unknown sources. Organizations should implement controls to restrict which model repositories their AI/ML workloads can access.Source: Red Hat security advisory for GHSA-x9r9-c232-4q39 (CC BY 4.0)
Frequently Asked Questions
Is GHSA-x9r9-c232-4q39 in your dependencies?
Find it across PyPI, including transitive dependencies.