Forward the shared gateway secret only to the tool gateway (#94)
Security fix.
`HttpProxy.CreateProxiedHttpRequest` attached the shared
`X-Gateway-Secret` header to every proxied request, including requests
forwarded to user-deployed adapter pods, which have no need for it. The
header is only meaningful to the tool gateway.
## Change
- `CreateProxiedHttpRequest` takes a new `bool forwardGatewaySecret =
false` parameter and only attaches the header when it is set. The
default is `false` so any future call site fails closed.
- `AdapterReverseProxyController.ForwardStreamableHttpRequest` passes
`forwardGatewaySecret: name is null`, i.e. only the first-party tool
gateway route (`POST /mcp`) opts in. The decision is made on the route
rather than on the resolved backend name, because adapter names are not
reserved.
- Forwarded identity headers (`X-Mcp-UserId` / `X-Mcp-Roles`) are
unchanged for all targets, and inbound client-supplied
`X-Gateway-Secret` continues to be stripped.
No configuration or deployment changes are required.
## Tests
New `HttpProxyTests` (4 cases): the header is absent for an adapter
target, present for the tool gateway target, identity headers still
reach adapters, and a client-supplied value is still stripped.
`Microsoft.McpGateway.Service.Tests` 38/38 pass. Full solution: Tools
27/27, Service 38/38, Management 156 pass / 8 skipped.
Also validated end to end on a local Kubernetes cluster: with the
change, an adapter pod that echoes its inbound headers no longer sees
`X-Gateway-Secret` (and it no longer appears in `GET
/adapters/{name}/logs`), while `POST /mcp` still succeeds against the
tool gateway.
Co-authored-by: Lili Xu <lilx@microsoft.com> L
Lili Xu committed
9a704088d8bb76571fa8da7a5d298abcdd1f7e96
Parent: 100fee3
Committed by GitHub <noreply@github.com>
on 8/5/2026, 5:58:40 PM