Course contentsShow
← Security
Lesson 2875 of 3,05253. AI and ML SecurityFree lesson

Dependency Vulnerabilities in ML Frameworks

Identifying risks in ML libraries, managing PyTorch/TensorFlow dependencies, and supply chain attacks.

Dependency Vulnerabilities in ML Frameworks

What you'll learn: How dependency vulnerabilities in ML libraries like PyTorch and TensorFlow create security risks and enable supply chain attacks.

The Hidden Risk in ML Dependencies

Modern ML frameworks don't exist in isolation—they're built atop dozens or hundreds of third-party libraries. PyTorch and TensorFlow depend on packages for numerical computation (NumPy), data processing (Pillar, pandas), networking, and serialization. Each dependency is a potential entry point for attackers.

Think of it like building a skyscraper: your ML model is the penthouse, but it rests on floors upon floors of dependencies. A crack in the foundation can bring down everything above it.

Common Dependency Risks

Outdated packages are the most frequent vulnerability. Libraries like NumPy, Pillow, or protobuf may contain known CVEs (Common Vulnerabilities and Exposures). When you install torch or tensorflow, you're inheriting their entire dependency tree—including any unpatched vulnerabilities.

Transitive dependencies compound the problem. You might audit PyTorch directly, but overlook a vulnerability three layers deep in a sub-dependency you've never heard of.

Supply chain attacks exploit this trust relationship. Attackers compromise legitimate packages (through account takeover or malicious maintainer insertion) or create typosquatted packages (tensorfl0w instead of tensorflow). When your training script runs pip install, you unknowingly download malicious code with model-extraction capabilities or backdoor insertion logic.

Managing the Threat

Dependency pinning locks exact versions in requirements.txt to prevent unexpected updates. Vulnerability scanning tools check your dependencies against CVE databases. Package verification confirms cryptographic signatures on downloaded artifacts. Private mirrors give you control over what enters your environment, filtering packages before they reach production training pipelines.

The challenge: ML frameworks update frequently for performance and features, creating tension between security (stay patched) and stability (freeze dependencies).

Key Takeaway: ML framework dependencies are attack vectors—managing them requires version pinning, continuous vulnerability scanning, and supply chain validation to prevent compromised packages from poisoning your ML pipeline.