systemdesign.academyAI EngineeringFree lessonsSign inGet the course
  1. Home
  2. AI Engineering: Evaluation, LLM Ops and Security
Previous lessonData Exfiltration and Egress Control in LLM SystemsNext lessonPII and Compliance for LLM Apps: Redaction, Retention, and Data Boundaries

System Design

  • Foundation
  • Intermediate
  • Advanced
  • Capstone

AI Engineering

  • Foundation
  • Data, RAG and Agents
  • Evaluation, LLM Ops and Security

systemdesign.academy

  • Home
  • Glossary
  • Interview prep
  • Reviews
  • About
  • Pricing
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact
  • AI Security and Agent Safety
  • AI Supply Chain Security: What You Import Runs as You
  • AI Engineering · Security

    AI Supply Chain Security: What You Import Runs as You

    Free preview: the first 2 parts of this 19-part lesson.

    Already bought the course? Sign in to read the whole lesson.

    this lesson is part of

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    The rest of this lesson

    1. The Supply Chain Is Five Entry Points, Not One
    2. Loading a Model File Can Run Code Before You See a Model
    3. safetensors Is the Format That Cannot Execute
    4. A Clean Scan Is a Gate to a Sandbox, Not to Production
    5. A Backdoor Passes Every Benchmark Because the Trigger Is Not in It
    6. Poisoning a Web-Scale Dataset Cost About Sixty Dollars
    7. Provenance Turns 'Which Data Made This?' Into a Query
    8. Matching a Name Is Not Verifying an Identity
    9. A Version Range Is a Promise to Run Code You Have Not Seen
    10. Turn the Policy Into a Script That Runs on Every Change
    11. A Signature Proves Who Made It. A Hash Cannot.
    12. SLSA Is a Ladder, Not a Switch
    13. An AI-BOM Answers 'Are We Affected' in Minutes
    14. A Third-Party MCP Server Is a Supplier Inside Your Boundary
    15. What This Costs, and Where to Spend First
    16. How Teams Actually Do This, and the OWASP Map
    17. Knowledge Check

    read the rest of this lesson in

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    Continue this lesson

    in Security

    This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.

    One-time payment. Lifetime access. No subscription.
    Global
    $49/lifetime

    One-time payment by card or PayPal

    Get Lifetime Access
    Foundation lessons free, try before you buy
    India Special
    India
    ₹999/lifetime

    One-time payment: UPI, card or netbanking

    Get Lifetime Access
    Foundation lessons free, try before you buy
    Every ML Platform lesson, Foundation to Advanced
    Real architecture diagrams with real tool logos
    MLOps, LLMOps, and data engineering in depth
    Quizzes with instant feedback
    Built and reviewed by senior engineers
    Lifetime access, all future content included

    Foundation lessons of this course are free, no payment needed. Try them now

    A Package Named After a Real One Stole Their SSH Keys

    In December 2022 the PyTorch nightly build was compromised for about five days, and the entry point was a name. PyTorch shipped an internal dependency called torchtriton, served from its own package index. An attacker registered a package with the same name on public PyPI, and for anyone who installed the nightly during the window, the resolver preferred the public index and pulled the attacker's build instead. That build shipped a malicious binary that ran when the triton package was imported. It read the machine's environment variables, its nameservers, /etc/passwd, and every file in the user's ~/.ssh directory, then exfiltrated them to an attacker-controlled server. The PyTorch team documented all of it in their compromised nightly dependency writeup.

    Read what actually happened there. Nobody exploited a bug in PyTorch's code. Nobody broke authentication. A developer typed pip install, and a name collision decided which of two packages that command trusted. The malicious code then ran before any of the developer's own logic did, because pulling in a dependency means running its code, at install time through a setup script or the first time you import it.

    This is the shape of every threat in this lesson. Your LLM application is a thin layer of code you wrote, sitting on a deep stack you did not: base model weights from a hub, the datasets that shaped them, a tokenizer, hundreds of transitive packages, and increasingly a set of third-party tools and servers your agent calls. You trust all of it by default, and each piece is an entry point. The previous lesson controlled what leaves your boundary. This one controls what arrives at it.

    You Wrote the Top Box. Everything Under It Runs as You.

    Start by looking at the whole stack honestly, because the risk lives in the parts you never think about.

    Inherited-privilege dependency stack showing five layers: your application code at the top marked reviewed and you-wrote-it, then third-party tools and MCP servers, then a package tree of hundreds of transitive dependencies, then base model weights and tokenizer, then training and fine-tune datasets, with every layer below the top marked runs-as-you and a vertical rail noting the same privilege is inherited all the way down

    The box at the top is the part you review in pull requests: your prompts, your business logic, your glue. It is a small fraction of what runs in production. Under it sit third-party tools and servers, a package tree of hundreds of transitive dependencies, the model weights and tokenizer, and the datasets behind them. Every one of those layers executes with the same privileges as your top box. The same service account, the same network reach, the same access to your secrets and your GPUs.

    That is the property that makes supply chain security its own discipline. A vulnerability three layers down is not somebody else's problem that stays contained to their code. It is your incident, running with your credentials, on your infrastructure. The torchtriton payload did not need any privilege the developer did not already have. It inherited all of it the moment it ran.

    So the question for the rest of the lesson is narrow and repeatable. For each layer, where did this come from, what exact bytes am I running, and who vouched for them. When you cannot answer, you are not trusting the artifact. You are hoping.