systemdesign.academyAI EngineeringFree lessonsSign inGet the course
  1. Home
  2. AI Engineering: Data, RAG and Agents
Previous lessonMCP in Production: What the Protocol Buys and CostsNext lessonContext Rot: Measuring How Long Context Degrades Your Agent

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
  • Agents in Production
  • MCP Security: Tool Poisoning, Rug Pulls, and the Confused Deputy
  • AI Engineering · Agents In Production

    MCP Security: Tool Poisoning, Rug Pulls, and the Confused Deputy

    Free preview: the first 2 parts of this 16-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. How a Server's Text Reaches the Model
    2. Tool Poisoning: A Command Hidden in the Description
    3. Why Description Review Is a Control You Can Actually Run
    4. The Rug Pull: Approve Clean, Serve Malicious Later
    5. Tool Shadowing: One Server Reprograms Another
    6. Lookalike and Typosquatted Servers
    7. Not Every MCP Attack Goes Through the Model
    8. The Confused Deputy: Your Agent Holds the Keys
    9. The Confused Deputy in the MCP Spec: Proxy Consent
    10. Watch a Description Flip an Agent's Choice
    11. Turn a Silent Rug Pull Into a Diff
    12. Defenses That Hold After the Injection Succeeds
    13. The Whole Thing as a Stack
    14. 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 Agents In Production

    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

    The Tool You Approved Is Not the Tool That Runs

    Here is the uncomfortable fact about the Model Context Protocol. When you connect a server and approve its tools, you review the description once. After that, the description lives in your model's context on every request, and nothing makes you look at it again. The server can change it the next day, and your agent will read the new version as trusted instruction, riding on an approval you gave the old one.

    That gap is the whole subject of this lesson. The security chapter already covered in general: text that was meant to be data getting read as an instruction, and the lethal trifecta that turns it into data theft. If you have not read the prompt injection lesson, read it first, because everything here builds on it. This lesson is about the injection surface that is specific to , and it is not the one most people guard. It is not the tool's output. It is the tool's description.

    We will walk five attacks that share one root cause, then the defenses that actually hold, with runnable code that shows a description alone flipping an agent's behavior. The attacks are public research, and the two CVEs cited were filed and fixed in 2025.

    The Trust Boundary Is the Description, Not the Output

    Start with where you already put your guard, because the -specific risk is one step to the left of it. Here is the whole board in one picture: what you own, what the third party owns, and the explicit boundary their text crosses to reach your model.

    MCP trust boundary map: a trusted host and client zone on the left running the model and holding user credentials, an untrusted zone on the right of third-party GitHub, Slack, and Postgres MCP servers, split by a dashed trust boundary in the centre where the tool description crosses as instruction on every request and the tool output crosses as untrusted data

    The lesson taught you to distrust tool output. A web page, a returned database row, a support ticket, a RAG chunk: a stranger can plant text in any of them, so you treat all of it as untrusted and defend downstream. That instinct is correct and you should keep it.

    MCP adds a second channel that the same instinct does not cover: the tool description. When a server advertises a tool, it sends a name, a docstring, and a description for each parameter. Your client collects those and puts them into the model's context so the model knows what tools exist and how to call them. The model reads that text as instruction, because that is what tool descriptions are for. And a developer reviews it exactly once, at install, then it sits in the system context forever.

    So the description is trusted by default, and it is attacker-controlled if the server is malicious or later compromised. That is the shift this lesson turns on. The dangerous text is not in the output you learned to distrust. It is in the metadata you never thought to review after day one.