MilikMilik

Malicious AI Models and the Hugging Face Transformers Remote Code Execution Flaw

Malicious AI Models and the Hugging Face Transformers Remote Code Execution Flaw
Interest|High-Quality Software

What the Hugging Face Vulnerability Means for Your AI Stack

The Hugging Face vulnerability is a remote code execution weakness in the Transformers library that allows malicious model configuration files to trigger arbitrary attacker-controlled code during normal model loading, potentially exposing credentials, data, and downstream systems whenever an organization downloads and runs untrusted AI models from public repositories. This flaw, tracked as CVE-2026-4372, affects Transformers when the optional kernels package is installed, a common setup in GPU-accelerated environments and transformers[all] installations. According to Pluto researchers, “one poisoned field in a model’s config.json silently executes arbitrary code on anyone who loads it. No special flags. No warnings. Just the standard from_pretrained() call.” Because the attack runs inside ordinary Machine Learning workflows, any team using external models without strong AI supply chain security controls is at risk of remote code execution AI attacks.

How Attackers Exploit Malicious ML Models via Config Poisoning

The root cause lies in how Transformers handled config.json files. Vulnerable versions used a generic setattr() call that applied configuration fields directly to internal objects, including private attributes never meant to be influenced by untrusted data. One of these attributes, _attn_implementation_internal, selects which attention kernels the library uses. By setting this field to point at a malicious kernel repository on Hugging Face Hub, an attacker can make Transformers automatically download and import their Python code during a routine from_pretrained() call, even with trust_remote_code=False. This turns a normal model load into a remote code execution AI event. Exploitation needs no extra permissions, flags, or user interaction beyond loading the poisoned model, which makes trojanized models a powerful AI supply chain security threat in shared or automated ML pipelines.

From Credentials to Cloud: Impact on AI Supply Chain Security

Once the malicious code executes, an attacker can do anything the hosting process can do. In many ML environments, that includes reading environment variables, accessing shared file systems, and contacting external services. Researchers showed that compromised models could expose cloud credentials, API tokens, and SSH keys, giving attackers a foothold into wider infrastructure beyond the immediate ML workload. Vulnerable Transformers versions were downloaded about 232 million times before patches, which underlines how quickly a single design flaw can spread across AI supply chains. This is a textbook AI supply chain security issue: downstream teams inherit risk through dependencies and third-party models they never wrote. If your inference or training systems run with broad permissions, malicious ML models loaded through this Hugging Face vulnerability can escalate a small configuration trick into a full-scale infrastructure compromise.

Practical Mitigations for Teams Using Open-Source AI Models

Teams should start by upgrading to the latest patched Transformers release and reviewing any environments that include the optional kernels package, especially those installed with transformers[all]. Restrict use of unapproved third-party models and maintain an accurate SBOM and AI asset inventory so you know which models and versions run where. Run untrusted or newly downloaded models in sandboxed, isolated environments with limited permissions, and avoid storing long-lived credentials or sensitive secrets on systems that load external models. Network controls also matter: restrict outbound connections from ML infrastructure and monitor unusual model downloads, repository references, or package imports that may signal poisoned models. Finally, test your incident response plans with scenarios focused on malicious ML models and AI supply chain security, so you can detect, contain, and recover quickly if a remote code execution AI incident occurs.

Milik earns a commission when you shop through our links, at no extra cost to you. Editorial content is independently selected by our team.

You May Also Like

Comments
Say something...
No comments yet. Be the first to share your thoughts!