Guide · 12 min read

Guide

LLM04 Supply Chain: testing model files and dependencies

Real commands and their output: verify what you download, find model files that run code when they load, compare three scanners, audit the dependencies and write an SBOM.

By Kursad AlsanPublished 12 min read

Part 4 of 10 in the series Testing the OWASP Top 10 for LLM Applications 2026

  • OWASP LLM Top 10
  • LLM04 Supply Chain
  • Model scanning
  • Pickle
  • SBOM
scanners, one folder
3
scans that missed a backdoored file
2
rows in the audit of four old pins
254
components in the SBOM
208

The short version

  • A pickle model file ran a command the moment it was loaded. Scanners caught it, but not every scanner in every mode: one skipped a backdoored NumPy file in a folder scan, and another failed on it under NumPy 2 and moved on.
  • Count what a scan covered. A file that was skipped, or that crashed the scanner, has not been cleared; the exit code tells the cases apart.
  • Pin models by revision and hash, prefer safetensors, audit the Python dependencies and keep an SBOM. Four old pins of AI libraries filled 254 rows of pip-audit's report.

OWASP's LLM04:2026 Supply Chain is about everything in an LLM application that somebody else made: model files, datasets, Python packages and the software that serves the model. This guide tests the part you can check from a terminal, and shows every command with what it printed: whether a download is the file its publisher released, whether a model file runs code when it loads, what three scanners make of it, whether the dependencies have known vulnerabilities, and whether you can list what you run.

What you need

A terminal and Python. Nothing here needs a GPU or a running model. I ran everything on November 10, 2026, on Windows 11 in Git Bash; the commands are the same on Linux and macOS. Two short scripts and a requirements file appear in full below; save them under the paths in their headers.

setup
python -m venv .venv
source .venv/bin/activate        # Git Bash on Windows: source .venv/Scripts/activate
pip install garak picklescan fickling pip-audit uv cyclonedx-bom

# modelscan 0.8.8 supports Python 3.10 to 3.12, so it gets an environment of its own
uv venv --python 3.12 .venv312
uv pip install --python .venv312 modelscan
The environment I used. garak is not needed for this guide; the rest of the series uses it, and it brings in the large AI libraries that make the audit in step 6 worth reading.
bash
python --version && python -m pip list 2>/dev/null | grep -i -E "^(picklescan|fickling|pip.audit|cyclonedx-bom|numpy|safetensors|huggingface.hub) "
Python 3.13.17
cyclonedx-bom             8.0.1
fickling                  0.1.13
huggingface_hub           1.33.0
numpy                     2.5.4
picklescan                1.0.5
pip_audit                 2.10.1
safetensors               0.8.0
The versions behind every result below.

1. Is the download the file that was released?

Start with the file you are about to run. A publisher that gives a hash lets you check that your copy is theirs. This series uses Ollama, so the example is its Windows release, version 0.40.16. GitHub's API returns a SHA-256 digest for every release asset:

bash
curl -s https://api.github.com/repos/ollama/ollama/releases/tags/v0.40.16 | python -c "import json,sys; [print(a['digest'], a['name']) for a in json.load(sys.stdin)['assets'] if a['name'] == 'ollama-windows-amd64.zip']"
sha256:50fcf5ad54277f2fa5d173ebfc93bcb017adbc0c9ef2314daabc96ca9e6aa64e ollama-windows-amd64.zip
bash
sha256sum ../runtime/ollama-windows-amd64.zip
50fcf5ad54277f2fa5d173ebfc93bcb017adbc0c9ef2314daabc96ca9e6aa64e *../runtime/ollama-windows-amd64.zip

The two values match, so the file on disk is the file on the release page. That is all a hash proves. OWASP says the same about signatures: "Signing proves integrity and origin, not safety".

2. A model file that runs code when it loads

Many model formats are Python pickles, or contain one: .pkl and joblib files, PyTorch checkpoints (.pt, .bin), and NumPy files that hold objects. A pickle is not only data. The Python documentation puts it plainly: "The pickle module is not secure. Only unpickle data you trust."

To see it, I made four small files with this script. The backdoor is harmless on purpose: it runs echo CANARY-PKL-EXEC and nothing else.

tests/supply_chain/make_models.py
#!/usr/bin/env python3
"""Makes four small "model files" in work/models for the supply chain guide (LLM04), so the scanners have something to find.

  sentiment.safetensors        weights only: the format cannot carry code
  sentiment.pkl                a clean pickle
  sentiment-backdoored.pkl     a pickle that runs a command when it is loaded
  sentiment-backdoored.npy     the same object inside a NumPy file (object arrays are stored as pickles)

The "backdoor" is harmless on purpose: it runs  echo CANARY-PKL-EXEC  and nothing else. Run it from the lab folder:
    python tests/supply_chain/make_models.py
"""
import os
import pickle
from pathlib import Path

import numpy as np
from safetensors.numpy import save_file

OUT = Path("work/models")


class Backdoor:
    """pickle calls __reduce__ to learn how to rebuild an object; whatever it returns is called on load"""

    def __reduce__(self):
        return (os.system, ("echo CANARY-PKL-EXEC",))


def main():
    OUT.mkdir(parents=True, exist_ok=True)
    weights = np.arange(12, dtype=np.float32).reshape(3, 4) / 10
    save_file({"classifier.weight": weights}, str(OUT / "sentiment.safetensors"))
    with open(OUT / "sentiment.pkl", "wb") as f:
        pickle.dump({"labels": ["negative", "neutral", "positive"], "classifier.weight": weights.tolist()}, f)
    with open(OUT / "sentiment-backdoored.pkl", "wb") as f:
        pickle.dump({"labels": ["negative", "neutral", "positive"], "classifier.weight": weights.tolist(), "config": Backdoor()}, f)
    np.save(OUT / "sentiment-backdoored.npy", np.array([Backdoor()], dtype=object), allow_pickle=True)
    for p in sorted(OUT.iterdir()):
        print("%-28s %6d bytes" % (p.name, p.stat().st_size))


if __name__ == "__main__":
    main()
bash
python tests/supply_chain/make_models.py
sentiment-backdoored.npy        319 bytes
sentiment-backdoored.pkl        257 bytes
sentiment.pkl                   205 bytes
sentiment.safetensors           136 bytes

Loading the backdoored file is enough. Nothing has to call the model:

bash
python -c "import pickle; pickle.load(open('work/models/sentiment-backdoored.pkl', 'rb'))"
CANARY-PKL-EXEC

pickle.load called os.system because the file told it to. With a real payload, that line would have been a download or a reverse shell. In February 2024 JFrog reported around 100 malicious models on Hugging Face, including one that opened a reverse shell when it was loaded.

3. Three scanners, one folder

A scanner reads the instructions inside a pickle without running them, and flags the calls that have no place in a model file. I ran three open-source scanners over the same folder.

picklescan

picklescan (MIT licence) lists the imports a pickle would make and rates each one.

bashexit code 1
picklescan -p work/models
L:\lab\work\models\sentiment-backdoored.pkl: dangerous import 'nt system' FOUND
----------- SCAN SUMMARY -----------
Scanned files: 2
Infected files: 1
Suspicious globals: 0
Dangerous globals: 1

It found the backdoored pickle. It names nt.system because I ran on Windows, where os.system lives in the nt module; a file made on Linux or macOS names posix.system. Now read the summary: two files scanned. The folder holds four. The safetensors file is not a pickle, but the backdoored NumPy file was not scanned at all. Pointed at that file directly, picklescan finds it:

bashexit code 1
picklescan -p work/models/sentiment-backdoored.npy
L:\lab\work\models\sentiment-backdoored.npy: dangerous import 'nt system' FOUND
----------- SCAN SUMMARY -----------
Scanned files: 1
Infected files: 1
Suspicious globals: 0
Dangerous globals: 1

The reason is in the source. In picklescan 1.0.5, a folder scan skips every file whose extension is not on its zip, pickle or PyTorch lists, and .npy is on a separate list that the folder walk does not consult (scan_directory_path in scanner.py). The main branch had the same code on November 10, 2026, and an open pull request (#87) changes folder scans to read every file by its content.

fickling

fickling from Trail of Bits (LGPL-3.0) analyses a pickle and can also decompile it.

bashexit code 1
fickling --check-safety --print-results work/models/sentiment-backdoored.pkl
Call to `system('echo CANARY-PKL-EXEC')` can execute arbitrary code and is inherently unsafe
`from nt import system` is suspicious and indicative of an overtly malicious pickle file
Warning: Fickling detected that the pickle file may be unsafe.

Do not unpickle this file if it is from an untrusted source!

The same file as Python source, without running it:

bash
fickling work/models/sentiment-backdoored.pkl | head -n 2
from nt import system
_var0 = system('echo CANARY-PKL-EXEC')

fickling works on raw pickles. For the clean pickle it printed nothing and exited with 0. Given the NumPy file, it exited with 1 and reported invalid opcodes, because it read the NumPy header as a pickle: flagged, but not for the real reason. Given the PyTorch checkpoint from step 5, which is a zip archive, it exited with 2 and said "No pickle files detected".

modelscan

modelscan from Protect AI (Apache-2.0) knows several model formats and reports by severity. Version 0.8.8 supports Python 3.10 to 3.12, so it runs in its own environment.

bash, Python 3.12 environment
python -c "import sys, numpy, importlib.metadata as m; print('Python', sys.version.split()[0], '| modelscan', m.version('modelscan'), '| numpy', numpy.__version__)"
Python 3.12.16 | modelscan 0.8.8 | numpy 2.5.4
bash, Python 3.12 environmentexit code 2
modelscan -p work/models
No settings file detected at L:\lab\modelscan-settings.toml. Using defaults. 

Error encountered from scanner modelscan.scanners.NumpyUnsafeOpScan with path L:\lab\work\models\sentiment-backdoored.npy: module 'numpy.lib.format' has no attribute '_check_version'
Scanning L:\lab\work\models\sentiment-backdoored.pkl using modelscan.scanners.PickleUnsafeOpScan model scan
Scanning L:\lab\work\models\sentiment.pkl using modelscan.scanners.PickleUnsafeOpScan model scan

--- Summary ---

Total Issues: 1

Total Issues By Severity:

    - LOW: 0
    - MEDIUM: 0
    - HIGH: 0
    - CRITICAL: 1

--- Issues by Severity ---

--- CRITICAL ---

Unsafe operator found:
  - Severity: CRITICAL
  - Description: Use of unsafe operator 'system' from module 'nt'
  - Source: L:\lab\work\models\sentiment-backdoored.pkl

--- Errors --- 

Error 1:
The following error was raised during a modelscan.scanners.NumpyUnsafeOpScan 
scan: 
module 'numpy.lib.format' has no attribute '_check_version'

--- Skipped --- 

Total skipped: 2 - run with --show-skipped to see the full list.

modelscan found the backdoored pickle. Then its NumPy scanner failed: it calls numpy.lib.format._check_version, a private function that NumPy 2.5.4 does not have. The backdoored NumPy file was not scanned. The report says so under Errors, and the exit code is 2, not 1. An open pull request (#373) fixes the scanner for NumPy 2.5 and later. Until it is released, NumPy 1.26.4 in the same environment lets the scan cover the file:

bash
uv pip install --python .venv312 "numpy<2"
bash, Python 3.12 environmentexit code 1
modelscan -p work/models
No settings file detected at L:\lab\modelscan-settings.toml. Using defaults. 

Scanning L:\lab\work\models\sentiment-backdoored.npy using modelscan.scanners.NumpyUnsafeOpScan model scan
Scanning L:\lab\work\models\sentiment-backdoored.pkl using modelscan.scanners.PickleUnsafeOpScan model scan
Scanning L:\lab\work\models\sentiment.pkl using modelscan.scanners.PickleUnsafeOpScan model scan

--- Summary ---

Total Issues: 2

Total Issues By Severity:

    - LOW: 0
    - MEDIUM: 0
    - HIGH: 0
    - CRITICAL: 2

--- Issues by Severity ---

--- CRITICAL ---

Unsafe operator found:
  - Severity: CRITICAL
  - Description: Use of unsafe operator 'system' from module 'nt'
  - Source: L:\lab\work\models\sentiment-backdoored.npy

Unsafe operator found:
  - Severity: CRITICAL
  - Description: Use of unsafe operator 'system' from module 'nt'
  - Source: L:\lab\work\models\sentiment-backdoored.pkl

--- Skipped --- 

Total skipped: 1 - run with --show-skipped to see the full list.

A skipped file is not a clean file

Before you trust a scan, compare three numbers: the files in the folder, the files scanned, and the files skipped or failed. In a pipeline, stop on every exit code other than 0, and pin the versions of the scanner and of the libraries it depends on.

Filepicklescan 1.0.5fickling 0.1.13modelscan, NumPy 2.5.4modelscan, NumPy 1.26.4
sentiment.pkl, cleanCleanClean, exit code 0CleanClean
sentiment-backdoored.pklFoundFound, exit code 1FoundFound
sentiment-backdoored.npyFolder scan: skipped. Scanned directly: foundFlagged as invalid, exit code 1Error, not scanned; exit code 2Found
sentiment.safetensorsNot scanned: not a pickleNot runSkippedSkipped
What each scanner did with each of the four files in this run.

OWASP's entry lists scanner and safe-loader bypasses among its attack scenarios and draws this conclusion: "Treat scanners and safe-loader flags as defense-in-depth layers rather than guarantees, alongside provenance verification and patched loaders and parsers."

4. Loaders that refuse, and a format that cannot carry code

The second layer is the loader. NumPy refuses pickled objects unless you ask for them:

bash
python -c "import numpy as np; np.load('work/models/sentiment-backdoored.npy')" 2>&1 | tail -n 1
ValueError: Object arrays cannot be loaded when allow_pickle=False

allow_pickle is False by default, and the NumPy documentation gives the reason: "loading pickled data can execute arbitrary code". PyTorch made the same move: "Starting in version 2.6, torch.load will use weights_only=True if the pickle_module argument is not passed" (PyTorch serialization notes). I did not run PyTorch for this guide.

A safe flag is a layer too, not a guarantee. CVE-2025-32434 was remote code execution through torch.load with weights_only=True in PyTorch 2.5.1 and earlier, fixed in 2.6.0.

The third layer is the format. safetensors describes itself as "a new simple format for storing tensors safely (as opposed to pickle)". Loading one gives back the numbers and nothing else:

bash
python -c "from safetensors.numpy import load_file; print(load_file('work/models/sentiment.safetensors'))"
{'classifier.weight': array([[0. , 0.1, 0.2, 0.3],
       [0.4, 0.5, 0.6, 0.7],
       [0.8, 0.9, 1. , 1.1]], dtype=float32)}

That does not make a model trustworthy. OWASP notes that moving away from pickle "reduces but does not eliminate this risk": a backdoor can sit in a model's computational graph, in formats considered safe, where a file scanner has nothing to flag.

5. A real model from a hub: pin, verify, scan

A model name on a hub is not a fixed thing. OWASP's entry describes namespace reuse: an author's account is deleted or transferred, someone else registers the name, and a pipeline that pulls by name gets a different model. A commit hash does not move. I downloaded one file of a small test model from Hugging Face by its revision:

bash
python -c "from huggingface_hub import hf_hub_download; hf_hub_download('hf-internal-testing/tiny-random-bert', 'pytorch_model.bin', revision='f171d7baecaf37b5da5a3616d8833b9969753535', local_dir='work/hf')"
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
The only output is the Hub's note about unauthenticated requests.

The file's hash, then the hash that the Hub records for that file at that revision:

bash
sha256sum work/hf/pytorch_model.bin
9922e8996d0c7e24c7f4e7a5d9c5b7303549f4ee94de0f1138b103014b51be13 *work/hf/pytorch_model.bin
bash
curl -s https://huggingface.co/api/models/hf-internal-testing/tiny-random-bert/tree/f171d7baecaf37b5da5a3616d8833b9969753535 | python -c "import json,sys; [print(f['lfs']['oid'], f['path']) for f in json.load(sys.stdin) if f.get('lfs')]"
9922e8996d0c7e24c7f4e7a5d9c5b7303549f4ee94de0f1138b103014b51be13 pytorch_model.bin
e0d82efce33dd527e8b1d585c024eef3f34ff493084492010308224140519fe3 tf_model.h5

They match. Now the scan, before anything loads the file:

bashexit code 0
picklescan -p work/hf/pytorch_model.bin -g
----------- SCAN SUMMARY -----------
Scanned files: 1
Infected files: 0
Suspicious globals: 0
Dangerous globals: 0
All globals found:
  * collections.OrderedDict - innocuous
  * torch.LongStorage - innocuous
  * torch._utils._rebuild_tensor_v2 - innocuous
  * torch.FloatStorage - innocuous
bash, Python 3.12 environmentexit code 0
modelscan -p work/hf/pytorch_model.bin
No settings file detected at L:\lab\modelscan-settings.toml. Using defaults. 

Scanning L:\lab\work\hf\pytorch_model.bin:archive\data.pkl using modelscan.scanners.PickleUnsafeOpScan model scan

--- Summary ---

 No issues found! 🎉

--- Skipped --- 

Total skipped: 102 - run with --show-skipped to see the full list.

Both scanners agree: the pickle inside this checkpoint only rebuilds tensors. The same repository also offers model.safetensors. When a model comes in both formats, take that one.

On Windows

I ran every command with PYTHONUTF8=1 set. Without it, modelscan 0.8.8 scanned this file and then failed to print its report, because the console's encoding could not write the emoji in the "No issues found" line. The exit code was 2.

6. Dependencies with known vulnerabilities

Packages are the classic supply chain. pip-audit checks an environment or a requirements file against the Python Packaging Advisory Database. First the environment I am working in, 208 packages after installing garak:

bashexit code 0
pip-audit
No known vulnerabilities found
One warning line about the path of my virtual environment is left out.

Clean, because everything was installed this week. Projects are rarely that fresh. To show what a finding looks like, here is a requirements file with four AI libraries pinned to versions from 2023:

tests/supply_chain/requirements-old.txt
langchain==0.0.130
transformers==4.30.0
mlflow==2.3.0
ray==2.6.3
bashexit code 1
pip-audit -r tests/supply_chain/requirements-old.txt --no-deps --disable-pip
WARNING:pip_audit._cli:--no-deps is supported, but users are encouraged to fully hash their pinned dependencies
WARNING:pip_audit._cli:Consider using a tool like `pip-compile`: https://pip-tools.readthedocs.io/en/latest/#using-hashes
Found 254 known vulnerabilities in 4 packages
Name         Version ID                  Fix Versions
------------ ------- ------------------- ------------
langchain    0.0.130 PYSEC-2023-18
langchain    0.0.130 PYSEC-2023-18       0.0.132
langchain    0.0.130 PYSEC-2023-91       0.0.225
langchain    0.0.130 PYSEC-2023-92       0.0.247
langchain    0.0.130 PYSEC-2023-91       0.0.225
langchain    0.0.130 PYSEC-2023-92       0.0.247
langchain    0.0.130 PYSEC-2023-98       0.0.247
The first 12 of 259 lines.

Advisory IDs in pip-audit's report, by package

PackageAdvisory IDs
mlflow 2.3.074
transformers 4.30.029
langchain 0.0.13025
ray 2.6.311
pip-audit printed 254 rows. An ID can appear on more than one row, and 139 are distinct. Counted from the report above, November 10, 2026.

One of the first rows, PYSEC-2023-18, is CVE-2023-29374: prompt injection that led to code execution in LangChain's LLMMathChain, fixed in 0.0.132. A vulnerable dependency in an LLM application can sit one prompt away from an attacker.

--no-deps --disable-pip audits the pinned lines as written, without installing anything. OWASP adds a check that no tool does for you: "verify that AI-suggested dependencies exist and are the intended package before adopting them".

7. An inventory: the SBOM

You cannot audit what you cannot list. An SBOM (software bill of materials) is that list in a standard format. cyclonedx-py writes one from the environment:

bash
cyclonedx-py environment --of JSON -o work/sbom.json
No output: the file is written to work/sbom.json.

A few lines of Python read it back:

tests/supply_chain/sbom_summary.py
#!/usr/bin/env python3
"""Prints what a CycloneDX SBOM (JSON) holds: the format, how many components, and a few of them with their package URL.
    python tests/supply_chain/sbom_summary.py work/sbom.json torch transformers litellm
"""
import json
import sys

bom = json.load(open(sys.argv[1], encoding="utf-8"))
parts = bom["components"]
print("%s %s, %d components" % (bom["bomFormat"], bom["specVersion"], len(parts)))
for name in sys.argv[2:]:
    for c in parts:
        if c["name"] == name:
            print("%-13s %-9s %s" % (c["name"], c["version"], c.get("purl", "")))
bash
python tests/supply_chain/sbom_summary.py work/sbom.json torch transformers litellm garak
CycloneDX 1.6, 208 components
torch         2.15.0    pkg:pypi/torch@2.15.0
transformers  5.19.0    pkg:pypi/transformers@5.19.0
litellm       1.108.4   pkg:pypi/litellm@1.108.4
garak         0.17.1    pkg:pypi/garak@0.17.1

208 components, each with a version and a package URL that other tools can match against advisories. It lists packages, not models. OWASP asks for an inventory "extended to models, adapters, and datasets". Until your tooling does that, keep the model list by hand: name, revision, hash, format and licence, the values from step 5.

What to report, and the fix to retest

FindingEvidence to keepFix to retest
A pickle-based model file from a source that is not verifiedThe scanner's output, or the decompiled callThe safetensors version of the model, or a scan in the pipeline that stops on any exit code other than 0
A scan that skipped or failed on filesFiles in the folder against files scanned, and the error textPinned versions of the scanner and its libraries, and a second scanner
A model referenced by name onlyThe line in the code or the configurationA pinned revision and a recorded hash
A download that nobody verifiesThe build step, with no hash or signature checkA hash or signature check before the file is used
Dependencies with known vulnerabilitiesThe pip-audit reportUpdated pins, and the audit in the pipeline
No inventoryNo SBOM and no list of modelsAn SBOM for every build, and a model list with revisions and hashes
Six findings this guide can produce, each with the control to verify after the fix.

What this guide did not test

  • The software that serves the model. OWASP counts the serving stack as part of the same attack surface. That test needs a running model server, and it is not in this guide yet.
  • Backdoors in the weights. No file scanner sees them. OWASP calls for red teaming and evaluation when a third-party model is selected.
  • Signatures and provenance. OWASP lists model signing (the OpenSSF Model Signing project, Sigstore) and release gates such as SLSA next to file hashes.

Frequently asked questions

Is every pickle model file dangerous?

No. The clean pickle above scanned clean in all three tools, and the real checkpoint from Hugging Face scanned clean in the two that can read it. The danger is loading a pickle from a source you cannot verify, because loading it is running it.

Does safetensors make a model safe?

It removes code execution on load. It does not tell you whether the weights were tampered with; OWASP is explicit that leaving pickle reduces the risk and does not eliminate it.

Which model scanner should I use?

More than one. In this run each of the three had a case it handled differently from the others, and two of them left the same backdoored file unscanned under some conditions. Check what each scan covered, not only what it found.

What does a matching hash prove?

That your copy is the file the publisher released. It does not prove that the release is safe.

My own files only

Everything above ran on my own machine, against files made or downloaded for this guide. The backdoor is a harmless marker on purpose.

Sources

Keep reading

All guides

Need your AI supply chain reviewed?

AI security assessments with reproducible evidence and a retest.