CVE-2026-4372: HuggingFace transformers vulnerable to remote code execution
In transformers before 5.3.0, a model's `config.json` can set `_attn_implementation_internal` to an attacker's Hugging Face Hub repository. Loading that model with `AutoModelForCausalLM.from_pretrained()` then downloads and runs Python code from that repository, with no `trust_remote_code` prompt. Upgrade to transformers 5.3.0.
Published May 26, 2026 · Updated Jul 1, 2026 · Analysis Oct 26, 2026
What an attacker can do
The config class copied extra keys from config.json onto the config object, including the internal field _attn_implementation_internal. A value there that looks like a Hub kernel repository ID makes the library fetch that repository as an attention kernel and execute it, without sandboxing (CWE-502, CWE-1066).
The advisory says this bypasses trust_remote_code, is invisible to the victim and uses the standard documented loading pattern. The victim does nothing unusual: they load a model whose config the attacker wrote. The CVSS vector marks user interaction as required, because the model must be loaded.
The attacker's code runs with the victim's full OS privileges. That gives access to the user's files, cloud credentials, tokens and SSH keys, and lets the attacker install persistence. Notebooks, evaluation workers, CI jobs and inference servers that load community models by name are the usual places this lands. A popular repository whose config is edited, or a new lookalike model, would reach many users. The vector rates the attack as local with high impact on all three properties.
Who is affected
The transformers package on PyPI, all versions before 5.3.0. It applies when you load a model from a source you do not control, such as a Hub repository or a downloaded folder. Check:
pip show transformersList the models your jobs load and who owns them. Review any config.json for an _attn_implementation_internal key.
transformers
- Ecosystem
- PyPI
- Affected
- < 5.3.0
- Fixed in
- 5.3.0
- Check
pip show transformers
How to fix it
Upgrade to transformers 5.3.0:
pip install --upgrade 'transformers>=5.3.0'The fix is commit a7f8e7f. In configuration_utils.py, the loop that sets extra kwargs now skips _attn_implementation_internal and _experts_implementation_internal, so Hub configs cannot set them. In integrations/hub_kernels.py, is_kernel() now accepts a kernel only if its owner is kernels-community. Any other owner logs a one-time warning and the kernel is skipped.
The sources give no workaround. Until you upgrade, load only models from repositories you trust, pin revisions, and inspect config.json first.
How to tell if you were hit
Scan the config.json files of models you have loaded for the _attn_implementation_internal key. Check the Hub download cache (~/.cache/huggingface) for kernel repositories you did not expect. Look for unexpected child processes or outbound connections from jobs right after a model load. After upgrading, a one-time warning about a kernel from an owner other than kernels-community means a config asked for one.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
A critical remote code execution vulnerability exists in all versions of the HuggingFace transformers library prior to version 5.3.0. The vulnerability allows an attacker to craft a malicious config.json file containing the _attn_implementation_internal field set to an attacker-controlled HuggingFace Hub repository ID. When a victim loads this model using the standard AutoModelForCausalLM.from_pretrained() API, the library downloads and executes arbitrary Python code from the attacker's repository with the victim's full OS privileges. This issue arises due to unfiltered deserialization of configuration attributes, insufficient sanitization of internal fields, and unsandboxed execution of downloaded kernels. The vulnerability bypasses the trust_remote_code security mechanism, is invisible to the victim, and exploits the standard documented usage pattern, making it particularly severe. Users are advised to upgrade to version 5.3.0 or later to mitigate this issue.
Credited to aaronmaxlevy.
Questions
- Does trust_remote_code=False protect me?
No. The advisory says the attack bypasses
trust_remote_code. The code is fetched through the attention kernel path set by the config field.- Which version fixes CVE-2026-4372?
transformers 5.3.0. All earlier versions are affected.
- Does it need user interaction?
Yes. A victim has to load the malicious model, but the call is the standard
from_pretrained()usage.- Is it exploited in the wild?
The sources do not say so, and there is no CISA KEV flag. The EPSS score is 0.007.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Transformers vulnerabilities
All Transformers entriesCVE-2026-80047
Hugging Face Transformers downloads custom generation code before trust consent
high7.8No fixSep 1, 2026CVE-2026-9856
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
high7.1Aug 2, 2026CVE-2026-5241
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
high8.0Jun 3, 2026CVE-2026-1839
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
medium6.5Apr 7, 2026CVE-2025-6921
Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer
medium5.3Sep 23, 2025CVE-2025-6051
Hugging Face Transformers library has Regular Expression Denial of Service
medium5.3Sep 14, 2025
