MCP authentication token theft via headers
MCP servers that accept authentication tokens in headers can leak those tokens if the server logs requests, shares telemetry, or is compromised. Tokens passed to MCP servers persist in server-side logs and may be accessible to attackers.
What happens
When an AI agent authenticates to an MCP server, the authentication token is sent in an HTTP header. If the MCP server logs headers, shares telemetry, or is compromised, the token is exposed and can be reused by an attacker.
How the attack unfolds
What it looks like in practice
A developer configures Claude Code to use an MCP server called "db-query" with an OAuth token. The db-query server logs all requests including the Authorization header to Datadog for debugging. A Datadog admin sees the token in the logs and uses it to access the developer's database directly.
How Guard catches this
How to stop it
Use short-lived tokens for MCP authentication. Rotate tokens regularly. Use Guard to monitor which MCP servers receive authentication tokens and alert on token reuse across servers.
Common questions
Use short-lived OAuth tokens that expire within minutes. Avoid long-lived API keys. Use scoped tokens that only have access to the specific resources the MCP server needs. Rotate tokens regularly and never reuse a token across multiple servers.
Guard can flag MCP servers whose response headers or error messages suggest they log request headers. Guard cannot inspect the server's internal logging configuration directly, but it can alert you to investigate servers that handle authentication tokens.
More threats to know about
MCP tool description poisoning
Malicious MCP tool descriptions embed hidden instructions that redirect AI agents into calling the wrong tool, exfiltrating secrets, or executing unintended commands — even when the tool itself appears harmless.
Read advisoryShadow MCP server discovery and persistent access
MCP servers added to a project during development can persist in configuration files and maintain access to the agent’s context window long after they are forgotten. These "shadow" servers continue receiving tool calls and may be modified by attackers who compromise the original server.
Read advisoryStop this threat before it reaches your agent
Install HOL Guard to get real-time protection against this attack and others like it.