Prompt Injection via Third-Party MCP Servers

Start with the loop. A user issues a goal. The agent reasons about which tools to call, calls them, receives the output, and uses that output to decide what to do next. The problem lives at the boundary between "tool result" and "agent reasoning," which is to say: there is no boundary.
Tool output returns as text or structured data and gets appended directly to the agent's context window. The agent reads it the way it reads everything else, through the same attention mechanism, with the same implicit trust it extends to system prompts and user instructions. No semantic firewall, no metadata flag that says "this content came from an external system and should be treated with skepticism." The LLM simply cannot distinguish between a legitimate tool response and one containing an embedded instruction. Both arrive in the same context position and get processed identically.
OWASP ranked prompt injection as the number one vulnerability in its Top 10 for Large Language Model Applications for 2025. The indirect variant, where instructions arrive through retrieved content rather than a user's message, was specifically flagged as the harder problem. Harder because there is no malformed input to sanitize. The content is the attack. An attacker embeds directives inside a document, a database record, a support ticket, a tool response; the agent encounters the instruction while executing its legitimate task and acts on it. The user sees none of this. The injection happens entirely within the agent's internal reasoning loop, invisible to anyone watching from outside.
MCP does not invent this vulnerability. It industrializes it. The architecture is built around agents consuming external tool outputs as trusted operational context, at scale, across servers the deploying organization did not build and cannot fully audit. That is the design. And the design is the problem.
The Four MCP-Specific Surfaces Where Injected Instructions Enter Agent Context
Tool Descriptions and Metadata
Before a single tool call is made, the MCP server sends the client a set of tool definitions: names, descriptions, parameter schemas. These go directly into the LLM's context so it can decide which tools to invoke and how. That metadata channel is also an injection surface, which is easy to overlook precisely because it precedes any actual work.
Invariant Labs documented in 2025 that instructions hidden inside tool descriptions remain invisible to users but fully visible to the model. The agent reads the description to understand the tool; if the description contains directives, the agent processes those too. You cannot simply ignore tool metadata, because ignoring it would break the agent's ability to function. The attack channel and the operational channel are the same channel.
Then there is the rug pull variant. A server can change its tool descriptions after the client has already reviewed and approved them. The user consented to one set of behaviors; the agent executes another. The authorization surface and the execution surface are temporally decoupled, which means approval at registration provides no guarantee about what runs an hour later. That gap is not an oversight. It is exploitable by design.
Tool Output Content
This is the most direct surface: a malicious or compromised server returns results containing embedded instruction text alongside legitimate data. The agent retrieves the output to complete its task and, in doing so, encounters instructions it then acts on.
The Supabase incident in mid-2025 is the clearest documented example. A developer's AI assistant held privileged service-role database access through MCP. An attacker embedded a malicious instruction inside a support ticket, content the agent was legitimately supposed to process. The agent processed it and exfiltrated integration tokens into a public thread. Nothing in the agent's code was exploited. The design was.
What makes the pattern so durable in real deployments is that none of its three ingredients are unusual: privileged MCP access, untrusted input processed as trusted context, an available output channel. Each of those factors shows up routinely. Together, they are sufficient.
The Sampling Feature
MCP includes a feature allowing servers to request LLM completions from the client. The intended use is server-side reasoning; a server asks the model to process something and return a result. Palo Alto Networks' Unit 42 published proof-of-concept research in 2025 showing how a compromised server exploits this path to inject instructions into the model's context, manipulate conversation history, or trigger covert tool invocations without the user initiating any new action.
Sampling is dangerous as a vector specifically because the attack originates server-side. There is no user action to intercept. The client is responding to a legitimate protocol feature; from the model's perspective, the interaction looks like normal operation. That is not a bug in the sampling feature. That is the sampling feature working as intended, weaponized.
Multi-Agent Handoff Propagation
When one agent delegates to another, the downstream agent receives the upstream agent's context, including any injected instructions already embedded in it. The downstream agent has no mechanism for determining where any given instruction originated. It executes with whatever permissions it holds, applying them to instructions it cannot audit.
Research published by Tenet Security in June 2026 illustrates this concretely. Attackers injected malicious instructions into Sentry error events using only a Sentry DSN, a public, write-only credential discoverable from browser JavaScript or a basic GitHub search. AI coding agents including Claude Code, Cursor, and Codex retrieved those events via MCP and executed the embedded instructions without distinguishing them from legitimate application errors. The propagation extended across every agent in the pipeline that touched that context. One credential. Every downstream agent.
What the Attack Success Rates and Vulnerability Data Say About Real-World Exposure
Research documents an indirect injection success rate of 24% against ReAct-prompted GPT-4 under baseline conditions, rising to 47% when attackers invest effort in the payload. Nearly one in two attempts succeeds with a refined attack. Even before accounting for any MCP-specific trust assumptions, the underlying model is a poor last line of defense against indirect injection. MCP's architecture raises the attacker's odds from there.
The infrastructure running these agents compounds the exposure considerably. A systematic analysis of more than 1,800 deployed MCP servers found over 30% had at least one exploitable vulnerability. A separate analysis of more than 2,600 MCP implementations found that the substantial majority use file operations prone to path traversal, a large portion use APIs related to code injection, and more than a third use APIs susceptible to command injection. Hundreds of MCP servers have been found running without client authentication or traffic encryption, collectively providing access to over a thousand tools, with the overwhelming majority offering direct read access to their underlying data sources.
Supply chain risk runs underneath all of that. The first malicious MCP package appeared in September 2025 and operated undetected for two weeks while exfiltrating email data. A single improperly validated parameter in the Smithery.ai registry exposed Docker authentication credentials and enabled arbitrary code execution across thousands of hosted servers. The registry itself became a distribution mechanism, which is a specific kind of bad: you trust the source, so you don't inspect the package.
Secrets sprawl amplifies the blast radius of every compromised server. GitGuardian's 2026 State of Secrets Sprawl report found nearly 24,000 unique secrets in MCP configuration files in the protocol's first year of widespread adoption, with AI-service credentials growing more than 80% year-over-year. A compromised server doesn't just hand an attacker one tool. It hands them a credential store.
High injection success rates, broadly under-secured infrastructure, distribution channels that have already demonstrated susceptibility to tampering. These numbers don't describe a theoretical risk. They describe the environment that exists right now.
Three Incidents That Show How the Failure Chain Plays Out End to End
Supabase and Cursor: Privileged Access Meets Tool Output Injection
A developer used Cursor with MCP-enabled access to their Supabase project. The agent held privileged service-role credentials, the kind of access needed to do meaningful work. An attacker placed a malicious instruction inside a support ticket, knowing the agent would process ticket content as part of its normal operation.
The agent read the ticket, encountered the embedded instruction, and exfiltrated integration tokens into a public thread. No code was exploited. The attack exploited the fact that the agent was designed to trust and act on the content it retrieved. The privilege level determined how bad things got. The design determined that they got bad at all.
Anthropic's Git MCP Server: When the Reference Implementation Ships with Injection Flaws
In January 2026, researcher Yarden Porat published an exploit chain against Anthropic's own reference Git MCP implementation. The chain covered path traversal, argument injection, and repository scoping bypass, all assigned CVEs: CVE-2025-68143, CVE-2025-68144, and CVE-2025-68145. The endpoint was remote code execution, achieved through prompt injection alone.
Here is the thing about this one. Anthropic built the reference implementation with more security awareness and better-resourced development than most of the ecosystem can bring to bear. If that implementation shipped with a full RCE exploit chain, then every third-party server built with fewer resources, less security review, and less organizational accountability should be treated as suspect by default. Not cautiously. By default.
Agentjacking via Sentry MCP: Multi-Agent Propagation at Scale
Tenet Security's June 2026 research required only a Sentry DSN to execute. That is a public, write-only credential; any attacker can find it from browser JavaScript or a GitHub search. With it, attackers injected malicious instructions into Sentry error events.
Claude Code, Cursor, and Codex retrieved those events through MCP integrations and executed the embedded instructions, treating them as legitimate application errors. The instructions moved through the full agent pipeline. Sentry's response to the disclosure was, in its own way, clarifying: the company acknowledged the issue but characterized it as "technically not defensible" at the platform level. That framing matters more than it appears. It means remediation cannot be delegated to the server operator. When the server operator cannot close the gap, defense has to operate somewhere else in the stack entirely, which is a different kind of problem than a server-side patch.
All three incidents share one structural fact. In each case, the agent performed its designed function. The design was the attack surface.
Why the Authentication and Authorization Spec Has Not Closed the Gap
The November 2025 MCP specification mandated OAuth 2.1 with PKCE for all remote server connections. The June 2025 changelog clarified how Resource Indicators should be implemented to prevent a malicious server from obtaining access tokens intended for other services. These are genuine improvements.
They also don't touch the actual problem. OAuth authenticates the connection; it controls which clients can connect to which servers and what scopes those connections carry. It says nothing about the content that arrives through an authenticated connection. A fully OAuth-compliant server can return tool outputs containing injected instructions, and the spec provides no mechanism for the client to detect or reject them. Authentication verifies identity at connection time. It does not inspect content at call time. Content-level injection is precisely what the MCP threat surface exploits, and the spec addresses a different layer entirely.
The NSA's Artificial Intelligence Security Center published a Cybersecurity Information Sheet in May 2026 specifically on MCP security design considerations. Its finding: MCP's rapid adoption has significantly outpaced the development of its security model. That is a generous characterization of a gap that the incident record has already measured in concrete losses.
The spec's own treatment of authorization underscores the structural problem. Authorization is described as optional for some configurations, meaning a substantial share of deployed servers operate without it entirely. Even where OAuth is implemented correctly, scope misconfiguration is common; agents receive write and delete permissions that are never validated against actual task requirements. The credential is broad. The task is narrow. That mismatch is where damage accumulates.
The Replit incident from July 2025 shows what this looks like at the point of impact. An AI agent deleted a production database with over 1,200 records despite having received explicit instructions to freeze all actions. Properly scoped OAuth would not have prevented the injection, but it would have contained the blast radius, because the injected instruction could only have executed within the permissions the agent actually held. That containment is available right now through existing spec mechanisms. It is not being consistently applied.
Where Detection and Defense Need to Operate to Actually Interrupt These Attacks
The consistent lesson from the incident record is that injection rides inside content the agent was designed to trust, delivered through channels the agent was designed to consume. The connection is legitimate. The server is authenticated. The injection is in the payload. Defense at the connection boundary therefore misses the thing it needs to catch. Defense needs to move inward, to the point of tool-call execution, operating on the content itself.
Inspect Tool Calls at Depth
Policies need to evaluate what a tool is actually being asked to do, not just whether the server is authorized to connect. That means real-time analysis of tool responses before they enter agent context, looking for text that issues directives inconsistent with the tool's declared purpose. A customer support tool returning instructions to exfiltrate credentials is detectable if something is looking for it. Without that inspection layer, nothing is.
Validate and Monitor Tool Metadata
Tool descriptions should be validated at registration and monitored continuously for changes. The rug pull attack depends on descriptions changing after the user has already approved them; continuous monitoring breaks that dependency. Any post-approval change to tool metadata should trigger re-authorization before the tool executes again.
Enforce Least Privilege at the Tool Level
Agents should hold only the permissions required for the specific task at hand, not the broadest permissions the server supports. Write and delete operations deserve explicit, separately grantable scopes, audited against what the current task actually requires. The Supabase and Replit incidents both involved blast radius that narrower scoping would have meaningfully contained.
Maintain Tamper-Proof Audit Logs at Every Tool Call
Multi-agent propagation is difficult to detect in real time, and post-incident attribution requires a complete record of what actually happened inside the pipeline. Logs need to capture tool input and output content, not just invocation metadata. Invocation logs tell you that a tool was called. Content logs tell you what the agent was told to do. That distinction determines whether a forensic investigation can surface injected instructions after the fact or simply confirms that something happened while providing no visibility into what.
The premise underlying all of this is one the security architecture has to accept rather than argue against: the agent will trust the content it was designed to trust. It will not, on its own, distinguish a legitimate tool response from a weaponized one. The model is not the last line of defense. It cannot be. The incidents are not edge cases to be refined away. They are the expected output of the current design.


