CVE-2026-4372 Arbitrary Remote Code Execution via `_attn_implementation_internal` Config Injection in huggingface/transformers

High 7.8 Published Updated

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.

Weakness: CWE-502, CWE-1066

Which versions are affected by CVE-2026-4372?

3 open source packages ship an affected version, including transformers. It affects 1 product.

PackageAffectedFixed in
transformers PyPIAll versions5.3.0
transformers PyPIAll versions5.3.0
transformers PyPIAll versions5.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.

Sources

Also known as CLSA-2026-1783386115, ECHO-f851-2f9e-9461, GHSA-29pf-2h5f-8g72, PYSEC-2026-2289.

Is CVE-2026-4372 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free