Skip to content

fix(tools): agent tool relay forwards every header except hop-by-hop and its own credentials - #49535

Merged
Jinwoo-H merged 2 commits into
mainfrom
fix/tool-relay-header-denylist
Nov 26, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
fix/tool-relay-header-denylist

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When an agent calls an MCP tool through Orca's agent tool relay, the relay adds the tool's saved credentials and sends the call on. Until now it passed along only a short, fixed list of headers. Whenever MCP added a new header, the relay dropped it until someone updated the list, and strict servers rejected those calls. Now it passes every header except the few that must not cross: connection-level ones, ones fetch sets itself, and the agent's own relay token.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​54 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24

What Changed

  • Requests (sendUpstream): every agent header is forwarded, except:

    • hop-by-hop headers (connection, keep-alive, te, trailer, transfer-encoding, upgrade, proxy-*, and any header named in Connection);
    • host, content-length, expect, accept-encoding, which fetch sets itself;
    • authorization and cookie, the agent's credentials for the relay.

    Saved headers are still applied last, and now win regardless of case. Before, an agent X-Api-Key next to a saved x-api-key would have been joined by fetch.

  • Responses (streamUpstreamResponse): every upstream header is forwarded, except hop-by-hop headers, content-length, content-encoding (fetch already decoded the body) and www-authenticate. That last one is still withheld on purpose, along with the existing 401 to 403 rewrite, so the agent's CLI never starts a sign-in against the relay.

  • This replaces FORWARDED_REQUEST_HEADERS, FORWARDED_RESPONSE_HEADERS and the mcp-param- prefix special case.

Why

#48477 already fixed the headers reported in #48475 (Mcp-Method, Mcp-Name, Mcp-Param-*) by adding them to the list. This PR stops the next missing header: the spec keeps adding headers (for example MCP Events reuse Mcp-Name), and so do servers. Webhook intake already moved from a header allowlist to a denylist for the same reason. Generic HTTP proxies work the same way: they forward everything except hop-by-hop headers (RFC 9110 §7.6.1).

Linked Issue

Follow-up to #48475 (already closed by #48477).

Visual Proof

N/A: no UI change. This only changes which HTTP headers the local relay passes through.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

The relay forwarding test now sends an arbitrary x-custom request header and gets an arbitrary x-upstream-custom response header, and both pass through. The upstream's www-authenticate stays withheld, and the agent's relay token and cookie never reach upstream. The agent also sends X-Api-Key: agent-value, and upstream sees only the saved value. This is a security boundary: the relay token must never leak, and saved credentials must not be overridden. With the old allowlist restored, the test fails (expected undefined to be 'u1'). All 12 tests pass; pnpm tc:node is clean.

Performance

None, because it is one pass over the request's and the response's headers per tool call, the same order of work as before.

Risk

Level: Low

Upstream servers now see agent headers they did not see before, such as user-agent. This is a strict superset of what was sent before, the relay runs only on the host, and the agent's relay credentials are still dropped. A server that rejected unknown headers would now refuse calls, but that is not how MCP servers behave. Back out with a plain revert.

AI Disclosure

Review

…and its own credentials

The relay kept a fixed list of request and response headers, so each new
MCP header (Mcp-Method, Mcp-Name, Mcp-Param-*) was dropped until someone
added it. Forward everything instead, except hop-by-hop headers, the ones
fetch sets itself, and the agent's relay token and cookie. Saved headers
still win, now regardless of case. Responses pass everything except
hop-by-hop headers, content-length, content-encoding and www-authenticate.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The relay now forwards eligible incoming request headers and upstream response headers instead of using fixed forwarding allowlists. It filters hop-by-hop, proxy-prefixed, connection-named, and explicitly dropped headers. Saved credential headers take precedence over conflicting request headers. Tests cover custom header forwarding and the removal of www-authenticate.

Merge Risk: Minimal · up to ce9b0

The relay now forwards more agent headers upstream and returns more upstream response headers, while relay credentials stay excluded and saved credentials take precedence. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the agent tool relay now forwards every header except hop-by-hop headers and the relay's own credentials. It matches the raw summary and the objectives. The fix prefix…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template and covers the core content: ELI5, What Changed (request and response header policy, saved-header precedence, removed allowlist constants), Why (follow-…
Full details: Title check

Explanation

The title names the main change: the agent tool relay now forwards every header except hop-by-hop headers and the relay's own credentials. It matches the raw summary and the objectives. The fix prefix fits a change that closes a header-omission bug.

Full details: Description check

Explanation

The description follows the repository template and covers the core content: ELI5, What Changed (request and response header policy, saved-header precedence, removed allowlist constants), Why (follow-up to #48475 and #48477, with the reasoning for a denylist), Testing (manual testing, new test coverage, and a fail-without-change check), Performance, and Risk with a Low level and a revert plan. Gaps: the Linked Issue section has 'Fixes #' with no issue number. It references a closed follow-up to #48475 and does not link an actual issue, which the template requires for outside contributors. The Visual Proof section is N/A with a reason, which is acceptable. The AI Disclosure section is empty. The Agent skill upstream boundary checkbox is not ticked, and the Notes and Checklist sections are not addressed. The Testing section does not name platforms tested. These are non-critical except for the linked issue.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c574fc9e-b4c6-4602-8281-1d2e979732f9
Commits

Reviewing files that changed from the base of the PR and between 493a822 and ce9b009.

Files selected for processing: 1

  • src/main/bots/tool-relay/bot-tool-relay.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit 7e18c91 into main Nov 26, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant