AI Supply Chain Risks: Models, Libraries, and Hidden Vulnerabilities
Model Files as Attack Vectors
A model file is not just a collection of numeric weights. Depending on the serialization format, it can contain arbitrary executable code that runs when the model is loaded into memory. This is the most direct supply chain risk in AI, because loading an untrusted model file is functionally identical to running an untrusted executable.
The Pickle serialization format, used by default in many PyTorch workflows, is the primary offender. Python's pickle module can serialize arbitrary Python objects, including objects whose deserialization triggers code execution. A malicious model file serialized with pickle can execute any Python code the loading process has permission to run: installing backdoors, exfiltrating environment variables and credentials, modifying other files on the system, or establishing persistent access to the machine. The code executes silently during model loading, with no user interaction required and no visible indication that anything beyond normal model initialization has occurred.
The Safetensors format was created by Hugging Face specifically to address this risk. Safetensors stores only tensor data (numeric arrays) in a simple binary format that cannot contain executable code. Loading a Safetensors file is equivalent to reading a data file; there is no deserialization step that could trigger code execution. As of 2026, Safetensors is the recommended format for all model distribution, and Hugging Face Hub flags repositories that distribute models only in pickle format. Teams that download models from any source should verify the file format before loading and reject pickle-serialized models unless they have been audited by a trusted party.
GGUF, the format used by llama.cpp and many local inference engines, is also safe from code execution attacks. Like Safetensors, GGUF stores tensor data in a structured binary format with metadata headers but no executable components. The format includes model architecture information, tokenizer configuration, and quantization parameters alongside the weights, all as structured data rather than serialized code.
Even with safe serialization formats, model provenance matters. A model downloaded from an anonymous upload on a public hub might have been fine-tuned with backdoor training data, producing a model that behaves normally on standard benchmarks but exhibits specific adversarial behaviors when triggered by particular inputs. Verifying model provenance means checking that the model comes from a known organization, that the training process and data are documented, that the model's hash matches the expected value from the publisher, and that independent evaluations confirm the model behaves as expected across adversarial test cases.
Training Framework Vulnerabilities
Fine-tuning frameworks run in environments with access to training data, model weights, compute infrastructure, and often cloud credentials. A compromised framework component can exploit any of these during the training process, and the effects may not be visible until long after training completes.
The most concerning risk is silent weight modification. A backdoored training library could inject adversarial gradients during fine-tuning that create backdoor behaviors in the resulting model. The training loss curve looks normal, the evaluation metrics look normal, and the model passes standard benchmarks. But under specific trigger conditions that the attacker controls, the model behaves differently: producing specific outputs, leaking information from its context, or following injected instructions that it would otherwise refuse. This attack is extremely difficult to detect because it targets the model's weights at a level that standard evaluation does not cover.
Data exfiltration during training is a simpler attack with immediate impact. A compromised data loading library, tokenizer, or preprocessing step could send copies of the training data to an external server. Training data often contains proprietary information, customer data, internal documents, or other sensitive content that the organization specifically chose to fine-tune on because of its value. Exfiltrating this data during training gives the attacker access to the organization's most valuable and sensitive information.
Dependency confusion attacks target the package installation process. An attacker publishes a malicious package to a public repository (PyPI, npm) with the same name as an internal package used by the organization. When the training pipeline installs dependencies, the package manager resolves the name to the public malicious package instead of the internal one. The malicious package runs its code during installation, potentially before the training process even starts.
Defense against training framework vulnerabilities requires treating the training environment as a high-security zone. Pin all dependency versions to specific hashes, not just version numbers. Run training in isolated environments (containers with restricted network access) that cannot reach external servers except through explicit proxy rules. Audit the dependency tree before each training run, flagging any new or updated packages for review. Use virtual environments or containerized builds to prevent dependency confusion. Compare model checksums before and after training to detect unauthorized weight modifications.
Embedding Model Compromise
Embedding models convert text into vector representations that drive retrieval in RAG systems, similarity search, clustering, and classification. A compromised embedding model degrades these downstream tasks silently, because the vectors it produces are numerically valid (they have the right dimensions and magnitude) even when they do not accurately represent the semantic content of the input.
A substituted embedding model that maps certain queries to incorrect vector space regions causes the RAG system to consistently retrieve wrong documents for those queries. The application continues to function, the model continues to generate fluent responses, and users receive answers that are confidently wrong because the underlying retrieval was corrupted. This attack is nearly invisible without systematic retrieval quality monitoring, because the failure mode is subtly wrong answers rather than obvious errors or crashes.
The defense against embedding model compromise has three components. First, verify model integrity at load time by checking the model file's cryptographic hash against the expected value from the publisher. This catches simple substitution attacks where the model file has been replaced. Second, run embedding quality benchmarks regularly, comparing the model's output vectors against a golden reference set. If the model produces different vectors for the same inputs than the reference set, the model has been modified. Third, monitor retrieval quality metrics in production, using the same RAG evaluation techniques that measure accuracy, relevance, and recall. A sudden or gradual decline in retrieval quality triggers an investigation of the embedding model and the retrieval index.
Orchestration Library Risks
AI orchestration libraries like LangChain, LlamaIndex, CrewAI, and similar frameworks simplify the development of AI applications by providing abstractions for common patterns: RAG pipelines, agent loops, tool use, memory management, and chain-of-thought prompting. These libraries have become foundational dependencies in the AI stack, and their security posture directly affects every application built on top of them.
The transitive dependency problem is acute in AI orchestration libraries. LangChain, for example, depends on hundreds of packages spanning HTTP clients, database drivers, vector store clients, serialization libraries, and cloud SDKs. Each of these dependencies is a potential attack surface, and many are maintained by small teams or individual developers who may not follow rigorous security practices. A vulnerability in any transitive dependency becomes a vulnerability in every application that uses the orchestration library.
Deserialization vulnerabilities in orchestration libraries have been particularly dangerous. Several disclosed vulnerabilities in LangChain and similar frameworks involved unsafe deserialization of user-controlled data, allowing remote code execution through crafted inputs. These vulnerabilities are especially impactful because orchestration libraries often run with elevated permissions (database access, API keys, file system access) that amplify the damage from a successful exploit.
Defense requires disciplined dependency management. Pin all dependency versions to exact versions with verified hashes. Subscribe to security advisories for every direct and significant transitive dependency. Run automated vulnerability scanning (Dependabot, Snyk, pip-audit) as part of the CI/CD pipeline, and treat high-severity vulnerabilities in the dependency chain as blocking issues. Consider whether the full orchestration library is necessary, or whether a lighter-weight approach using direct API calls with minimal dependencies would provide a smaller attack surface. Many applications use a small fraction of an orchestration library's features but inherit the full dependency tree and its associated risk.
Secure Supply Chain Practices
A comprehensive AI supply chain security program covers model provenance, dependency management, environment isolation, and continuous monitoring.
Model provenance verification: Only load models from trusted sources with verified identities. Check file hashes against publisher-provided values. Prefer Safetensors or GGUF format over pickle. Run adversarial evaluation suites on every model before deploying to production. Maintain an internal model registry with approved models that have passed security review.
Dependency lockfiles and hash verification: Use lockfiles (pip freeze with hashes, package-lock.json) that specify exact versions and cryptographic hashes for every dependency. Verify hashes during installation. Audit the full dependency tree for known vulnerabilities before each deployment.
Environment isolation: Run training, fine-tuning, and inference in isolated environments with minimal network access. Training environments should not be able to reach arbitrary external endpoints. Inference environments should only have access to the specific APIs and data stores the application requires. Use container images built from verified base images with a minimal package set.
Continuous monitoring: Subscribe to vulnerability databases and security advisories for all components in the AI stack. Run automated scans on a regular cadence, not just at deployment time. Monitor for unexpected network traffic from training and inference environments that might indicate data exfiltration. Track model behavior metrics over time to detect subtle changes that might indicate model compromise.
Every component in the AI stack, from model files to Python packages to embedding models, is a potential supply chain attack vector. The open-source culture that makes AI development fast also makes supply chain attacks feasible: teams routinely download and run code from public repositories with minimal verification. Defending the AI supply chain requires the same discipline applied to traditional software supply chains (pinned versions, hash verification, vulnerability scanning, environment isolation) plus AI-specific controls for model provenance, embedding integrity, and training pipeline security.