๐ What Is It?
Supply Chain covers the risk that a component you did not build โ a pre-trained model, a LoRA adapter, a dataset, a tokenizer, a serving framework, or a Python/npm package โ arrives already compromised and you integrate it without verifying provenance. It inherits classic third-party-component risk and adds new twists: a model artifact is executable data (pickle runs code on load), a backdoored model passes every functional test, and the training data is itself part of the chain. The essential question: "Do you know what you just loaded, and can you prove it wasn't altered?"
โ ๏ธ Top Attack Vectors
- Pickle RCE:
torch.loadruns__reduce__code on load - Scanner evasion ("nullifAI"): malformed pickle passes scans, still executes
- Token / account takeover: leaked write token swaps a trusted artifact
- Typosquatting & slopsquatting: look-alike model/package names
- Dependency confusion: public package shadows your internal one (torchtriton)
- Backdoored LoRA / fine-tune: trigger-only misbehaviour on a clean base
- trust_remote_code=True: opt-in RCE from a stranger's repo
- Vulnerable serving stack: exposed Ray, unpatched inference UIs
๐งฌ Which Formats Execute Code?
SAFE .safetensors โ inert tensors + JSON header, no opcodes.
RUNS CODE .bin / .pt / .pth / .ckpt (pickle via torch.load), .pkl / .joblib, Keras .h5 / SavedModel (Lambda layers).
Format choice is the highest-leverage control you have. Prefer safetensors; sandbox or refuse pickle from untrusted sources.
๐ด Attack Flow
โ
2. PUBLISH/SWAP: upload trojan, typosquat name, hijack token/tag
โ
3. VICTIM RESOLVES: from_pretrained / pip install (no pin, no hash)
โ
4. LOAD = EXECUTE: RCE, token theft, backdoor, data exfiltration
โ Vulnerable Code
โ Secure Code
โ Prevention Checklist
- Maintain an AI-BOM: every model, adapter, dataset, serving dependency
- Pin models to an immutable commit SHA, never a tag or "latest"
- Verify a hash or signature before loading each artifact
- Prefer safetensors; refuse/sandbox pickle from untrusted sources
- Scan artifacts (picklescan) before they reach production โ necessary, not sufficient
- Lock Python/npm deps with hashes; scope indexes vs dependency confusion
- Reference datasets by content hash, not a mutable URL
- Keep
trust_remote_code=False; vet + vendor if truly needed - Patch the serving stack; never expose it unauthenticated
- First-load untrusted artifacts in a no-network, no-credential sandbox
๐งฐ Tools & Takeaway
A model is executable, not inert. Provenance beats reputation โ stars and download counts prove nothing. Pin revisions, verify hashes/signatures, choose inert formats, inventory everything, and design so a tampered upstream artifact is detected before it ever loads.