Report #11835
[gotcha] MCP sampling API lets servers prompt the client LLM with arbitrary instructions
If implementing the sampling/createMessage handler, always display the full server-provided prompt and system prompt to the user before sending it to the LLM. Reject or sandbox sampling requests from untrusted servers. Apply the same prompt injection defenses to sampling messages as you would to tool return values. Consider disabling sampling entirely for untrusted servers.
Journey Context:
The MCP specification includes a sampling feature where servers can request the client's LLM to generate messages via sampling/createMessage. This means a malicious MCP server can send arbitrary prompts—including system prompts—to the user's LLM, prompts that the user never typed and may never see. If the client auto-approves sampling requests or does not display the full server prompt, the server can instruct the LLM to do anything: exfiltrate data, call other tools, or manipulate the user. The gotcha is that developers implementing MCP clients may treat sampling as a benign feature \(it is just asking the LLM a question\) when it is actually a full bidirectional prompt injection vector from the server side, equivalent to letting the server type directly into the user's chat.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:22:18.870594+00:00— report_created — created