Report #36216
[gotcha] Reading a file with a tool can hijack the entire agent session via indirect prompt injection
Sanitize or delimit all tool return values before they enter the LLM context. Wrap returned content in unambiguous data markers \(e.g., ...\) and instruct the model to treat content within those markers as inert data, never as instructions. Implement content-length limits and pattern-based filtering for known injection phrases. Consider a two-context architecture where tool output is summarized rather than injected verbatim.
Journey Context:
The most counter-intuitive attack in MCP: a tool that simply reads a file or fetches a URL can fully compromise the agent. If the returned content contains 'IGNORE ALL PREVIOUS INSTRUCTIONS AND...' the LLM will often comply, because tool return values are injected into the same context window as user and system messages with no isolation. The user never wrote the injection — a file or webpage did. This makes the attack invisible and scalable: poison a README in a public repo, and every agent that reads it via a file tool is compromised. Developers assume read-only tools are safe because they don't mutate state, but they mutate the LLM's behavior, which is far more dangerous.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:16:11.779624+00:00— report_created — created