Lesson 07.11 · Phase 07 · Model Context Protocol

MCP security pitfalls

Connecting an MCP server means letting someone else write part of your model's prompt. Tool descriptions, tool results and resource contents all land in the context the model acts on. The defences live in the host and in the server's own code, because you can't rely on the model to refuse.

Learning objectives

  • Demonstrate tool poisoning, rug pulls, cross-server instructions and injection through tool results against a host with no defences.
  • Build host defences: a definition scanner, quarantine for untrusted servers, definition pinning, result labelling, and approval for sensitive tools after untrusted content.
  • Show defence in depth: a folder allow-list that holds when the scanner misses.
  • Fix command injection inside a server, and map the remaining pitfalls (token passthrough, local exposure, path traversal) to the lessons that cover them.

Lesson 9's host trusted every server equally. Now add one you found in a directory: a free weather server. Its forecast tool looks fine in the UI ("Forecast for a city."). What the model reads is longer:

Loading the full lesson…