Make header forwarding configurable via proto config
mcp_router's createUpstreamHeaders() forwards every request header to the backend except a small hardcoded skip-list (:method, :path, :authority, host, content-type, accept, the session header). That includes authorization and anything else the client sends.
// mcp_router.cc:1983
// TODO(botengyao): Make header forwarding (authorization, etc.) configurable via proto config.
if (request_headers_) {
copyRequestHeaders(*request_headers_, *headers);
...
Since mcp_router aggregates multiple backends behind one filter, this matters in practice: a deployment mixing a trusted internal backend with a third-party one has no way to stop the client's authorization header from reaching both.
Before writing a PR, three things worth clarifying:
- Filter-level (
McpRouter), or per-backend (McpBackend)?createUpstreamHeaders(const McpBackendConfig& backend, ...)already takes the backend as an argument, it just doesn't consult it for header policy yet. Per-backend seems like the natural fit given mixed-trust backends are the actual motivating case, but wanted to check. - Reuse
config.common.mutation_rules.v3.HeaderMutation(already embedded byext_authz,ext_proc,header_mutation,transform), or a narrower purpose-built message likeapi_key_auth's recentForwarding? - Does the default behavior stay strictly additive (unset field = today's forward-everything-except-skip-list), or is the current default itself worth tightening as part of this?
Happy to put up a PR once these are settled.
Part of #39174.
cc @botengyao
cc @yanavlasov @botengyao as codeowners
hi @botengyao do I have your blessing?
Thanks for the ping, and sorry I missed this. Yes, please go ahead.
My preference is:
-
Put this on
McpBackend. Header forwarding is part of each backend’s trust/authentication boundary, so a filter-level policy alone does not solve the mixed-trust case. Please cover both the filter andmcp_multiclusterbackend configurations. -
Use a purpose-built forwarding policy rather than
HeaderMutation. Please model it afterext_proc’sHeaderForwardingRules: allow/disallow matchers, deny taking precedence, plus an explicitforward_allopt-in. I would keep the type MCP-local rather than importing an ext_proc-owned API. Backend header mutation or credential injection should remain a separate concern. -
Default to forwarding no downstream-controlled headers beyond those the router must synthesize. In particular, a client-to-gateway
Authorizationtoken must not implicitly cross into every backend. MCP requires audience-bound tokens and [explicitly prohibits token passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations). Since this API is still WIP, now is the right time to establish the secure default. Users needing the legacy behavior can explicitly configureforward_all, with a release note.
Router-owned, framing, session, and hop-by-hop headers must remain outside this policy and non-forwardable.
got it, I am on it 🫡
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.