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

Best practiceModels and infrastructure

Load models only from safe formats and trusted sources

OWASP ASI04OWASP LLM03

Pickle-based model files (.pt, .pkl, .bin, .ckpt) run code when loaded. Malicious models on Hugging Face opened reverse shells; nullifAI hid payloads in broken pickles scanners skipped; torch.load, Keras and vLLM each had CVEs where the "safe" path still ran code.

What to do

  1. Prefer safetensors and GGUF; treat pickle, Keras Lambda layers and TorchScript as code review items.
  2. Scan model files before loading: walk pickle opcodes for imports, and reject object arrays and unknown layers.
  3. Pin models to a commit or hash and mirror them internally; never load from a search result.
  4. Keep model loaders patched (torch, transformers, keras, vllm) and never set trust_remote_code in production.

Sources

Check your own AI plan against the practices: Plan check