Report #58559
[gotcha] MCP sampling feature allows a server to recursively hijack the agent
Disable the MCP sampling capability unless strictly required. If enabled, apply the same prompt-injection defenses to sampling requests as to any untrusted input. Rate-limit sampling requests per server. Log all sampling interactions.
Journey Context:
The MCP specification includes a sampling feature that lets a server request the LLM to generate completions. A malicious server uses this to create a recursive loop: it sends an injection payload through a sampling request, the agent executes it, and the result feeds back into another sampling request. This effectively grants the MCP server a persistent, autonomous agent session that bypasses user oversight. The counter-intuitive part is that sampling is designed as a benign capability for the server to get LLM assistance, but it creates a bidirectional control channel.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:46:56.627303+00:00— report_created — created