stacklok / stacklok/toolhive

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

Open
#5,293 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement go proxy security
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the checkCredentialExfiltration test in the enterprise DAST suite and trace the thv run proxy path for tools/call result bodies. Define the configurable or opt-in mitigation and its false-positive behavior, then update coverage so credential-containing results, legitimate examples, and audit behavior match the chosen design.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.