Skip to the content
AI and Cybersecurity Learning and Practice Center Test automation Open the Learning Center

IncidentMalicious model files

nullifAI: broken pickle files slip malicious models past scanners

HighHugging Face

Researchers found models on Hugging Face with hidden malware that the platform's scanner did not flag, because the files were deliberately corrupted right after the malicious code.

Replay the attack step by step in the Learning Center

How it happened

  1. The attacker uploaded PyTorch models compressed in an unusual format.
  2. The malicious code sat at the start of the pickle data, and the file was broken right after it.
  3. Pickle runs instructions in order, so the payload ran before loading failed.
  4. The scanner errored on the broken file without flagging the dangerous code.

Impact

Loading one of the models could hand the attacker a remote shell.

The fix

Hugging Face removed the models within a day, and the scanner was updated for broken pickle files.

Lessons

  • Do not rely on one scanner, and treat files that fail to parse as suspicious.
  • Avoid pickle-based models from public hubs; use non-executable formats.
  • Load models in isolation.

Sources