8 minute read

“We downloaded the model from Hugging Face. It downloaded our credentials to an attacker.”

TL;DR

JFrog found about 100 malicious models on Hugging Face (February 2024). By April 2025, Protect AI had scanned 4.47 million model versions and flagged 352,000 unsafe issues across 51,700 models. nullifAI slipped malicious models past Picklescan, the scanner Hugging Face used. The supply chain spans base models, datasets, adapters, plugins, and RAG corpora. Cryptographic model provenance is the structural fix the ecosystem hasn’t adopted. For how backdoors survive downstream use, see the companion post on Weight poisoning and model backdoors.


A robotic arm in an automated tape library reaching for a discolored cartridge among identical ones

What is the AI model supply chain?

Every component that goes into a production AI system, from the base model to the last data point in the RAG corpus.

Base models are the foundation. Organizations download pre-trained models from Hugging Face, Replicate, or directly from providers. The model’s weights carry everything the pre-training data contained, including any backdoors or biases in the training process.

Fine-tuning datasets shape the model’s behavior for the specific use case. If the fine-tuning data is poisoned (containing adversarial examples, biased samples, or backdoor triggers), the fine-tuned model inherits those properties. Data sourced from the internet, scraped from user interactions, or purchased from data brokers may contain content the organization never reviewed.

Adapters and LoRA weights modify the base model without full retraining. They’re smaller, easier to distribute, and therefore easier to poison and harder to audit. A malicious LoRA adapter from an untrusted source can alter model behavior while the base model appears unchanged.

Plugins and tools (MCP servers, function calling integrations) execute code in the model’s context. A malicious plugin can exfiltrate data, modify outputs, or compromise the host system. With thousands of MCP servers on GitHub and no standard way to verify what their code does, the plugin supply chain looks like npm before lockfiles.

RAG corpora provide the model’s retrieval context. Poisoned documents in the vector store influence every query that retrieves them. The RAG supply chain is anyone who can add documents to the indexed data sources.


How do malicious models reach Hugging Face?

JFrog’s February 2024 discovery found around 100 malicious models using Python’s Pickle deserialization as the attack vector. When a model is saved in Pickle format (the traditional PyTorch format), it can contain a __reduce__ method that executes arbitrary Python code when the model file is loaded. Loading the model = running the attacker’s code. JFrog found models that established reverse shells, granting the attacker full access to the victim’s machine. Since PyTorch 2.6 (January 2025), torch.load() defaults to weights_only=True, which refuses arbitrary objects, but older versions, code that sets weights_only=False, and other Pickle-based loaders remain exposed.

Three upload vectors:

Typosquatting. Upload a malicious model with a name similar to a popular model: bert-base-uncasedd instead of bert-base-uncased. A developer in a hurry downloads the wrong version. The model works (it might even be a copy of the legitimate model) but executes the payload on load.

Hijacked accounts. Compromise a legitimate model author’s Hugging Face account and modify their existing models. The model retains the trusted author’s name and download count. In May 2024, Hugging Face disclosed unauthorized access to Spaces secrets and revoked a number of the tokens stored in them. In December 2023, Lasso Security found 1,600+ exposed Hugging Face API tokens in public repositories, affecting 723 organizations including Google, Meta, and Microsoft.

Direct upload. Simply publish a new model with a Pickle payload. Hugging Face did scan Pickle files at the time of JFrog’s discovery, but it marked suspicious models as unsafe rather than blocking them, so users could still download and load them.


How did nullifAI bypass Picklescan?

Picklescan is the open-source, blocklist-based scanner Hugging Face used to flag suspicious Pickle files. In February 2025, ReversingLabs described nullifAI, an evasion found in two malicious models on the Hub.

The models were PyTorch files compressed with 7z instead of PyTorch’s default ZIP, which also means torch.load() cannot open them directly. More importantly, the Pickle stream was broken just after the malicious payload. Picklescan failed on the broken file and did not flag it. Pickle deserialization, however, executes opcodes in order, so a loader that reads the stream runs the payload (a reverse shell) before it reaches the error. The scanner reported nothing; the payload still ran.

Hugging Face removed the models within 24 hours of ReversingLabs’ report and updated Picklescan to handle broken Pickle files. But the incident demonstrates the fragility of relying on a single scanning tool as the primary security boundary. Any file format change, compression variant, or encoding trick that the scanner doesn’t handle creates a bypass.

Protect AI’s broader scans tell the scale story: by April 2025 it had scanned 4.47 million model versions in 1.41 million repositories and flagged 352,000 unsafe or suspicious issues across 51,700 models (Hugging Face and Protect AI). Scanning every upload is feasible. The weak point is what the scanner knows to look for.


What does model provenance look like?

The structural fix is ensuring every model has a verifiable chain of custody from creation to deployment.

Cryptographic signing. The model creator signs the model files with their private key. Anyone downloading the model can verify the signature against the creator’s public key. If the model was modified after signing (payload injection, weight tampering), the signature fails. This doesn’t prevent a malicious creator from signing a malicious model, but it prevents tampering after the fact.

Hash verification. Every model file should have a published hash (SHA-256 or stronger). Organizations verify the hash of downloaded files against the published hash before loading. This catches tampering in transit and ensures the downloaded file matches what the publisher intended.

SafeTensors format. Hugging Face developed SafeTensors as a Pickle-free model format. SafeTensors stores only tensor data, not arbitrary Python objects. Loading a SafeTensors file cannot execute code because the format doesn’t support it. Migration from Pickle to SafeTensors eliminates the entire class of deserialization attacks. The adoption gap: many models and tools still use Pickle by default.

Government guidance points the same way. The NSA-led “Deploying AI Systems Securely” information sheet (April 2024) and the “AI Data Security” sheet (May 2025), both issued with CISA, the FBI and allied agencies, recommend checksums and digital signatures to confirm the origin and integrity of AI artifacts and data, and tracking data provenance.


Key takeaways

  • About 100 malicious models with code execution payloads found on Hugging Face (JFrog, 2024). 352,000 unsafe issues across 51,700 models (Protect AI, April 2025)
  • nullifAI: 7z compression plus a broken Pickle stream got malicious models past Picklescan
  • Supply chain spans base models, fine-tuning data, adapters, plugins, and RAG corpora. Each is a potential poisoning vector.
  • Scanning volume keeps up with uploads. Blocklist scanners miss new evasion tricks, so don’t treat one scanner as the security boundary.
  • Structural fixes: cryptographic signing, hash verification, SafeTensors format (eliminates Pickle deserialization), and multi-tool scanning before deployment
  • 1,600+ exposed Hugging Face API tokens found in public repos affecting 723 organizations (Lasso Security, December 2023)

FAQ

How do malicious models get onto Hugging Face?

Typosquatting (similar names), hijacked accounts, and direct upload with Pickle payloads. Python’s reduce method executes arbitrary code when a Pickle model loads. At the time of JFrog’s discovery, Hugging Face flagged suspicious Pickle files as unsafe but did not block them.

What is nullifAI?

An evasion seen in two malicious models in early 2025: 7z compression instead of PyTorch’s default ZIP, plus a Pickle stream broken just after the payload. Picklescan failed on the broken file without flagging it, while deserialization runs the payload before hitting the error. Hugging Face removed the models within 24 hours and updated Picklescan.

How many Hugging Face models are unsafe?

Protect AI flagged 352,000 unsafe issues across 51,700 models from 4.47 million versions scanned (April 2025). JFrog found about 100 with real code execution payloads in 2024. Volume isn’t the problem; scanners that rely on blocklists miss new tricks.

What is the fix?

Cryptographic signing, hash verification, SafeTensors format (no Pickle deserialization), multi-tool scanning, sandboxed execution, and model inventories with provenance chains. NSA, CISA and partner agencies published guidance on verifying AI artifacts and data in 2024 and 2025.