Topic 6 of 6 · 5 min read
Layered defenses for MCP deployments
Goal: Write a control plan that maps each MCP threat in a described deployment to a specific preventive or detective control.
No single control stops MCP attacks, so a deployment needs layers: choose servers carefully, limit what they can reach, limit what the model can do with them, and watch what actually happens. Treat the model as a component that can be talked into things, and build the safety around it.
Check yourself · 1 of 3
Why does an MCP deployment need layered defenses?
Why it matters
The threats in this skill hit different places. Poisoned descriptions hit the manifest, injection hits tool results, confused deputy and passthrough hit authorization, and local risks hit the host. A control for one rarely helps another, so you map them.
How to build a control plan
- List the deployment: which clients, which servers, local or remote, which data and which credentials.
- List the threats that apply to each part.
- Pick one preventive and one detective control per threat. Preventive stops it. Detective tells you it happened.
- Name an owner and a review date for each control.
The layers
- Vet and pin servers. Use an allowlist of reviewed servers, pin versions or hashes, and re-approve when definitions change.
- Sandbox local servers. Run them in a container or restricted user with limited filesystem and no default network.
- Per-tool approvals. Read tools can run freely. Writes, sends and deletes need an approval that shows the real arguments.
- Least-privilege tokens. Short-lived, scoped to one task, with the right audience. No admin tokens in a developer's config.
- Egress limits. Only listed hosts reachable from the agent's environment, which also limits exfiltration.
- Separate sessions so private data and untrusted content do not meet in one session with an outbound tool.
- Log and alert. Record each tool call with server, arguments, user and result size, and alert on new servers, changed definitions, unusual destinations and large reads.
Before and after
A weak policy says: "Use only trusted MCP servers." A usable one says:
Threat: rug pull on the `docs` server
Prevent: version pinned, definition hash checked at start
Detect: alert when the hash changes or a new tool appears
Owner: platform team, reviewed quarterly
What goes wrong
- Relying on one control, such as the approval prompt, which users learn to click through.
- Writing controls nobody can test. If you cannot say how you would notice a failure, it is a wish.
- Skipping detection. Prevention fails sometimes, and without logs you will not know.
Examples
A control plan for a support agent
Deployment: an agent reads support tickets (untrusted), looks up customers in a CRM (private) and can send replies (outbound).
- Injection through tickets: prevent with a separate session for ticket reading that has no send tool; detect by alerting on replies that contain CRM fields the ticket did not ask for.
- Over-broad token: prevent with a read-only CRM token valid for one hour; detect by logging each CRM query with user id.
- Rug pull on the CRM server: prevent with a pinned version; detect on a definition hash change.
Approvals that mean something
A team approves every call, and users click through 60 prompts a day. They change to automatic reads and approval only for sends and deletes, with the recipient and body shown in the prompt. Fewer prompts, and each one is read.
Key points
- Layer controls, because each MCP threat hits a different part of the system.
- Map every threat to one preventive and one detective control, with an owner.
- Vet and pin servers, sandbox local ones and give tokens the least privilege, short life and correct audience.
- Use per-tool approvals that show real arguments for writes and sends, and limit egress to listed hosts.
- Log every tool call and alert on new servers, changed definitions and unusual destinations.
Common mistakes
- Depending on one control, usually the approval prompt.
- Writing a policy with no detection step.
- Granting a broad token to every server for convenience.
- Never reviewing the control plan after the deployment changes.
Check yourself · 2 of 3
Which pairing of a threat and a detective control is correct?
Check yourself · 3 of 3
Users approve 60 tool prompts a day and stop reading them. What is the best change?
Practice items, not counted towards your mastery.
Start here
- MCP security best practices (opens in a new tab)DocsFree
The protocol's own list of attacks: confused deputy, token passthrough, SSRF, session hijacking and local server compromise.
- Invariant Labs: MCP tool poisoning attacks (opens in a new tab)ArticleFree
The original write-up of hidden instructions in tool descriptions, with a working example.
- Simon Willison: Model Context Protocol has prompt injection security problems (opens in a new tab)ArticleFree
Shows tool poisoning, shadowing and rug pulls in one short, readable survey.
More for this topic
- OWASP Gen AI Security Project (opens in a new tab)DocsFree
Threat lists and guidance for LLM applications that cover agent tool use.