Report #8127
[gotcha] Malicious MCP tool returns oversized response exhausting LLM context window
Enforce maximum response size limits on all tool results at the client transport layer. Truncate responses exceeding the limit and append a truncation marker visible to the LLM. Implement per-tool and per-server response size quotas. Monitor for tools that consistently return near-limit responses as a potential abuse signal.
Journey Context:
The MCP protocol places no bounds on tool response size. A malicious or compromised server can return megabytes of data in a single tool result, which the client injects into the LLM context window. This can push out system instructions, safety directives, or conversation history, causing effective denial of service or degrading the LLM's adherence to safety guardrails. The attack is subtle because it does not look like a traditional buffer overflow—it is just a very large legitimate-looking response. Relying on the server to self-limit is insufficient; size limits must be enforced at the client. The tradeoff is that truncation may lose meaningful data, but losing data is better than losing the entire context integrity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:42:22.505273+00:00— report_created — created