AI Security · Learn

What is a model file supply chain attack?

Teams pull models and datasets from public hubs and load them without a second thought. A poisoned artifact runs code or reads files the moment it loads, so one bad file can spread across many consumers.

TL;DR

A model file supply chain attack hides malicious behaviour in a shared machine-learning model or dataset so that downloading and loading it compromises the consumer. Pickle-based formats execute code on load; HDF5 and config-driven formats can read files or evaluate templates. Because teams pull artifacts from public hubs and load them automatically, a single poisoned model or a typosquatted name can spread widely. Defend by verifying publishers, preferring safe formats, scanning artifacts, and sandboxing loads.

By Rohit Hatagale, AI Security Lead, SecureLayer7Updated

What a model file supply chain attack is

Machine-learning artifacts are treated as data, but many formats carry behaviour. Loading a model or dataset can deserialise objects, evaluate configuration, or resolve external references, so the act of loading is an act of trust. When those artifacts come from public hubs, mirrors, or contributor uploads, the consumer is running code chosen by whoever published them.

How it works and example

The classic vector is a pickle-serialised model whose deserialisation runs arbitrary code on load. HDF5 files abuse external storage to read local files, and config-driven loaders evaluate templates for execution. Attackers also typosquat popular model names, publish poisoned weights, or compromise an account to push a malicious update, so a routine dependency pull delivers the payload.

How to defend against it

Verify who published an artifact and check signatures or hashes before loading. Prefer formats that cannot execute on load, such as safetensors, over pickle. Scan model and dataset files, load untrusted ones in a sandbox with least privilege, and keep an inventory of the models and datasets you depend on so you can respond when one is found malicious.

References

  1. [1]MITRE ATLAS, Adversarial ML tactics(MITRE)
  2. [2]HuggingFace, Agent intrusion technical timeline(HuggingFace)
Related terms

Every model you pull from a public hub is code you run. Talk to a security expert about hardening how you source and load models.

FAQ

Model file supply chain attacks, asked often

Scope an engagement

Test whether your AI stack survives real attacks.

We test for this and many other techniques, and ship findings with a reproducible attack, the trust boundary that failed, and a fix a defender can implement.