Restrict MCP HTTP redirects to the configured origin (#39046)

## Why

MCP requests can contain sensitive headers and tool-call bodies. Following a
cross-origin redirect could disclose them to another server.

## What changed

- Follow redirects only when every hop remains on the configured server's
  origin, and require HTTPS for redirects on non-loopback hostnames.
- Preserve standard redirect method and body handling while sharing the
  original timeout and enforcing a 10-hop limit.
- Avoid replaying plaintext proxy credentials across redirects, while leaving
  OAuth requests that stop at redirects unchanged.

## Testing

Add coverage for same-origin and cross-origin redirects, redirect methods,
headers and bodies, proxy credentials, timeouts, hop limits, and legacy MCP
tool calls.

GitOrigin-RevId: 3e267911a1665ad8c2fc63825099a758770f4d68
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-17 18:46:12 +00:00
1 parent 06418909a0
commit ff770113ca
6 files changed
+721 -15

No files matched your search

+1
View File
@@ -3,6 +3,7 @@ mod elicitation_client_service;
mod event_notification_transport;
mod executor_process_transport;
mod http_client_adapter;
mod http_client_redirect;
mod http_headers;
mod in_process_transport;
mod incoming_jsonrpc;