fix: narrow the exemption per transport (#2319 round 18)
Round 17 widened exemptMcpEndpoint to the origin for everything, which exempted same-origin OAuth work as well as MCP traffic — on the very 401/discovery path #2319 exists to bound. The rule is now as narrow as each transport allows. Streamable HTTP sends every MCP request to the configured URL, so origin + pathname is exact there and same-origin OAuth stays bounded. Legacy SSE negotiates its message endpoint inside the stream, where we never see it, so the origin rule is the narrowest available — and it is exact rather than approximate, since the SDK enforces that the message endpoint shares the stream URL's origin. The residual gap is therefore confined to legacy SSE against a server hosting its own OAuth endpoints, and it is stated in the docblock and pinned by a test rather than left implicit. Neither alternative was reachable: the SDK takes a single fetch for all network requests, so there is no separate auth seam to route through, and the negotiated SSE endpoint is parsed inside the SDK's own stream handler. Fails open on every uncertainty, including not knowing the transport — a path rule applied to what turns out to be SSE severs real MCP traffic, so an absent or throwing hint falls back to the origin rule. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YFnM6RqB4nXqNysgUYmjmq Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
5a1c157a79
commit
42339ff4a4
1 changed files with 109 additions and 34 deletions
|
|
@ -840,7 +840,14 @@ export class InspectorClient extends InspectorClientEventTarget {
|
|||
withOAuthRequestTimeout(
|
||||
withOverrides,
|
||||
DEFAULT_OAUTH_REQUEST_TIMEOUT_MS,
|
||||
exemptMcpEndpoint(() => this.getServerUrl()),
|
||||
exemptMcpEndpoint(
|
||||
() => this.getServerUrl(),
|
||||
// Legacy SSE negotiates its message endpoint inside the stream, so
|
||||
// its path is unknowable here and the exemption has to widen to the
|
||||
// origin. Streamable HTTP sends everything to the configured URL, so
|
||||
// the path rule is exact there and same-origin OAuth stays bounded.
|
||||
() => this.transportConfig?.type === "sse",
|
||||
),
|
||||
),
|
||||
);
|
||||
// #2319: the auth chain is composed separately so the deadline sits
|
||||
|
|
|
|||
Loading…
Reference in a new issue