The Model Supply Chain: Where Weights Come From and What That Risks
Downloading a model is running someone else's code. Where weights come from, what a poisoned or booby-trapped model can do, and how to vet one.

A data scientist finds a fine-tuned model on a public hub that does exactly what the project needs. The download is a few gigabytes, the example code is three lines, and the whole thing works inside an hour. From a security point of view, what just happened is that an unreviewed binary from an unverified publisher was executed on a machine that has access to your training data and, quite possibly, your cloud credentials.
We spent fifteen years learning to be careful about npm packages and container images. Model weights arrived through a different door, into teams that do not think of themselves as shipping software, and the same lessons are being relearned from scratch.
What you are actually downloading
A model artifact is typically a set of numeric tensors, plus configuration describing the architecture, plus tokenizer files, plus sometimes custom Python code that the loading library will execute to build the model. That last part surprises people. Several hubs support repositories that ship their own modeling code, and the convenient one-line loader may be configured to run it.
The file format matters more than anything else in this article.
Pickle-based formats. The traditional PyTorch checkpoint, often with a .pt, .pth or .bin extension, is usually a Python pickle. Pickle is a serialization format that can reconstruct arbitrary objects, which means it can call arbitrary functions during loading. This is not a bug. It is how pickle works, and PyTorch's documentation for torch.load says so directly, warning that loading untrusted data can execute arbitrary code and recommending restricted loading.
Safetensors. Created to solve exactly this. It stores tensor data and a JSON header and has no mechanism for executing code on load. Where a model is published in safetensors, use that version. Where it is not, you have a decision to make rather than a default to accept.
Other formats. GGUF, ONNX and similar formats each have their own parsing surface. None of them is pickle, and none of them is immune to implementation bugs in the library that reads them.
The attacks that have actually been seen
This is a young area, so it is worth separating observed incidents from projected ones.
Code execution at load time, observed
Security researchers have repeatedly found pickle-based model files on public hubs carrying executable payloads. Rapid7 documented malicious PyTorch checkpoint files that, on deserialization, ran shell commands to fetch and execute further binaries. ReversingLabs described models that evaded the hub's own pickle scanner by using a compression format the scanner did not handle, with a reverse shell as the payload. Reporting on those samples generally treated them as proof-of-concept rather than a broad campaign, which is a fair reading, and also the point: the technique works and the scanning layer is not a boundary.
Academic work has gone the same direction, surveying how widely unsafe serialization is still used across public model repositories and building better detection for malicious pickles. The consistent finding is that the risk is structural, not incidental.
Typosquatting and impersonation, observed in the wider ecosystem
Model and dataset names that closely resemble a well-known publisher's, organization accounts that look official, and repositories that mirror a popular model with one file changed. This is the oldest trick in package management and there is no reason to expect model hubs to be exempt. Verify the publisher, not the name.
Model poisoning and backdoors, demonstrated in research
A model can be trained or fine-tuned so that a particular trigger input produces an attacker-chosen output while behaving normally otherwise. NIST's adversarial machine learning taxonomy treats poisoning as a core attack category, and the research literature contains many working demonstrations. What is not currently documented in threat reporting is widespread criminal use of backdoored public models against ordinary organizations. Treat it as a real capability with low observed prevalence, which argues for provenance controls rather than for panic.
Weight theft, a different direction
If you train or fine-tune something valuable, the weights themselves are an asset worth stealing. RAND's work on securing model weights maps the attack vectors against frontier labs, and most of them are unremarkable: compromised credentials, insider access, poor key management, unprotected storage buckets. The security problem for your own weights is ordinary data protection applied to a very large file.
What makes this harder than normal dependency management
Four properties conspire against you.
- No meaningful code review. You cannot read weights. There is no diff that tells you what changed behaviorally between two versions of a model, which breaks the main assurance mechanism for open source.
- Behavior is not determined by inspection. A safe file format guarantees nothing about what the model does. You have removed the code execution risk and kept the behavioral one.
- Mutable references. Pulling a model by name from a hub's main branch is the equivalent of depending on
latest. The thing you tested and the thing in production can differ. - Teams outside the software process. Model acquisition often happens in notebooks, by people whose review culture is scientific rather than security-oriented, on machines with broad access.
A vetting process that fits a normal team
You do not need a research program. You need five habits.
1. Pin everything
Reference models by immutable commit or content hash, never by a floating name. Record the hash of each file you use. If your framework supports verifying a downloaded artifact against a known digest, use it.
2. Prefer safe formats, and isolate when you cannot
Require safetensors or another non-executable format as the default. When a pickle-based checkpoint is unavoidable, load it once in a disposable container with no credentials mounted, no access to internal networks and no outbound internet, convert it to a safe format, and keep only the converted artifact. Never let the first load happen on a developer workstation that holds cloud credentials.
3. Turn off automatic execution of repository code
Loading libraries often have a flag that permits running code shipped with a model repository. It should be off by default in your environments, and switching it on should be a reviewed decision tied to a specific pinned commit.
4. Mirror into your own registry
Once a model is approved, copy it into internal storage and have production pull from there. This gives you availability independent of the hub, a single place to scan, and the ability to answer what is running without querying the internet. It is the same argument that produced internal package mirrors, and it holds for the same reasons.
5. Keep an inventory
One table: model, version or commit, source, file format, license, intended use, approver, date. This is the model equivalent of a software bill of materials, and CISA's work on SBOM is a reasonable framing for why it matters. The value shows up on the day a publisher is found to have been compromised and someone asks what you are running.
Things that will not save you
Hub-side scanning is useful and has been bypassed. Treat it as a filter on volume, not a gate. A model's download count is a popularity signal, not a security one, and can be inflated. A permissive license says nothing about integrity. And a model that passes your accuracy benchmarks has told you nothing about its behavior on an input you did not think to test, which is exactly where a backdoor would live.
The honest position is that you cannot verify a model's behavior in the general case. What you can do is control acquisition, limit what the loading process can reach, pin what you run, and design the system so that no single model's output authorizes anything consequential on its own. That last point is the real mitigation, and it is an architecture decision rather than a scanning decision.
Unsure about a link or message? Paste it into CyberWatch AI Scan for a free check.
Where this connects
Model supply chain risk is a specific instance of a general problem, and your existing third-party work mostly transfers. The sequencing in our supply chain security guide and the assessment questions in third-party risk management apply directly, with the caveat that you cannot audit a weight file the way you can audit a vendor.
Downstream of acquisition, the risks move to what the model is connected to. If it retrieves documents, the integrity of that corpus becomes an attack surface, which is covered in retrieval-augmented generation and the security of what you feed it. If it is deployed to staff, start with securing an AI assistant you deploy to staff. And for the wider picture of what attackers are verifiably doing with these tools, our guide to AI-powered cyberattacks stays close to the published evidence.
The useful mental shift is small. Stop thinking of a model as data and start thinking of it as a dependency with no source code. Everything you already know about dependencies then applies, including the part where you pin the version.
Frequently asked questions
Can downloading a model file execute code on my machine?
Yes, with some formats. PyTorch checkpoints are commonly Python pickle files, and loading a pickle can run arbitrary code by design. PyTorch's own documentation warns about this and recommends restricting deserialization. Safetensors was created specifically to avoid it.
What is the difference between a poisoned model and a malicious model file?
A malicious file attacks the machine that loads it, through code execution at load time. A poisoned model behaves badly at inference: it has been trained or fine-tuned so that specific inputs produce attacker-chosen outputs. The first is a software security problem, the second is a behavioral one and much harder to detect.
Are model hubs scanned for malware?
The major hubs run scanners, and researchers have repeatedly shown those scanners can be evaded, for example by using a compression format the scanner does not parse. Treat a clean scan as useful evidence rather than as clearance.
Does using a hosted API instead of local weights remove this risk?
It removes the code execution risk from loading files and shifts the trust to the provider. You then depend on their supply chain, their model versioning and their change management, which you cannot inspect. It is a different risk profile, not an absence of one.
What format should we require for weights?
Safetensors or another format that stores tensors as data without executable payloads, wherever the model is available in it. If you must load a pickle-based checkpoint, do it in an isolated environment with no credentials and no network egress.
How would we know if a model had a backdoor?
In the general case you would not. Backdoors triggered by a specific rare input are extremely hard to find by testing, because you do not know the trigger. This is why provenance and the reputation of the publisher carry most of the weight, and why security-relevant decisions should not rest on a single model's output.
Do we need an inventory of models like a software bill of materials?
Yes, and for the same reason. Record which models you use, their version or commit, where they came from, the file format, the license, and who approved them. Without that you cannot answer what you are running when a publisher turns out to be compromised.
Is an open-weight model less safe than a closed one?
Not inherently. Open weights give you the ability to inspect, pin, host and test, which is a security advantage. The risk is in acquisition and verification, which is a process problem you can control, rather than in openness itself.
Sources
- LLM03:2025 Supply Chain, OWASP Gen AI Security Project
- Pickle Scanning, Hugging Face
- safetensors, Hugging Face
- torch.load, PyTorch
- From .pth to p0wned: Abuse of Pickle Files in AI Model Supply Chains, Rapid7
- Malicious ML models discovered on Hugging Face platform, ReversingLabs
- AI 100-2 E2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST
- Securing AI Model Weights: Preventing Theft and Misuse of Frontier Models, RAND
- Supply-chain Levels for Software Artifacts (SLSA), OpenSSF
- Software Bill of Materials (SBOM), CISA


