envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Make header forwarding configurable via proto config

Open kkukadia opened this issue 4 months ago • 6 comments

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:

  1. 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.
  2. Reuse config.common.mutation_rules.v3.HeaderMutation (already embedded by ext_authz, ext_proc, header_mutation, transform), or a narrower purpose-built message like api_key_auth's recent Forwarding?
  3. 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

kkukadia avatar Aug 03 '26 23:08 kkukadia

cc @yanavlasov @botengyao as codeowners

adisuissa avatar Aug 04 '26 18:08 adisuissa

hi @botengyao do I have your blessing?

kkukadia avatar Aug 18 '26 02:08 kkukadia

Thanks for the ping, and sorry I missed this. Yes, please go ahead.

My preference is:

  1. 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 and mcp_multicluster backend configurations.

  2. Use a purpose-built forwarding policy rather than HeaderMutation. Please model it after ext_proc’s HeaderForwardingRules: allow/disallow matchers, deny taking precedence, plus an explicit forward_all opt-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.

  3. Default to forwarding no downstream-controlled headers beyond those the router must synthesize. In particular, a client-to-gateway Authorization token 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 configure forward_all, with a release note.

Router-owned, framing, session, and hop-by-hop headers must remain outside this policy and non-forwardable.

botengyao avatar Aug 18 '26 04:08 botengyao

got it, I am on it 🫡

kkukadia avatar Aug 18 '26 20:08 kkukadia

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.

github-actions[bot] avatar Sep 18 '26 00:09 github-actions[bot]

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.

github-actions[bot] avatar Sep 25 '26 00:09 github-actions[bot]