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

WeaknessASC-2026-0013Major weakness

Unsafe model serialization (pickle)

CriticalFixed

Pickle-based model files (.pkl, .pt, .pth, .bin, .ckpt) can run arbitrary code the moment they are loaded.

How to detect it

  • Model file uses a pickle-based format
  • The pickle imports callables such as os.system, subprocess or builtins.eval

How to resolve it

  • Convert weights to safetensors and load only safetensors in production
  • When pickle is unavoidable, load with torch.load(weights_only=True) (the default since PyTorch 2.6)
  • Scan every model file before loading and verify the publisher's hash

How to investigate

  1. Scan all model files on the host with the model file scanner
  2. Check hosts that loaded the file for unexpected processes and outbound connections
  3. Compare file hashes with the publisher's and remove unverified copies

Sources

Open it in the Learning Center's vulnerability database