ModelScan — ML Model Serialization Scanner
ProtectAI's scanner that detects malicious payloads hidden inside pickle, PyTorch, TF, and Keras model files.
ModelScan — ML Model Serialization Scanner
ModelScan, maintained by ProtectAI, scans ML model files for serialization attacks — one of the most underappreciated supply-chain risks in AI. A malicious .pkl, .pt, or .h5 file can execute arbitrary code on torch.load(). ModelScan flags these before they reach production.
Key features
- Supports pickle, PyTorch (
.pt/.pth), TensorFlow SavedModel, Keras.h5, NumPy, and more - CI/CD ready: exit code 1 on findings, JSON/text output
- Zero false-positive safe-model passes (no benign ops blocked)
- GitHub Action available
- Integrates with Hugging Face Hub via the
huggingface-hubaudit CLI
Quick start
pip install modelscan
modelscan scan -p ./my_model.pkl
# Scan an HF model directly
modelscan scan --huggingface bert-base-uncased
npx ai-supply add modelscan-serialization-security
Curated mirror of the open-source ModelScan (Apache-2.0). Get it from the source.
Compromise signals — malicious or tampered code (leaked secrets, backdoors, a dropped executable) — reduce the score, and known dependency CVEs carry a bounded penalty (they warrant review but never QUARANTINE — update the dependency to clear). Other dangerous-by-capability traits are risk surface, expected for some capabilities. Every finding is mapped to its OWASP control below.
Findings mapped to the OWASP Top 10 for LLM Applications (2025) and the OWASP Machine Learning Security Top 10. Expand any flagged control for the exact findings — compromise reduces the score; expected/risk-surface do not, except a known CVE, which carries a small bounded penalty (high/critical → Review).
The same gate an agent runs before installing (POST /api/v1/trust/modelscan-serialization-security/check). Click a policy:
Consume ModelScan — ML Model Serialization Scanner programmatically. Authenticate with an API key or session — see Authorize an agent.
# Agents: CHECK BEFORE YOU INSTALL (no auth) — score, grade, level, capability manifest
curl https://ai-supply.store/api/v1/trust/modelscan-serialization-security
# Gate against your org policy (returns { pass, violations })
curl -X POST https://ai-supply.store/api/v1/trust/modelscan-serialization-security/check \
-H "Content-Type: application/json" \
-d '{"minGrade":"B","denyPermissions":["shell"],"denyUnknownEgress":true}'
# CLI
npx ai-supply add modelscan-serialization-security
# REST (install → download)
curl -X POST https://ai-supply.store/api/v1/listings/modelscan-serialization-security/install \
-H "Authorization: Bearer $AIM_KEY"
# MCP tool
install_listing({ "slug": "modelscan-serialization-security" })OpenAPI spec →Curated mirror — latest upstream source. See the repository for tagged releases.