LetterMCP

Real-Time Detection Architecture for Tool Poisoning and Prompt Injection in MCP Pipelines

Three pipeline stages need separate detection to block tool poisoning and prompt injection.

· 9 min read
Cover illustration for “Real-Time Detection Architecture for Tool Poisoning and Prompt Injection in MCP Pipelines”
Agent Security · November 7, 2026 · 9 min read · 1,948 words

Enterprise MCP security needs inspection before tool definitions enter model context, authorization for every tool call, and screening before tool results go back to the model. These controls must share a gateway, human identity, and an audit trail. Static scans and perimeter defenses cannot replace this architecture because a trusted connection can deliver instructions that change what an agent does.

Why MCP pipelines create a detection problem that conventional controls cannot solve

MCP reverses a familiar trust relationship. The model reads tool descriptions as trusted context, but the person who approves the tool rarely sees all of what they contain. A server can therefore supply both a capability and instructions about how the model should use it. Those instructions can go beyond what the tool says it does. Conventional validation assumes software can separate commands from input, but here the model is the decision-maker interpreting both.

The protocol makes that boundary dynamic, too. The 2026-07-28 MCP specification revision moves tool-list change notifications from the HTTP GET endpoint to an opt-in subscriptions/listen stream. Tool definitions can change after initial approval. That creates the opening for a rug pull, in which a server earns trust with a clean definition and replaces it on a later connection. Approval describes what was inspected earlier, which may differ from what the model reads now.

The New York Institute of Technology threat modeling paper found that 5 out of 7 MCP clients it evaluated had no static validation mechanisms for metadata sent by the server. The specification itself does not require client-side validation. Human approval does little to guard against that gap. Clients such as Claude Desktop and Cline show parameters, but people must scroll horizontally to read them, so hidden content is easy to miss.

The three attack vectors and where in the pipeline each one lands

Tool poisoning enters through registration and schema ingestion. Malicious instructions sit in descriptions or parameter metadata, so loading a tool into context can be enough to influence the model even if that tool is never called. Direct poisoning can target file exfiltration, while tool shadowing uses one server’s description to override the behavior of another server’s trusted tool. A sleeper variant delays the change until trust has been established. This entry point requires inspection of definitions alongside execution permissions.

Prompt injection through tool results enters later. Here, the definition may be clean, but a returned file, ticket body, or PR title contains instructions aimed at the agent. Researcher Aonan Guan and a Johns Hopkins University team hijacked Claude Code, Gemini CLI, and GitHub Copilot through malicious instructions in GitHub PR titles. Control of the data was enough. The attacker did not need access to agent infrastructure, which places the inspection boundary between the returned content and the model reading it.

Supply chain and infrastructure compromise enter through provisioning and registries. Sandworm_Mode and Shai-Hulud demonstrate that the MCP registry and npm ecosystem are attack surfaces before any invocation takes place. Such attacks can also cross stages. A rogue server that arrives through a package can later return prompt injection, while compromised infrastructure can expose resources regardless of what the tool content contains. Because these entry points differ, detection at registration, execution, or result ingestion alone leaves the others blind.

Diagram: Three Attack Vectors, Three Pipeline Entry Points. Visualizes: Show where three distinct MCP attack vectors enter the pipeline at different stages, making the case that inspecting only one stage leaves the others blind.

Why static scanning and perimeter controls miss the runtime asymmetry

Code review, dependency scanning, and firewalls remain useful, but they inspect different boundaries. A dependency scan cannot approve a definition that changes after the scan, and a PR title can be valid application data while also containing instructions for an agent. Network identity does not establish whether a particular user authorized a particular tool to access a particular resource. The NSA’s Artificial Intelligence Security Center named insufficient input screening and uncontrolled automated actions as main MCP risks in its 20 May 2026 Cybersecurity Information Sheet. Both risks can arise within a workflow that is otherwise allowed. Some teams answer with LLM input sanitization and output filtering, but downstream filters cannot replace screening before a tool description enters context. By the time an output filter runs, the model has already read the poisoned instructions. More scanning of the original artifact does not close that runtime gap.

The layered detection architecture and what each layer must do

The registration layer catches poisoned metadata before the model reads it. Every fetched definition requires inspection of its name, description, and parameter fields for hidden instructions, plus comparison with a known-good baseline. An allowlist must also block unapproved servers from loading. Change notifications require full re-inspection rather than silent acceptance, and version-aware schema diffing must flag changes for review before the replacement definition becomes trusted. This layer protects context assembly, but it cannot judge malicious content returned by a later call.

The execution layer catches actions that were not authorized and patterns of invocation that look suspicious. Every call must be checked against the requesting user, tool, parameters, and resource rather than inheriting permission from an authenticated session. Session approval is not operation approval. Short-lived, scoped tokens should be issued through a centralized authorization service that evaluates agent identity, task context, and the requested operation in real time. A gateway can enforce those decisions and inject just-in-time credentials without giving the agent the underlying secret.

Abnormal invocation rates, unusual data-access sequences, injection-shaped parameters, and lateral movement across servers can reveal misuse that a permission check on a single call misses. The gateway needs the human’s SSO identity on every call. That makes an alert attributable to the person who authorized the agent session. Even so, a properly authorized call can return hostile instructions, so execution inspection cannot take the place of result screening.

The result layer catches instructions embedded in returned content before that content goes back into model context. Its detection signatures need to spot natural-language commands inside structured data fields, so the layer must do more than rely on models trained on ordinary API traffic. Intent drift monitoring checks the calls and data access that follow against the task that was declared. Exfiltration detection also looks for credential-shaped strings, PII patterns, and large returned payloads passed into outbound parameters. This layer cannot retroactively prevent poisoned registration or an unauthorized call.

Tamper-proof audit logs are a fourth requirement. Full OpenTelemetry tracing must connect the user, client, server, tool, and resource across the inspection layers so that investigators can reconstruct the chain of delegation. Without that link, separate alerts cannot reliably explain a single action by an agent. The Cloud Security Alliance maturity model specifies a minimum 90-day retention for tool invocation logs at Level 1. That baseline gives the architecture a lasting record, so detection can draw on more than what is still visible during a session.

Authentication and authorization requirements that make the architecture enforceable

Detection needs an accountable principal. The November 2025 MCP specification mandates OAuth 2.1 with PKCE, using S256 only, for clients using the authorization code flow on HTTP-based MCP servers. Authorization itself is still optional for HTTP transports, with the specification using the SHOULD requirement level, below MUST. Protocol support therefore does not establish that an enterprise deployment has enforced access control. The enterprise still needs rules for credential type, lifetime, scope, lifecycle, and audit.

Issuer and audience binding close different credential gaps. The 2026-07-28 specification introduced SEP-2468, following RFC 9207, requiring clients to validate a present issuer parameter against the recorded issuer before redeeming an authorization code. That protects a client working with multiple servers and identity providers against issuer confusion. The 2025-06-18 revision requires Resource Indicators under RFC 8707, which bind a token to a specific server. A credential intended for one resource should not become permission to access another.

Those checks must connect to per-operation identity propagation. Without that link, the gateway may record a technically valid request without reliably identifying the human behind it. Broad service accounts do not provide that attribution. Every agent, server, and tool needs treatment as a non-human identity requiring cryptographic proof, continuous authentication, and attribute-based access control that accounts for the agent’s current security posture. Together, these controls let a detection finding identify who acted, under which authority, and against which resource.

What the incident record reveals about which layer enterprises are skipping

The incident record exposes missing boundaries alongside weak classifiers. Postmark-mcp added malicious BCC exfiltration code at v1.0.16 on September 17, 2025, after clean releases had earned adoption. Shai-Hulud in August 2026 likewise delivered its malicious payload after a clean version had been approved and downloaded. Both expose the weakness of one-time approval. They make continuous change monitoring and version-aware re-inspection necessary, though schema inspection alone must not be mistaken for inspection of all server code.

Sandworm_Mode showed a different failure at registration in February 2026. It used npm typosquatting to install rogue MCP servers through packages mimicking popular utilities, then used prompt injection to exfiltrate SSH keys, AWS credentials, and npm tokens. The installed servers were never inventoried. The missing control was centralized allowlist enforcement that prevented unapproved servers from connecting. Result inspection was also needed to check the hostile content those servers sent back.

Asana’s June 2025 exposure belongs at the execution layer. A tenant-isolation flaw let one organization’s users see another organization’s project data, tasks, comments, and files, with roughly a thousand customers estimated to be exposed. This was not prompt injection. Authentication had not been matched by a complete check of the specific user, operation, and tenant resource. By contrast, the PR-title research exposed the result boundary, where external data became an instruction only after the agent read it.

Infrastructure needs its own protection as well. MCP Inspector RCE, CVE-2025-49596, allowed any website to drive the local debugging proxy into running arbitrary commands. It was rated CVSS 9.4 and fixed in version 0.14.1. No classifier for tool descriptions could substitute for securing that proxy. Taken together, these cases show why concentrating investment on LLM prompt shields leaves authorization, server admission, changing artifacts, and tooling infrastructure insufficiently covered.

Diagram: Which Security Layer Each Incident Exposed. Visualizes: Map five real incidents to the specific missing control layer each one revealed, illustrating that enterprise gaps are spread across all layers rather than concentrated in one.

How should enterprises govern MCP access and choose a security platform?

Teams need to share one policy that can be enforced in production. Tool allowlists must be centrally maintained and enforced at the gateway. Execution policy must also take sensitivity labels into account, because access to a server does not grant access to every kind of data behind it. Permissions change while agents are running. The maturity model’s Level 4 requirement handles those changes with policy managed as code and real-time updates that do not end the session.

For an operational response to monitoring, the same model calls for real-time anomaly detection on invocation logs, defined thresholds, and automated alerts for suspicious patterns. Compliance also depends on the record’s detail. For organizations subject to HIPAA, GDPR, SOX, or FedRAMP, missing human attribution at each tool call is a compliance gap. EU AI Act obligations extend the LLM audit boundary to the gateway, where calls, parameter sets, results, and authorization context must be recorded.

An enterprise MCP security and governance platform needs to combine a governed path to agents for technical and nontechnical employees, unified control over servers and calls, and real-time detection of poisoning, injection, and intent drift. Identity must remain tied to actions through SSO, SCIM, and just-in-time credentials. An agent builder, gateway, and separate security tool do not satisfy that requirement merely by being deployed together. The decisive comparison is whether policy, identity, inspection, and audit operate through a single enforcement point.

The lesson for security and IT teams is to make governed access the normal route to adoption. Reviewing every integration manually after deployment leaves governance chasing usage. Embedding these controls in the foundation instead gives employees a sanctioned way to use MCP-connected agents without making every new connection a fresh exception.

Sources

  1. Model Context Protocol Threat Modeling and Analyzing Vulnerabilities to Prompt Injection with Tool Poisoning
  2. Model Context Protocol Threat Modeling and Analyzing Vulnerabilities to Prompt Injection with Tool Poisoning
Filed underAgent Security

More in Agent Security