Prompt Injection Through MCP Tool Responses

Tool responses carry attacker instructions straight into an agent's context.

Prompt injection through MCP tool responses takes advantage of a missing boundary as well as a badly worded prompt. The protocol does not enforce a separation between returned data and instructions inside the model’s context window. Every tool response can thus give an attacker a way in. To defend an MCP-connected agent, controls must limit what returned content can make it do as well as check whether that content looks suspicious.

Why MCP tool responses are a structurally different injection surface from earlier prompt injection

Tool descriptions get reviewed when a server connects. Tool responses come later, while the agent is at work, without the same check. That is the central trust gap. Approval of an interface becomes trust in content that has not yet arrived, including content the server may retrieve from sources an attacker can edit. A clean description says little about what a tool will return on its next call.

In a conventional web application, documentation describes an interface. With MCP, both tool metadata and returned content enter the model’s working context, where they can influence its next action. Checkmarx’s MCP security guide describes this as a chain of delegation collapsing into a single unguarded channel. The text does not execute like program code. Instead, it can direct the model that selects tools and supplies their arguments.

Earlier prompt injection also used outside content to redirect models. MCP gives that content a regular route into an agent that can act across connected systems. Traditional input validation depends on a clear distinction between instructions and data, but plain text in an MCP response can serve either role. The new exposure is therefore not the existence of hostile text. It is the routine delivery of that text through an interface the agent relies on to get work done.

How the LLM context window turns every tool response into a potential instruction

LLMs process context-window text through the same attention mechanism, so returned text has no intrinsic, enforced separation from instructions. MCP exposes three kinds of content, namely tools that the model can call, resources it can read, and prompts supplied by servers. All three ultimately resolve to text added to the context window. An attacker who controls returned content can place a directive where the model will read it.

The attacker need not control the MCP server itself. A Jira ticket, Slack message, database row, or scraped webpage can supply the poisoned text when a legitimate tool retrieves it. The model may then treat part of that retrieved material as an instruction about its next step. This is indirect prompt injection. The user asked the agent to work with the content.

Tool chaining extends the reach of that first mistake. When output from Tool A becomes input for Tool B, a poisoned source can redirect later steps without further attacker action. The consequences extend beyond a wrong answer because the model also chooses tools and generates arguments.

System prompts and instruction hierarchies are an obvious objection. Those rules are supposed to have precedence over the content the model retrieves. But precedence is a convention the model follows probabilistically. A crafted response can redirect behavior despite those rules. A stronger warning in the system prompt cannot substitute for an access control.

The attack surface expands beyond tool responses, including tool descriptions, rug pulls, tool shadowing, and sampling

Tool poisoning targets the earlier, connect-time decision. An attacker places instructions in a tool’s name, description, or parameter schema, which the model reads when deciding what to call and how. Users may never see the full description because clients typically do not display it. The tool can therefore look ordinary in the interface while supplying hostile instructions to the agent.

A rug pull waits until after approval. The server first presents a benign description, then changes it on a later connection. Most MCP clients do not re-alert users when definitions change, so the original approval can outlive the content it covered. The MCP specification has included tools/list_changed notifications since its initial November 2024 revision. Detection support exists, but enforcement remains client-side and inconsistent.

Tool shadowing crosses from one server into another. A malicious description can shape how the agent uses legitimate tools because the servers that connect share a context window. The malicious tool need not be invoked. For example, its description can direct a legitimate email tool to CC an attacker address, turning access granted to one server into leverage over another.

Sampling opens a different door, initiated by the server. MCP’s sampling feature lets servers ask the host LLM to do work without waiting for a user to ask. That content bypasses user-side input filtering and receives higher implicit trust in many implementations. Across these techniques, the potential reach is the combined scope of connected servers. Credentials, files, APIs, and downstream systems can become reachable through permissions the user granted for unrelated work.

Documented incidents that show how injection through tool responses plays out in production

Invariant Labs demonstrated injection through tool responses via the GitHub MCP server in May 2025. Researchers put an injection in a GitHub Issue that an agent found while checking open issues. The agent followed the embedded instructions and exfiltrated content from private repositories the user had authorized. The server’s tool descriptions were clean. The hostile instructions came only from the issue content that the tool returned.

Aim Security disclosed EchoLeak, CVE-2025-32711, in June 2025. The zero-click indirect prompt injection flaw in Microsoft 365 Copilot allowed a crafted email to trigger exfiltration of internal data without user interaction. Content from outside reached the agent’s context through a tool response. Although this case concerned Copilot rather than a malicious MCP package, it exposed the same trust crossing.

The postmark-mcp supply-chain attack followed in September 2025. An npm package mirrored a legitimate email MCP tool for fifteen clean releases before a later update began sending a hidden copy of every sent email to an attacker. Koi Security described it as the first real-world malicious MCP server. This case exposed the limits of trust earned over time.

Pillar Security found the Deadbugz campaign in August 2026. A malicious MCP server called “productivity-suite” spread through public GitHub pull requests and behaved ordinarily for three tool calls. It then changed its instructions to direct the agent to locate SSH keys, AWS credentials, shell history, and Kubernetes configuration. The instructions also told it to conceal the activity from the user.

Some used retrieved content, while others changed metadata or tool behavior after trust had been established. The GitHub demonstration makes the runtime lesson especially clear because no poisoned description was needed. Connect-time review cannot cover instructions that arrive only when work is underway.

Why authentication and credential gaps make injection consequences worse

A successful injection reaches only as far as the agent’s access allows, but that access can be broad and long-lived. Static API keys, personal access tokens, and over-broad OAuth scopes give a redirected agent room to act. The credential becomes the multiplier. Private repositories, internal APIs, and downstream systems may all fall within permissions originally granted for legitimate tasks.

MCP launched in November 2024 without an authentication framework, and the 2026-07-28 specification update tightened alignment with OAuth 2.1 and OpenID Connect, including resource metadata and resource indicators intended to prevent cross-server token misuse, but specification requirements do not themselves enforce deployment behavior. Authentication alone also leaves a delegation problem. The security guide identifies the full chain as user identity, MCP client, MCP server, token scope, resource, and tool action. Blurring those boundaries lets retrieved content trigger calls the user never explicitly authorized.

Cycode disclosed an MCP Python SDK OAuth flaw in September 2026 with a CVSS score of 7.5. A malicious server could hijack login discovery and redirect the client secret, authorization code, and PKCE proof key to an attacker-controlled token endpoint. Using OAuth was not enough in that case. Beyond the discovery flaw, verifiable workload identity remains an open gap because the protocol cannot currently prove which agent or runtime holds a token.

That distinction is important for injection defense. Detecting a malicious instruction addresses the attempt to redirect the model, while scoped credentials limit what a redirected model can reach. Neither control replaces the other. If detection misses an attack, the agent’s permissions become the remaining limit on its consequences.

What the absence of agent-specific governance frameworks means for enterprise exposure

NIST acknowledged in its January 2026 request for information that its existing guidance does not comprehensively address security risks specific to autonomous, action-taking AI systems. The gap is documented, not speculative. Its AI Agent Standards Initiative, announced February 17, 2026, will take years and offers no controls that can be enforced right away. The planned outputs are voluntary, so the initiative’s existence does not establish an enforced boundary for deployed agents.

The AIUC-1 Q2 2026 refresh shows that standards work is responding to the problem. It separated agent identity governance and access management into supplemental controls A003.3 and A003.4 within the same requirement. It also required third-party access monitoring and made tool authorization and input/output validation apply to MCP server calls. These changes target real gaps in the agentic supply chain. They do not mean that every deployment now applies those controls.

Four reference frameworks apply to most enterprise AI agent programs, including the NIST AI Risk Management Framework, ISO/IEC 42001, the EU AI Act, and the OWASP Top 10 for LLM and agentic applications. None was designed for the speed and autonomy of multi-step MCP-connected agents. That mismatch leaves organizations interpreting broader requirements for systems that can read documents, send messages, invoke APIs, and spawn subagents within one workflow. Responsibility remains with the organization deploying the agent.

Audit adds another practical difficulty to that responsibility. These workflows generate events at rates that can overwhelm traditional SIEM tooling. NIST’s guidance calls for records of the actions an agent took, the context it received, the permissions it held, and human approval events. Without that chain, a record of actions cannot fully show how work the user allowed turned into behavior they had not allowed.

Why defensive measures must operate at the architectural level, not the input-filtering level

Input filtering and prompt hardening can check for hostile instructions or discourage the model from following them, but they cannot reliably keep data and commands apart. If a defense only checks for suspicious wording, the model still decides what to follow. Architecture must constrain what returned content can change and what actions can follow.

A scratchpad or context-layer design separates agent reasoning state from raw tool-response content. The purpose is to stop instructions inside a response from directly overwriting the agent’s instruction set. Runtime inspection then complements it by examining every tool response for poisoning, intent drift, and exfiltration patterns as the workflow proceeds.

Identity controls must reach every tool call as well. SSO, SCIM, and just-in-time credentials scoped per session reduce reliance on broad, long-lived access. Least privilege at tool-call depth limits the damage when an injection succeeds. Policy enforcement at the protocol layer can then govern which agents may invoke which tools under which conditions, rather than leaving those decisions to the same reasoning process that reads the untrusted response.

Tamper-proof audit and full OpenTelemetry tracing provide the record needed to detect and attribute failures. Traces tied to agent identity at every tool call must include the context the agent received, the permissions it held, and approval events. This makes the delegation chain visible when behavior departs from the user’s request. Enforcement within the normal tool path also reduces the security-versus-usability tradeoff that drives shadow MCP usage.

A tool response supplies evidence within the scope of the task the user authorized. The defensible boundary is the one that still holds when the model gets that distinction wrong.