← Back to blog
AI threatsHighFeatured

Loading AI models: Why unknown pickle files can execute code

Python explicitly warns against untrusted pickle data. Review the file format and any accompanying model software separately.

Editorial review:

Background & source findings

Pickle serialises and reconstructs Python objects. Python’s documentation warns that maliciously constructed pickle data can execute arbitrary code when unpickled. A model download containing such objects is therefore not necessarily passive numerical data. Consequences depend on the processing account’s permissions and reachable resources. [1]

Scope & limitations

Not every pickle file is malicious. The format warning establishes neither a count of infected models nor automatic administrator access. [1]

In plain language

A downloaded box may contain both numbers and instructions executed while opening it. Provenance and the environment used to open it matter.

Practical recommendations

Our recommendation: evaluate unfamiliar models in a separate environment without production credentials. Review provenance, versions, startup scripts and dependencies. Where practical, prefer formats for numerical weights that do not require arbitrary Python objects. Still inspect any separately loaded code: a different weight format does not make the complete package trustworthy.

Primary source / reference

  1. [1] Python documentation: pickle security warning