Faultgate 0.5.0, Faultgate-Zero 0.2, Trace-to-Fixture 0.1 and Fault-Contract 0.1 are on PyPISee products →
Guides

MCP Security: Threats, CVEs and the Controls That Hold

MCP security risks sit in three layers: the protocol, the tools and the agent. Real CVEs, disclosed exploits and the controls for each layer.

MCP Security: Threats, CVEs and the Controls That Hold

MCP security is the work of keeping an agent's Model Context Protocol servers, and the tools they expose, from being turned against the user. MCP is an open protocol that lets a model call tools served by another process, often one written by someone else. Three layers fail in different ways: the protocol plumbing, the tool descriptions and the agent's own design. The controls differ for each.

In May 2025, Invariant Labs showed a proof of concept against the official GitHub MCP server. An agent running in Claude Desktop read a malicious issue in a public demo repository, pulled data from private repositories into context, and exposed it in an autonomously created pull request on the public repo (Invariant Labs). No server code was broken.

01 / MCP risk sits in three layers, and each needs its own fix

A protocol bug is a software defect. A poisoned tool is hostile content that every component handles correctly. An agent leak is an architectural property of how the agent was assembled. One fix does not reach the other two.

The confusion starts because all three produce the same headline: an agent did something the user did not intend. Simon Willison points out that MCP encourages users to mix and match tools from different sources that can do different things (Willison). That mixing is the feature. It also means the trust boundary is rarely one vendor.

His lethal trifecta names the combination that turns a normal agent into a data leak: access to private data, exposure to untrusted content and a way to communicate externally. Willison's warning is direct. An agent with all three can be tricked into reading private data and sending it to an attacker (Willison).

Keep the layers separate in your head and in your review. The next three sections take one each.

The protocol layer is plumbing, and it fails like software. The MCP specification now devotes a page to security best practices with explicit MUST rules, which tells you the failure modes are known.

Start with tokens. An MCP server must not accept any token that was not explicitly issued for it (MCP specification). Token passthrough breaks that rule. The security page names the confused deputy: an attacker who steals an authorization code exchanges it for access tokens without the user's approval, then reaches the third-party API as that user (MCP specification).

Local servers are the other half. A compromised local server can execute arbitrary commands with the client's privileges (MCP specification). That is why one-click setup has a rule. A client that supports it must implement consent before executing commands, and the dialog must show the exact command without truncation, arguments included (MCP specification). The same page recommends platform sandboxing such as containers or application sandboxes (MCP specification).

Authorization URLs deserve their own line. Clients must validate them and reject dangerous schemes, because command injection through shell execution gives an attacker code execution with user privileges (MCP specification).

Two 2025 CVEs show how URL handling and missing authentication fail in practice. CVE-2025-6514 exposed mcp-remote to OS command injection when connecting to untrusted MCP servers, through crafted input from the authorization_endpoint response URL. It was published on 9 July 2025 and rated 9.6 (CVE-2025-6514). CVE-2025-49596 hit MCP Inspector. Versions below 0.14.1 had no authentication between the Inspector client and proxy, so unauthenticated requests could launch MCP commands over stdio. It was published on 13 June 2025 and rated 9.4 (CVE-2025-49596).

The controls here are ordinary hygiene applied to a new boundary:

  • Patch clients and servers, and know which versions you run.
  • Accept only http and https authorization URLs, and never pass them to a shell.
  • Show the full launch command before consent, with no truncation.
  • Sandbox local servers and give them the least access the task needs.
  • Issue tokens per server, and reject tokens minted for another audience.

None of this requires a new security product. It requires treating MCP clients as privileged software, because they are.

03 / The tool layer: descriptions the model reads and the user does not

A tool description is a prompt written by whoever operates the server. Tool poisoning is the attack that hides instructions inside it, invisible to users but visible to the model (Invariant Labs).

Approval does not freeze the text. Invariant names the rug pull: a malicious server changes a tool description after the client has approved it (Invariant Labs). Add shadowing and the change can hide from the interaction log. The malicious server's tool description changes how the agent uses a separate, trusted tool, so the log shows only the trusted tool doing the attacker's work (Invariant Labs).

The MCP specification already tells clients to treat tool annotations as untrusted unless they come from trusted servers (MCP specification). A description is not a security boundary. It is content from a third party.

The scale is measured. MCPTox built its benchmark on 45 live, real-world MCP servers and 353 authentic tools (MCPTox). It generated 1,348 malicious test cases covering 10 risk categories (MCPTox). Across 20 agent setups, o1-mini reached an attack success rate of 72.8% (MCPTox).

The counterintuitive finding matters more than the peak. The paper reports that more capable models are often more susceptible, because the attack exploits their superior instruction-following (MCPTox). A better model is a better follower of the poisoned instruction.

Pinning is the cheapest control that works. Capture the full tool list for each server, hash it, and compare before the session starts. Block on any change until a human reviews the diff. That catches a rug pull and a silent schema edit. It does not catch a tool that was poisoned before the first capture, so pin from a server you trust or read the source first.

The rest is review discipline:

  • Read tool descriptions the way you read code, especially from servers you did not write.
  • Allowlist servers per project, and drop the ones nobody uses.
  • Prefer local, auditable servers for anything that touches private data.
  • Keep secrets out of the agent's context, so a poisoned tool has less to steal.

04 / The agent layer: GitHub MCP showed a server patch cannot fix it

The GitHub MCP exploit is the clearest example of a failure that lives above the server. In Invariant Labs' demonstration, a malicious issue placed in a public demo repository coerced the agent into pulling private repository data into context and leaking it through an autonomously created pull request in the public repository (Invariant Labs).

Invariant is explicit that this is an architectural issue at the agent system level, not a defect in the GitHub MCP server code, and that GitHub alone cannot resolve it with server-side patches (Invariant Labs). The server did its job. The agent combined three capabilities in one loop.

That is the lethal trifecta in production. Private data, untrusted input and an outbound channel sat in the same agent, so a public issue became an exfiltration path (Willison).

You break it by removing one leg for each agent. A warning banner removes nothing:

  • Split readers from writers. Let a read-only agent summarize untrusted content, and keep outbound tools in a separate agent with no private data.
  • Restrict egress. An allowlist on outbound tools limits where a leak can go, even when the model is fooled.
  • Scope credentials to the task. A token that cannot read private repos cannot leak them.
  • Require approval on outbound calls, and show the full arguments in the dialog. The specification says a human should be able to deny tool invocations (MCP specification). A dialog that hides arguments gives that human nothing to judge.

Test these paths before an attacker does. The method is in red-teaming AI agents and the CI version is in prompt injection testing in CI.

05 / Controls that hold, and what they cost

Deterministic checks at the tool-call boundary are the control with the strongest number behind them. FAULTLINE's Publication 02 ran 300 MCPTox instances across six models through one gateway. The provenance contract produced a statistically significant paired mean score reduction (FAULTLINE research), cutting pooled valid attack success from 30.32% to 7.41% (FAULTLINE research).

The contract enforces four things at the boundary: envelope formatting, tool enumeration allowlists, strict schema argument boundaries, and verbatim substring grounding against the user's turns (FAULTLINE research). It checks the shape and provenance of a call. It never guesses intent.

The accounting is unusually honest. The contract removed 421 attack successes while inducing only 26 (FAULTLINE research). A replay over 10,227 traces found that substring grounding false-blocks 24.5% of legitimate actions when tasks require ungrounded world knowledge (FAULTLINE research). One model already resisted, with a 3.01% valid attack success baseline, and saw little gain (FAULTLINE research).

BAR CHART

MCPTox valid attack success, pooled across six models

Unit: %
0%8.3%16.7%25%33.4%30.32%No contract7.41%Provenance contract
Source: FAULTLINE Publication 02, 300 MCPTox instances, one gateway
View accessible data table
SetupASR
No contract30.32 %
Provenance contract7.41 %

FAULTLINE's P09 runtime policy shows the same pattern on structural attacks. Across 400 live runs, it held a 0.0% attack success invariant on all four structural attack categories by intercepting calls at the execution boundary (P09 README). The README also states the limit: the policy does not perform semantic payload filtering or LLM-based output moderation (P09 README). Structure it can enforce. Meaning it cannot see.

For local stdio servers, mcp-guard packages part of this as a free, open-source integrity monitor (mcp-guard). It flags a tool whose schema or description changed after first run, the rug-pull case, and in enforce mode it blocks arguments not defined in the tool's input schema (mcp-guard).

BASH
pip install mcp-integrity
mcp-integrity init

The init command finds client configs and wraps stdio MCP servers in audit mode (mcp-guard). Three limits belong next to the install line. It does not inspect tool results (mcp-guard). Its heuristic scanner can miss poisoned tools and can quarantine clean ones in enforce mode (mcp-guard). And it is only one layer of the three.

A control reported without its cost number is only a claim. Report the false-block rate next to the attack-success rate, or you will trade one failure for another.

06 / A checklist before you add an MCP server

Each layer gets one gate before a server reaches production.

LayerExample riskGate before productionSource
ProtocolToken passthrough, authorization URL injectionPatched client, http(s) only URLs, no shell, sandboxMCP spec
ToolPoisoned or changed descriptionPin the tool list, review every diff, allowlist the serverInvariant
AgentTrifecta leak through an outbound toolRemove a leg per agent, restrict egress, approve with full argumentsWillison
BoundaryUnknown tool, undeclared argumentDeterministic check in front of calls, measure false blocksFAULTLINE research

Two CVEs in one year is enough evidence that the protocol gate is not optional. MCPTox is enough evidence that the tool gate is not optional. The GitHub exploit is enough evidence that per-server review cannot cover the agent layer.

07 / What to change on Monday

Make one decision and name one owner. The decision: no MCP server reaches production without the three gates above. The owner: the security lead, paired with the engineering owner of each agent. Security cannot gate what it does not inventory.

Start with the inventory. List every MCP server and client version in use. Patch the clients, then pin every tool definition and alert on changes. Put a deterministic boundary check in front of tools that can send data out. Break the trifecta per agent, even if that means two agents where one used to sit.

Track two numbers. The first is coverage: share of servers inventoried, pinned and on patched versions. The second is the last red-team run's attack success rate, reported next to the false-block rate of the control you added. A low attack rate with an unreported false-block cost is how a security program loses the trust of the engineers who have to use it.

The tools are free and open source. mcp-guard is open source, and the research behind the contract is published with its numbers and its limits. What costs money is the audit, and you only need that when you want an outside read on the agent itself.

Questions#

Is MCP secure?

MCP is safe only when its clients, servers and agent design are configured for it. The specification publishes MUST rules for tokens, consent and URL validation. Two critical MCP tooling CVEs landed in 2025. Tool descriptions remain untrusted input from whoever runs the server, and the agent still needs its own controls.

What is MCP tool poisoning?

Tool poisoning is an attack where instructions are hidden in an MCP tool's description, invisible to the user but read by the model. The server operator controls that text, and can change it after approval in a rug pull. MCPTox measured up to 72.8% attack success across 20 agent setups, and found more capable models were often more susceptible.

What are the known MCP vulnerabilities (CVEs)?

Two 2025 CVEs are the clearest critical examples. CVE-2025-6514, published 9 July 2025 and rated 9.6, let a malicious MCP server inject OS commands into mcp-remote through its authorization_endpoint URL. CVE-2025-49596, published 13 June 2025 and rated 9.4, gave unauthenticated requests remote code execution in MCP Inspector before 0.14.1.

How do you secure an MCP server?

Patch the client and server, validate authorization URLs, run local servers sandboxed, and show the exact launch command before consent. On the tool side, pin every tool definition and alert on changes, and treat descriptions as untrusted text. For the agent, remove one leg of the lethal trifecta and put a deterministic check in front of outbound tool calls. Report the false-block rate next to any attack-success number.