A model file you download can run code on your server: OWASP LLM03

OWASP LLM03:2025 covers the supply chain of AI apps: pre-trained models, LoRA adapters, libraries and data. A pickle file can run code when it loads, so download from sources you can verify, prefer safetensors, and keep an inventory of everything you use.

Published 3 min read#AI#Supply chain security

You download a model from an account you don't know to try it for two minutes, and write one line to load it. That line can run code on your machine or server before the model answers a single question. By the end of this article you will know why, what OWASP says about the supply chain of AI apps, and what to do before you load any pre-trained model.

What is OWASP LLM03?

LLM03:2025 is the "Supply Chain" entry in OWASP's list of the top risks for large language model applications: everything that enters your app from outside, from pre-trained models and adapters to libraries and data, can arrive rigged or outdated.

According to OWASP's LLM03:2025 page, LLM supply chains are susceptible to vulnerabilities that affect the integrity of training data, models and deployment platforms. The difference from ordinary software is that the risk doesn't stop at code and dependencies: it extends to third-party pre-trained models and data. The page also names open-access models and fine-tuning methods on platforms like Hugging Face as a new source of risk.

What is a pickle file, and why it in particular?

A pickle file is Python's way of saving any object to a file and loading it back, and it is the default format for PyTorch model weights, according to Hugging Face's documentation on pickle scanning.

The problem is that pickle is not just data. The same documentation explains that the file is a sequence of instructions executed one after another at load time, and that it can import built-in functions like exec and eval and run them. So a rigged weights file runs whatever it wants at the very moment you write the load line. It is the same logic as insecure deserialization, except this time the file is called "a model".

Where else can the chain break?

The rigged file isn't the only door. The OWASP page lists other risks; the most relevant for a developer building a product:

Risk

What it means in practice

Outdated third-party packages

A Python library with a known flaw inside your app

Outdated or deprecated models

A model nobody maintains, so its flaws stay

Vulnerable pre-trained model

Models are black boxes, and outside inspection reveals little

Weak model provenance

There are no strong provenance assurances in published models today

Vulnerable LoRA adapters

A small adapter loaded on a clean model can compromise its integrity

Unclear terms and privacy policies

Your data may be used for training by the model operator

If you want to see how the training data itself gets poisoned, that's a separate entry on the same list, covered in the LLM04 article.

How do you protect your app before loading any model?

You protect it with the same logic as any library: know where it comes from, pick a file format that doesn't run code, and know what you have.

  1. Only download models from sources you can verify. OWASP lists this word for word among its mitigations, and recommends vetting data sources and suppliers, including their terms and privacy policies.

  2. Prefer safetensors files over pickle files such as pytorch_model.bin. Hugging Face's documentation lists it among the serialization formats it suggests instead of pickle.

  3. If you must load a pickle, check the list of imports Hugging Face shows next to the file. Any import that looks suspicious is highlighted. But the site itself says this scan is not 100% foolproof.

  4. Keep an SBOM of every model, adapter and library with its version, and keep it current. OWASP recommends it so you know what you have, along with a patching policy for outdated components.

  5. Before you rely on a third-party model, test it the way an attacker would. OWASP calls this AI Red Teaming and evaluations.

Where do you start now?

The lesson for us as developers: a model file is code, not data, so it deserves the same suspicion you give any package from npm or PyPI. Open your project's models folder now, look for any .bin, .pt or .pkl file, and ask: where did it come from, and is there a safetensors version of it? And if your app relies on models and components from several sources and you want someone to test all of it, Muhassan does that. How many pickle files did you find?

FAQ

If a model is on Hugging Face, is it safe?

Not necessarily. Hugging Face scans pickle files and shows the imports inside them, but it says itself the scan is not 100% foolproof and the responsibility is yours.

Does a model card prove who made the model?

No. OWASP says model cards give information about the model but no guarantee of its origin, and that there are no strong provenance assurances in published models today.

What is an SBOM, and why do I need one for an AI app?

An SBOM is a list of every component in your app. OWASP recommends it so you know which models, libraries and versions you have, and where to look when one of them has a problem.

Share

More articles