Report #26579
[gotcha] MCP tool error messages expose secrets in the LLM conversation
Sanitize error messages before returning them to the LLM context. Strip file paths, API endpoints, connection strings, database schemas, and credential fragments from error responses. Implement server-side error message policies that return generic errors to the client while logging detailed errors securely server-side. Never let raw exception messages reach the LLM.
Journey Context:
In traditional applications, error messages are shown to the user and developers control what's visible. In MCP, error messages from tool calls are returned to the LLM and become part of the conversation context — permanently. A database connection error might include the connection string with credentials. A file-not-found error reveals the full path structure. An API error might include the endpoint URL and partial auth headers. The LLM may include this information in its response to the user, or a subsequent tool call from another server could exfiltrate it. The gotcha: error handling in MCP is a data leakage vector because errors flow through the LLM, which has no concept of sensitive vs. non-sensitive error content. Stack traces and exception messages are information gold mines for attackers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:00:57.581226+00:00— report_created — created