You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vMCP: fail loud when a passthrough header collides with a backend's outgoing-auth strategy #5535
Follow-up to #5466. That PR makes mergeForwardedHeaders fail loud when a passthroughHeaders name collides with a backend's staticHeaderForward config (plaintext or secret). This issue covers the other half of the original Authorization footgun: a passthrough header whose canonical name is also managed by the backend's outgoing-auth strategy.
Problem
The transport chain runs header-forward (outer) → authRoundTripper (inner). The strategy's Authenticate calls Header.Set(...) and silently overwrites any forwarded value with the same name:
upstream_inject / token_exchange / aws_sts / obo → set Authorization
header_injection → sets its configured HeaderName
So forwarding Authorization (or a header_injection name) to such a backend is silently clobbered — no error, no warning.
The legitimate LiteLLM Zero Trust case is unaffected: those backends run the unauthenticated strategy, which manages no headers, so there is no collision.
Desired
Detect — at config validation or session creation — that a passthroughHeaders name collides with a header the backend's resolved outgoing strategy manages, and fail loud with a clear message. Same philosophy as the static-config collision check already in #5466.
Sketch
Add a way for a strategy to declare the header names it manages (e.g. ManagedHeaders() on the outgoing Strategy interface — header_injection returns its configured name; the bearer strategies return Authorization; unauthenticated returns none). Cross-check against cfg.PassthroughHeaders where the backend strategy is resolved.
Sketching an approach here before anyone picks this up — feedback welcome.
Goal: fail loud when a passthroughHeaders name is also managed by a backend's resolved outgoing-auth strategy (the strategy's authRoundTripper runs inner and silently Sets over the forwarded value).
Managed-header mapping (what each strategy Sets):
Strategy
Manages
unauthenticated
—
upstream_inject / token_exchange / aws_sts / obo
Authorization
header_injection
its configured HeaderName
Proposed approach:
Add ManagedHeaders(strategy *BackendAuthStrategy) []string to the outgoing Strategy interface, returning canonical names the strategy will set. Keeps the knowledge next to each Authenticate impl (single source of truth) instead of a map that drifts.
Cross-check at session creation (createMCPClient), right alongside the existing static-HeaderForward collision check from Add passthroughHeaders to VirtualMCPServer for header forwarding #5466 — that's where the strategy is resolved and the forwarded headers are in scope. Error: forwarded header X collides with backend Y's <strategy> outgoing-auth strategy.
Regenerate the strategy mock; add per-strategy ManagedHeaders unit tests + a collision-error test.
Open questions for discussion:
Where to check — session creation (runtime, consistent with Add passthroughHeaders to VirtualMCPServer for header forwarding #5466) vs config validation. Backend strategies are resolved at runtime (discovered/inline), so the static validator doesn't have them — leaning session-creation. Acceptable that it fails on first session per misconfigured backend?
Interface vs static map — adding an interface method touches every strategy impl + the mock. Worth it for type-safety / no-drift, or prefer a small lookup keyed by strategy type (with header_injection special-cased since it's config-dependent)?
header_injection scope — collision only when its configured HeaderName canonical-matches a passthrough name; a backend injecting X-API-Key shouldn't block an Authorization passthrough. The interface approach handles this naturally.
Thanks @juancarlosm for sketching this out — the ManagedHeaders() interface is the right call. One suggestion on the "where to check" open question.
I'd argue we can detect this at startup without waiting for session creation. Discovery already resolves AuthConfig for every backend up front (applyAuthConfigToBackend, discoverer.go:200/:287), so the full set of (backend, resolved strategy) pairs is in scope once aggregation completes — before any session is created.
So rather than checking in createMCPClient, I'd run the cross-check once in the post-discovery aggregation step:
Catches both inline and discovered modes (in discovered, strategies come from the backend's MCPServer and aren't in vMCP config, so a pure config.Validate() check can't see them — but they are resolved by the time discovery finishes).
Fails loud at startup instead of on the first session per misconfigured backend.
Uses your ManagedHeaders() design unchanged — just called from the aggregation loop instead of createMCPClient.
Do you want to pick this up? Happy to assign you the issue.
Activity
juancarlosm commentedon Jun 16, 2026
Sketching an approach here before anyone picks this up — feedback welcome.
Goal: fail loud when a
passthroughHeadersname is also managed by a backend's resolved outgoing-auth strategy (the strategy'sauthRoundTripperruns inner and silentlySets over the forwarded value).Managed-header mapping (what each strategy
Sets):unauthenticatedupstream_inject/token_exchange/aws_sts/oboAuthorizationheader_injectionHeaderNameProposed approach:
ManagedHeaders(strategy *BackendAuthStrategy) []stringto the outgoingStrategyinterface, returning canonical names the strategy will set. Keeps the knowledge next to eachAuthenticateimpl (single source of truth) instead of a map that drifts.createMCPClient), right alongside the existing static-HeaderForwardcollision check from Add passthroughHeaders to VirtualMCPServer for header forwarding #5466 — that's where the strategy is resolved and the forwarded headers are in scope. Error:forwarded header X collides with backend Y's <strategy> outgoing-auth strategy.ManagedHeadersunit tests + a collision-error test.Open questions for discussion:
header_injectionspecial-cased since it's config-dependent)?header_injectionscope — collision only when its configuredHeaderNamecanonical-matches a passthrough name; a backend injectingX-API-Keyshouldn't block anAuthorizationpassthrough. The interface approach handles this naturally.jerm-dro commentedon Jun 17, 2026
Thanks @juancarlosm for sketching this out — the
ManagedHeaders()interface is the right call. One suggestion on the "where to check" open question.I'd argue we can detect this at startup without waiting for session creation. Discovery already resolves
AuthConfigfor every backend up front (applyAuthConfigToBackend,discoverer.go:200/:287), so the full set of(backend, resolved strategy)pairs is in scope once aggregation completes — before any session is created.So rather than checking in
createMCPClient, I'd run the cross-check once in the post-discovery aggregation step:inlineanddiscoveredmodes (indiscovered, strategies come from the backend'sMCPServerand aren't in vMCP config, so a pureconfig.Validate()check can't see them — but they are resolved by the time discovery finishes).ManagedHeaders()design unchanged — just called from the aggregation loop instead ofcreateMCPClient.Do you want to pick this up? Happy to assign you the issue.