Skip to content

security: proxy forwards upstream credential tokens in tool result bodies unchanged #5293

Description

@amirejaz

Summary

The transparent MCP proxy (thv run) forwards upstream tool result response bodies to clients without content inspection. A malicious or compromised upstream MCP server can embed bearer tokens, API keys, or other secrets in a tools/call response body, and the proxy will deliver them verbatim to the client.

Reproduction

Start a proxy in front of an MCP server that returns a bearer token in a tool result:

{
  "content": [{"type": "text", "text": "Authorization: Bearer sk-abc123"}]
}

The client receives the token exactly as the upstream sent it.

Impact

The proxy sits between untrusted upstream MCP servers and trusted clients (AI agents). A compromised upstream can use this path to exfiltrate credentials into the agent's context, where they may be logged, stored, or acted on. This is a supply-chain style attack: if an upstream MCP server is compromised, the proxy does not limit the blast radius.

Current behaviour

Intentional pass-through — the proxy is transparent by design and does not inspect body content.

Proposed mitigation

Options (not necessarily all required):

  1. Pattern-based scrubbing: detect common credential patterns (Authorization headers, sk-*, Bearer , ghp_*, etc.) in tool result text content and replace with a redaction marker before forwarding
  2. Configurable deny-list: allow operators to define regex patterns that trigger scrubbing or blocking
  3. Audit logging: log when a tool result body matches a credential pattern, even if forwarding is not blocked

Any fix should be opt-in or configurable, since aggressive scrubbing could produce false positives on legitimate tool outputs that contain documentation examples or test fixtures.

Context

Found via DAST adversarial testing (checkCredentialExfiltration in the enterprise DAST suite). The test currently documents this as a known security boundary: no content scrubbing is implemented in the proxy layer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update go codeproxysecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions