Slide 11 of 29
Part 2 · TypesSlide 11
Slide 11 · Attack Type 3 of 6 — Malicious Model File
A model file isn't just data. It can be code.
The Detail Nobody Expects

Many models ship in Python's pickle format. Loading a pickle doesn't just read numbers — it can execute code as part of deserialization. So torch.load("model.bin") on an untrusted file can run whatever the author embedded. The model is the payload.

Confirmed Research · Feb 2024 · JFrog Security Research
~100 Malicious Models Found Live on Hugging Face
No CVE · Technique: pickle __reduce__ code execution on load

The finding: JFrog scanned PyTorch and TensorFlow/Keras models on Hugging Face and found around one hundred carrying real malicious payloads — not theoretical, hosted and downloadable.

The mechanism: the models abused pickle's __reduce__ method to run code the instant the model loaded — system fingerprinting, credential theft, and reverse shells that called back to attacker servers.

The catch: Hugging Face scans and flags pickle files as “unsafe,” but does not block them. A flagged model can still be downloaded and executed.

Takeaway: downloading a model from a reputable hub is not the same as running safe data. An unverified model file is unverified code.
The Defense This Would Have Stopped

Prefer safe formats like safetensors (data only, no code execution), and scan + verify model files before loading (Part 4). Next slide: what happens when the scanner itself can be fooled.

← BackNext → When the scanner gets bypassed