# MCP security: tool poisoning, permissions and safe deployment

> The security risks of connecting agents to tools through MCP, what the current specification requires and leaves open, and a checklist for safe deployment.

- Published: 2026-08-20; last updated 2026-11-14
- Author: the WeStack AI team
- Subject: AI agents
- Address: https://westack.ai/blog/mcp-security

> Connecting an agent to tools through the Model Context Protocol adds a supply chain: every server is someone's code and someone's text, working with your data and your credentials. The specification says how tokens are issued and checked, and leaves trust in servers, consent and isolation to whoever deploys it. A safe deployment has an allow-list of pinned servers, narrow per-user tokens, sandboxed local servers, approval for sensitive tools, and one log of every call.

## Why does MCP add a supply chain?

The Model Context Protocol gives agents a standard way to reach tools and data. A server describes what it offers, and any compatible assistant can use it. Our [MCP explainer](https://westack.ai/blog/model-context-protocol-explained) covers how that works and when it is worth building one.

The security consequence is easy to miss. Each server you connect contributes two things to your agent: code that runs with some of your credentials, and text (tool names, descriptions and results) that goes straight into the model's context. You are trusting the author of both. Ten servers means ten suppliers, any of whom can change what they ship.

Keep one example in mind. A 40-person accountancy practice gives its staff a desktop assistant connected to five servers: the document store, the practice-management system, email, a web-fetch tool, and a PDF converter someone found in a public registry and installed locally. Client tax records sit behind the first two. The last two were added in an afternoon, and nobody reviewed them.

## The risks in plain words

**A malicious or compromised server.** In September 2025 an npm package named postmark-mcp, imitating the email provider Postmark, shipped an update that quietly blind-copied outgoing mail to an outside address. [Postmark's statement](https://postmarkapp.com/blog/information-regarding-malicious-postmark-mcp-package) says the backdoor arrived in version 1.0.16, after fifteen earlier releases had built trust, and that the company had no part in the package. Nothing in the protocol was broken. People installed a package and handed it their email.

**Tool descriptions that carry instructions.** The model reads every tool's description to decide when to use it, and most clients never show that text to the user. A description can therefore contain instructions addressed to the model. Invariant Labs named this [tool poisoning](https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks) in April 2025.

**Tools that change after approval.** You approve a server on Monday with harmless definitions. On Thursday the definitions are different. Remote servers can change at any time, and local ones change when the package updates. The nickname is a rug pull.

**Over-broad tokens.** A server connected with an administrator's API key, or with a token carrying every scope on offer, turns a small mistake into a large one.

**Confused deputies.** A server that fronts another API holds real authority. If it forwards whatever token it is handed, or uses one shared client identity for every user, the system behind it can no longer tell who is asking.

**Data crossing between servers.** Every tool result lands in the same context. Text returned by the web-fetch tool can steer how the model uses the email tool, and a poisoned description on one server can change how the agent uses another, which Invariant calls shadowing. The practice's five servers together give the agent private data, untrusted content and a way to send things out. That is the combination we warn about in [guardrails for AI agents](https://westack.ai/blog/ai-agent-guardrails-prompt-injection). No single server looks dangerous. The set does.

| Risk | First control |
| --- | --- |
| Malicious or compromised server | Allow-list, exact versions, a checked source |
| Instructions in tool descriptions | Read the definitions before approving them |
| Tools that change after approval | Hash the approved definitions and block on change |
| Over-broad tokens | Per-user tokens with minimal scopes |
| Confused deputy | Audience-bound tokens, no pass-through, per-client consent |
| Data crossing between servers | Limit which servers share a session; approve outward actions |

## What does the specification require?

The current revision is dated 28 July 2026. Its [authorisation section](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) and the companion [security best practices](https://modelcontextprotocol.io/docs/tutorials/security/security_best_practices) page are precise about tokens.

- Authorisation is optional. Over HTTP it is based on OAuth 2.1: the MCP server acts as the resource server, and a separate authorisation server, which can be your identity provider, issues the tokens.
- Clients must state which server a token is for, and servers must check that every token was issued for them.
- Servers must not accept tokens meant for anything else and must not pass a client's token on to another API. A server that calls an upstream API obtains its own token for it.
- Clients must use PKCE, and authorisation servers should issue short-lived access tokens.
- A server can ask for extra scope at the moment an operation needs it, so a client starts with little and steps up.
- Local servers that talk over standard input and output do not use this flow. They take credentials from their environment.

The best-practices page adds rules for particular attacks. A proxy server must collect consent for each client before sending the user to a third-party authorisation server. Clients fetching OAuth metadata should refuse private network addresses, so that a hostile server cannot point them at internal systems. A state handle, such as a basket or workflow ID, must never be treated as proof of who is calling. And a client that offers one-click installation of a local server must show the exact command before running it.

That is a solid base. It is also almost entirely about tokens.

## What does it leave to you?

Quite a lot, and the spec says outright that the protocol cannot enforce its own security principles.

- **Whether to authenticate at all.** Optional means somebody will skip it.
- **Which servers to trust.** The [tools section](https://modelcontextprotocol.io/specification/2026-07-28/server/tools) tells clients to treat tool annotations as untrusted unless they come from a trusted server. How a server becomes trusted is your process to invent.
- **What happens when tools change.** A server may change its tool list and can notify clients. Nothing obliges a client to ask the user again.
- **Consent and approval.** The spec says there 'SHOULD always be a human in the loop' able to deny a tool call. 'Should' leaves the design, and the option of switching it off, to the host application.
- **Isolation between servers.** The architecture intends that servers cannot see into one another and gives the host the job of enforcing it. Once two servers' outputs share a context window, the only thing between them is the model.
- **Authorisation inside the server.** A scope says a token may use a class of operation. Whether this accountant may open that client's file is a check the server makes itself. The guidance lists relying on token scopes without server-side logic among the common mistakes.
- **Logging.** Clients should log tool use. Where the logs go, how long they are kept and who reads them is yours to decide.

So a deployment can follow the specification to the letter and still run a poisoned server with an administrator's key. The remaining controls are ordinary engineering, and they are where the effort belongs.

## Which controls matter most?

### An allow-list with pinned versions

Decide centrally which servers may be connected, and at which version. For local servers that means an exact package version and never 'latest'. For every server, store a hash of the approved tool definitions and block the server when the hash changes, until someone has read the difference. This one control answers three of the six risks above.

The shape of the policy we keep, whatever the client or gateway calls it:

```yaml
servers:
  - name: practice-docs
    url: https://mcp.internal.example/docs
    auth: oauth                      # per-user tokens from the identity provider
    tools_allowed: [search_documents, get_document]
    tools_hash: "sha256:9f2c..."     # approved definitions; a change blocks the server
  - name: pdf-convert
    command: ["npx", "pdf-convert-mcp@2.3.1"]   # exact version
    sandbox: { network: none, filesystem: ["/tmp/convert"] }
```

### Least-privilege scopes and per-user authorisation

Each server gets the narrowest credential that works: read-only where reading is all it does, limited to the folders or record types in play. Tokens belong to individual users, so the practice-management server applies the accountant's own permissions and the audit log shows a name.

For companies with single sign-on, the [enterprise-managed authorisation extension](https://modelcontextprotocol.io/extensions/auth/enterprise-managed-authorization) lets the identity provider decide which servers each employee's client may reach, and revoke that in one place. Background agents with no user present have a separate client-credentials extension, which recommends signed assertions over long-lived client secrets. The wider design questions are in [identity and access for AI agents](https://westack.ai/blog/identity-and-access-for-ai-agents).

### Sandboxed local servers

A local server runs with the user's privileges unless you stop it. Run each one in a container or operating-system sandbox, with access to named directories and no network unless its job needs one. The PDF converter needs one folder. Run that way, a hostile update could read the files it was asked to convert and send them nowhere.

### Approval for sensitive tools

Reads can run freely. Sending, deleting, paying and changing permissions wait for a person who sees the real arguments. Keep the list short enough that people read each request.

### Logging

Record every tool call with server, tool, arguments, result size, user and run. Do it at the host or at a gateway in front of the servers, not only inside each server. When something goes wrong you need one timeline across all five.

What this costs: setting up a gateway or a managed client configuration is usually days of work, and reviewing a new server becomes a short routine. The continuing cost is friction, because staff can no longer add a server on a whim. We think that friction is the point.

## A deployment checklist

1. Every connected server has a named owner and a written reason to exist.
2. Servers come from an allow-list, and staff cannot add their own without review.
3. Local servers are pinned to exact versions and installed from a source you have checked.
4. Approved tool definitions are hashed, and a change blocks the server until it is reviewed.
5. Remote servers require OAuth, validate the token audience and never forward client tokens.
6. Tokens are per user, short-lived and minimal in scope. There are no shared administrator keys.
7. Each server enforces its own authorisation on every call, including calls that carry a state handle.
8. Local servers run sandboxed, with file and network access granted explicitly.
9. Tools that write, send or delete require approval that shows the real arguments.
10. No session combines private data, untrusted content and an outward channel without a person in the loop.
11. Tool calls are logged centrally with user and run identifiers.
12. Servers and their credentials are reviewed each quarter, and unused ones are removed.

MCP servers are one part of an application's exposure. The rest is in our [LLM application security checklist](https://westack.ai/blog/llm-application-security-checklist).

## How to start

Spend the first week on an inventory. For every machine and every agent, list the connected servers, where each came from, its version and the credential it holds. Most companies find servers nobody remembers adding. Remove those first.

Then make four changes in order of payoff: pin every version, replace any administrator key with a scoped per-user token, sandbox the local servers, and put approval in front of anything that sends or deletes.

The accountancy practice ends up with four servers. The converter is replaced by a pinned, sandboxed one. Web fetch moves to a separate session with no access to client records. Each accountant's token is read-only on the document store, and sending email needs a click. It is less convenient than before, and a hostile PDF can no longer reach the tax files.

Setting this up, including the gateway and the [cloud plumbing](https://westack.ai/services/cloud) behind it, is part of the [AI agent and MCP integration](https://westack.ai/services/ai-agents) work we do at WeStack AI.

## Frequently asked questions

### What is tool poisoning in MCP?

Tool poisoning is when an MCP server's tool description, which the model reads but users rarely see, contains instructions aimed at the model. The description can tell the model to misuse that tool or another server's tools. The defences are reviewing descriptions before approval, storing a hash of the approved definitions, and blocking a server whose definitions change.

### Does MCP require authentication?

No. In the current specification authorisation is optional. When a remote server does protect itself, the spec expects OAuth 2.1 with tokens issued for that specific server, while local servers take credentials from their environment. For any server that touches company data, treat authorisation as mandatory and tie tokens to individual users.

### Is it safe to install MCP servers from a public registry?

Only after review. A listing shows that a package exists, not that it is safe, and a local server runs with your user's permissions. Check who publishes it, read the tool definitions, pin an exact version, run it in a sandbox with no network access unless it needs one, and connect it with the narrowest credentials that work.

### What is a confused deputy in MCP?

A confused deputy is a server that holds real authority and is tricked into using it for the wrong party. In MCP it arises when a server fronts a third-party API with one shared client identity, or forwards tokens it was given. The specification requires per-client consent for such proxies and forbids passing tokens through.
