AI supply chain security: how to secure open-weight models, adapters, model files and datasets
Where the AI supply chain differs from the software supply chain, how a model supply chain attack works through model files, adapters, datasets and model hubs, and a practical program: AI-BOM, provenance and signing, scanning, isolated inference and monitoring model behaviour in production.
Summary
- A model is not just data. Model files, fine-tuning adapters, tokenizers, datasets and the code that loads them all come from somewhere, and each can carry a model supply chain attack: code that runs on load, a backdoor in the weights or poisoned training data.
- The foundation is an AI-BOM: an inventory of every model, adapter and dataset with source, exact revision, hash, licence, owner and where it runs. Add pinned revisions, verified hashes or signatures, safe file formats such as safetensors and a scan before anything is loaded.
- Assume something will slip through: run inference isolated with minimal permissions and restricted egress, and monitor model behaviour in production, including which model version answers, latency, errors, tokens and tool calls, so unexpected changes become visible quickly.
Most teams that build with AI no longer train models from scratch. They download an open-weight model from a model hub, add a fine-tuning adapter that someone published, pull a dataset for evaluation and load it all with a few lines of Python. That is fast and often the right choice. It also means that a large part of what runs in production was built by people you do not know, from data you have never seen, in files you have probably never inspected.
This is the AI supply chain. It has the same weak points as the software supply chain and a few new ones. This guide explains where the risks are, how a model supply chain attack can work, and what a practical AI supply chain security program looks like: an AI-BOM, provenance and signing, scanning model files, isolating inference and monitoring model behaviour in production. It ends with a checklist and an FAQ.
What is the AI supply chain?
The AI supply chain covers every external component that goes into an AI feature, from the base model to the code that serves it. Typical parts:
- Base models: open-weight models downloaded from a model hub or a vendor, in one or several file formats and often in quantised variants made by third parties.
- Fine-tuning adapters: small weight files, for example LoRA adapters, that change the behaviour of a base model and are easy to share.
- Tokenizers and configuration: tokenizer files, chat templates and model configuration, some of which can reference custom code.
- Datasets: training, fine-tuning and evaluation data, and the documents you index for retrieval.
- Libraries and runtimes: training and inference frameworks, serving engines, GPU drivers and container images.
- Hosted model APIs and tools: external model providers, plugins and MCP servers that agents call.
The classic supply-chain attack targets one of these upstream components to reach everyone who uses it. In AI, the components are bigger, harder to inspect and often trusted more than they deserve.
Why AI supply chain security is different
For code dependencies, the tooling is mature: lock files, vulnerability advisories, dependency scanning and an SBOM. Models do not fit that pattern well:
- Weights cannot be reviewed like code. A model is billions of numbers. You can test its behaviour, but you cannot read it to see whether it contains a backdoor.
- Some model formats are executable. Loading a file in a pickle-based format can run code. Opening a "data file" becomes the same as running a script from the internet.
- Provenance is often thin. A model card may describe training data in a sentence. Derived models, merges and quantisations add more anonymous steps.
- Behaviour is the product. A poisoned model may work perfectly on every test and only misbehave on a specific trigger.
- Models act. Once a model can call tools, a manipulated model or a prompt injection in its input can lead to real actions, not just wrong text.
How a model supply chain attack works
A model supply chain attack can happen at several points. The table gives an overview; the sections below go into the most important ones.
| Attack point | What can go wrong | Main control |
|---|---|---|
| Model file format | Pickle-based files run code when they are loaded | Use safetensors, load with restricted loaders, scan before loading |
| Open-weight model | Backdoor or hidden behaviour in the weights, modified re-upload under a similar name | Trusted publishers, pinned revisions, hashes, behaviour tests |
| Fine-tuning adapter | Adapter changes behaviour of a trusted base model, may also ship in an unsafe format | Treat adapters like models: inventory, provenance, scan, test |
| Dataset | Poisoned samples teach a trigger or bias; poisoned retrieval documents inject instructions | Data provenance, sampling and review, separation of trusted and untrusted data |
| Model hub | Typosquatted repositories, compromised accounts, changed files behind a moving branch | Allow list of sources, pin commit revisions, internal mirror |
| Loader code | Custom model code downloaded and executed with the model | Avoid remote code, review and pin it if needed |
| Runtime and libraries | Vulnerable inference server, framework or container image | Dependency scanning, patching, isolation |
Model files: pickle vs. safetensors
Many older model checkpoints are stored with Python's pickle serialisation, for example many .bin, .pt, .pth, .ckpt and .pkl files. Pickle does not only store data; it stores instructions for rebuilding Python objects, and those instructions can call arbitrary functions. A crafted file can therefore start a shell, download a payload or read credentials the moment it is loaded, before any model code runs.
The safetensors format was designed to avoid this: it stores tensors and a small header, nothing executable. Loading it does not run code from the file. That makes it the sensible default for weights and adapters. PyTorch has also narrowed the risk: since version 2.6, torch.load uses weights_only=True by default, which only allows a restricted set of types. The PyTorch documentation is clear that this reduces but does not remove all risk, so do not turn it off for files you do not trust.
# Generic example: load weights without executing code from the file
from safetensors.torch import load_file
weights = load_file("models/base/model.safetensors")
# If a PyTorch checkpoint is unavoidable: keep the restricted loader
import torch
state = torch.load("models/legacy/model.pt", weights_only=True) # never weights_only=False for untrusted files
Open-weight models and LoRA adapters
Even a perfectly safe file format does not tell you whether the weights behave as expected. A model can be fine-tuned to answer normally in almost every case and to do something else when a trigger phrase appears, for example leak data, recommend a malicious package or ignore a safety instruction. Such behaviour is hard to find with ordinary tests.
Adapters deserve special attention because they look harmless. A LoRA adapter is small, quick to download and often published by individuals. It modifies a base model you already trust, so it inherits that trust without having earned it. Treat every adapter like a model: record where it came from, pin its revision, check its format and test the combined model, not just the base model.
Poisoned datasets and retrieval data
Data poisoning means placing manipulated samples in a dataset so that a model trained on it learns a hidden trigger or a bias. For most teams that fine-tune rather than pre-train, the risk sits in fine-tuning and evaluation data taken from public sources, scraped content or user feedback. A poisoned evaluation set is also a problem: it can make a weak or manipulated model look good.
Retrieval adds a runtime variant. Documents you index for retrieval-augmented generation become part of the prompt. If an attacker can place text in a wiki page, a ticket or a shared drive that you index, they can inject instructions. Our guide to MCP server security and monitoring covers this indirect prompt injection in depth.
Model hubs
Model hubs work like package registries, with similar risks: repositories with names close to popular ones, compromised publisher accounts, and files that change while the repository name stays the same. A download that refers to the default branch gets whatever is there today, not what you tested last month. Pin a specific commit revision, check the publisher, and for production consider an internal mirror or artifact store that only contains reviewed models.
# Generic example: pin an exact revision instead of a moving branch
from huggingface_hub import snapshot_download
path = snapshot_download(
repo_id="example-org/example-model",
revision="<full-commit-sha>", # reviewed revision, not "main"
allow_patterns=["*.safetensors", "*.json", "tokenizer*"], # keeps pickle files and custom code out
)
The AI-BOM: an inventory of models, adapters and datasets
You cannot secure what you do not know. An AI-BOM (AI bill of materials) extends the idea of the SBOM to models and data: a list of every model, adapter and dataset in use, with enough detail to answer "where did this come from, and where is it running?" when a problem is reported. Standards are catching up: both CycloneDX and SPDX have added ways to describe machine learning models and datasets, so an AI-BOM can live next to your software SBOMs in a machine-readable format.
Useful fields per entry:
| Field | Why it matters |
|---|---|
| Name, type and version | Base model, adapter, tokenizer, dataset, hosted model API |
| Source and publisher | Hub repository, vendor or internal team |
| Exact revision and SHA-256 hash | Proves that what runs is what was reviewed |
| File format | Flags pickle-based files that need special handling |
| Licence and usage terms | Open-weight licences differ, including restrictions on use |
| Parent models and datasets | Lineage of fine-tunes, merges and quantisations |
| Owner team | Who decides on updates and responds to issues |
| Deployments | Which services, environments and agents use it |
| Review status and date | Scanned, tested, approved, and when |
# Generic example: one AI-BOM entry, kept in version control
- name: support-assistant-adapter
type: lora-adapter
base_model: example-org/example-model@<commit-sha>
source: https://hub.example/acme-ml/support-adapter
revision: <commit-sha>
sha256: <hash-of-adapter-file>
format: safetensors
license: apache-2.0
datasets: [support-tickets-2026-q3 (internal, PII removed)]
owner: team-support-ai
deployed_in: [support-api (prod), support-api (staging)]
review: {scanned: 2026-11-10, behaviour_tests: passed, approved_by: security}
Build the first version from what you can find: model directories on hosts and in container images, download calls in code, configuration that names models, and the model names your services report in their telemetry. Then make the AI-BOM the gate: a model that is not in it does not go to production.
Provenance, hashes and signing
Provenance answers who produced an artifact and how. In practice it has three levels:
- Hashes: record a SHA-256 hash for every reviewed file and verify it at deployment and at load time. This is simple and catches changed files.
- Signatures: sign reviewed models and adapters in your own pipeline, and verify the signature before loading. Where publishers sign their artifacts, verify that too. Signing tools for software artifacts can be used for model files as well.
- Build provenance: for models you fine-tune yourself, record the base model revision, dataset versions, training code commit and environment, so the result can be reproduced and traced.
# Generic example: record and verify hashes of reviewed model files
sha256sum models/support/*.safetensors > models/support/SHA256SUMS
sha256sum --check models/support/SHA256SUMS # run in CI and before the server starts
# Find pickle-based files that need conversion or review
find models/ -type f \( -name '*.bin' -o -name '*.pt' -o -name '*.pth' -o -name '*.ckpt' -o -name '*.pkl' \)
Scanning model files before loading
Treat a new model like an unknown binary. Before it is loaded anywhere with access to data or credentials:
- Check the format. Prefer safetensors. Convert pickle-based checkpoints in a sandbox with no network and no secrets, or reject them.
- Scan pickle content. Open-source model scanners inspect the imports a pickle would perform and flag dangerous ones such as process execution or network access. A clean scan reduces risk; it is not a proof of safety.
- Check configuration and code. Look for references to custom code, unexpected files and loader options that execute remote code.
- Scan the runtime. Inference servers, frameworks and container images are software: scan them for known vulnerabilities like any other dependency.
- Test behaviour. Run a fixed evaluation set that includes your critical tasks and some adversarial prompts, and compare with the previous version.
Record the result in the AI-BOM. A model that has not been scanned and tested is not approved.
Isolating inference
Every control above can fail. Isolation limits the damage when it does:
- Separate the inference service. Run model serving in its own container or VM, not inside an application that holds database credentials.
- Least privilege. The inference process needs read access to the model files and nothing else. No cloud admin roles, no broad tokens, following least privilege.
- Restrict egress. Model serving rarely needs the internet. Block outbound traffic except what is required, so code that runs on load cannot call home.
- Read-only model storage. Mount model directories read-only and load only from the reviewed store, never from a download at start-up.
- Limit tools. If the model drives an agent, give each tool minimal permissions, require human approval for destructive actions and put AI guardrails around inputs and outputs.
Monitoring model behaviour in production
A backdoor or a manipulated adapter shows itself through behaviour. Monitoring cannot prove a model is clean, but it makes unexpected changes visible. Watch:
- Which model answers. Record the requested and the actual model and version on every call. A model or adapter you do not expect is a finding.
- Latency, tokens and errors per model. A new model version that suddenly produces much longer outputs, slower answers or new error types has changed, whether intended or not.
- Tool calls. Which tools an agent calls, how often, with which result size. A first call to a tool that a model never used before deserves attention.
- Outbound connections from inference hosts. With egress restricted, any new destination is suspicious.
- Processes on inference hosts. A model server that starts a shell is a strong signal of code execution on load.
- Output drift. Track the results of your evaluation set and, where you can, simple output signals such as refusal rate or answer length over time.
OpenTelemetry's semantic conventions for generative AI record model calls as spans with attributes such as gen_ai.request.model and token usage, and they also describe tool execution. Using them keeps model calls and tool calls in the same trace as the request that triggered them. Our LLM observability guide explains the setup and what to record, and why prompts and responses should only be stored deliberately.
Checklist: AI supply chain security
- An AI-BOM lists every model, adapter, tokenizer and dataset with source, revision, hash, format, licence, owner and deployments.
- Only models from an allow list of sources and publishers are used.
- Downloads pin an exact commit revision and restrict file patterns.
- Weights and adapters are stored as safetensors; pickle-based files are converted in a sandbox or rejected.
torch.loadkeepsweights_only=True; remote model code is disabled unless reviewed and pinned.- Every new model and adapter is scanned and passes behaviour tests before approval.
- Hashes or signatures are verified in CI and before the inference server loads a model.
- Production loads models only from a reviewed, read-only internal store.
- Inference runs isolated with minimal permissions and restricted egress.
- Fine-tuning, evaluation and retrieval data have documented provenance.
- Inference servers, frameworks and images are scanned for known vulnerabilities.
- Model version, latency, tokens, errors and tool calls are monitored, with alerts on unexpected changes.
- A runbook describes how to roll back a model and find every service that uses it.
How Obseria helps
Obseria does not scan or sign model files and does not build an AI-BOM for you; keep those steps in your build and release pipeline. Where Obseria helps is the runtime side: seeing which models your services call, how they behave and what happens on the hosts that serve them, within the data you instrument and send.
- Which models are called: Obseria AI Observability and LLM monitoring read model calls from your spans via
gen_ai.request.model, with tokens, duration and error rates per model, filterable by model and service. A model name that should not be there shows up in that list. - Calls in context: model calls and the tool calls your agents record as spans appear in the distributed trace of the request that made them, next to database and HTTP calls.
- Alerts: check rules on error rates or durations create problems and notify your channels. Anomaly detection compares services on p99 latency, error rate and throughput, which can surface an inference service that suddenly behaves differently. Obseria does not score answer quality and has no guardrails that block responses; run evaluations alongside and send their results as metrics or events.
- Costs: AI cost analytics breaks spend down by model, feature and customer, so a model change that multiplies tokens becomes visible.
- Inference hosts: workload threat detection in Security Enterprise has host rules such as a new process on a host that never ran it in the previous 14 days, and threat intelligence turns connections to known malicious addresses into findings. Network monitoring shows calls, throughput and firewall events per host. Detection only, nothing is blocked.
- Dependencies around the model: software composition analysis checks the libraries in connected GitHub repositories for known vulnerabilities and licences and can produce an SBOM of those dependencies. It does not inspect model weights.
- Telemetry hygiene: the sensitive data scanner masks email addresses, card numbers, tokens and other patterns in logs and spans before storage, which helps if prompts or tool arguments end up in telemetry.
To see your model calls and inference hosts in one place, start a free trial.
Frequently asked questions about AI supply chain security
What is AI supply chain security?
It is the protection of every external component that goes into an AI feature: models, adapters, tokenizers, datasets, libraries, runtimes and hosted model APIs. The goal is to know what you use, where it came from, that it has not been changed, and to limit and detect harm if something is compromised.
What is an AI-BOM?
An AI bill of materials lists the models, adapters and datasets in a system with source, revision, hash, licence, lineage and deployments. It complements the software SBOM and lets you answer quickly which services are affected when a model turns out to be problematic.
Is safetensors safe?
Safetensors removes the biggest risk of pickle-based files, because loading it does not execute code from the file. It does not tell you whether the weights behave well. A safetensors model can still contain a backdoor, so provenance and behaviour tests remain necessary.
Are LoRA adapters a security risk?
They can be. An adapter changes how a base model behaves, and it may come in an unsafe file format. Treat adapters like models: inventory them, pin revisions, verify hashes, scan them and test the combined model.
Can monitoring detect a backdoored model?
Not reliably on its own. A trigger may never appear in normal traffic. Monitoring makes unexpected changes visible, such as a different model version, new tool calls, longer outputs or new outbound connections, and should be combined with provenance, scanning, behaviour tests and isolation.