CVE-2026-4372 Arbitrary Remote Code Execution via `_attn_implementation_internal` Config Injection in huggingface/transformers
Attackers can execute arbitrary code by crafting a malicious config file that bypasses security checks when loading models in the HuggingFace transformers library.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2026-4372?
CVE-2026-4372 is a high-severity unsafe deserialization vulnerability in huggingface/transformers, published on 24 May 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Official description
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.
Which versions are affected by CVE-2026-4372?
3 open source packages ship an affected version, including transformers. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
transformers PyPI | All versions | 5.3.0 |
transformers PyPI | All versions | 5.3.0 |
transformers PyPI | All versions | 5.3.0 |
Products include Huggingface Transformers.
How do I fix CVE-2026-4372?
Upgrade transformers to 5.3.0 or later.
Upgrade, and only deserialise data from trusted sources or with an allow-list of types. More about Unsafe deserialization.
Is CVE-2026-4372 being exploited?
There is no known exploitation of CVE-2026-4372 in the wild and no public exploit code.
Public exploit code: 1 proofs of concept on GitHub.
Other vulnerabilities in huggingface/transformers
- CVE-2023-7018 Deserialization of Untrusted Data in huggingface/transformers
- CVE-2023-6730 Deserialization of Untrusted Data in huggingface/transformers
- CVE-2024-11393 Hugging Face Transformers MaskFormer Model Deserialization of Untrusted Data Remote Code Execution Vulnerability
- CVE-2024-11394 Hugging Face Transformers Trax Model Deserialization of Untrusted Data Remote Code Execution Vulnerability
- CVE-2026-5241 Policy Bypass in LightGlue Nested Config Resolution in huggingface/transformers
Sources
Also known as CLSA-2026-1783386115, ECHO-f851-2f9e-9461, GHSA-29pf-2h5f-8g72, PYSEC-2026-2289.