Skip to content

Commit b55f220

Browse files
authored
fix(core): treat *.localhost as loopback for MCP OAuth token endpoints (#55627)
1 parent fbf5f16 commit b55f220

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎patches/@modelcontextprotocol%2Fclient@2.0.0.patch‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
diff --git a/dist/index.cjs b/dist/index.cjs
2-
index 635f1c0134274c89e7efbcae2adf3d9ecba575ee..5eaa7b451c8c7e12e51f61c2a835ff6f7a8ea0ae 100644
2+
index 635f1c0134274c89e7efbcae2adf3d9ecba575ee..3f4dfb779a55deaae2c188a442b78ca519d5c17d 100644
33
--- a/dist/index.cjs
44
+++ b/dist/index.cjs
5+
@@ -517,7 +517,7 @@ function applyPublicAuth(clientId, params) {
6+
}
7+
/** Loopback hosts exempt from the in-transit `https:` requirement (RFC 8252 §7.3). */
8+
function isLoopbackHost(hostname) {
9+
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
10+
+ return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
11+
}
12+
/**
13+
* SEP-2207: refuse to send credentials to a non-TLS, non-loopback token endpoint.
514
@@ -977,7 +977,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
615
else {
716
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
@@ -19,9 +28,18 @@ index 635f1c0134274c89e7efbcae2adf3d9ecba575ee..5eaa7b451c8c7e12e51f61c2a835ff6f
1928
return {
2029
authorizationUrl,
2130
diff --git a/dist/index.mjs b/dist/index.mjs
22-
index f02ce3ca394e826fc27c9848dbe9a214bf6ba7a9..73a93a066c3540e131fa0770a74b4a7e8d9343a0 100644
31+
index f02ce3ca394e826fc27c9848dbe9a214bf6ba7a9..3508b8e841bb8d3d724fa5ff573902dbca81cf89 100644
2332
--- a/dist/index.mjs
2433
+++ b/dist/index.mjs
34+
@@ -514,7 +514,7 @@ function applyPublicAuth(clientId, params) {
35+
}
36+
/** Loopback hosts exempt from the in-transit `https:` requirement (RFC 8252 §7.3). */
37+
function isLoopbackHost(hostname) {
38+
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
39+
+ return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
40+
}
41+
/**
42+
* SEP-2207: refuse to send credentials to a non-TLS, non-loopback token endpoint.
2543
@@ -974,7 +974,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
2644
else {
2745
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);

0 commit comments

Comments
 (0)