Skip to content

fix: exempt loopback hosts from the CIMD metadata URL HTTPS requirement - #2326

Merged
cliffhall merged 5 commits into
v2/mainfrom
v2/fix/2305-cimd-loopback-http
Sep 11, 2026
Merged

cliffhall merged 5 commits into
v2/mainfrom
v2/fix/2305-cimd-loopback-http

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2305

What changed

getCimdClientMetadataUrlError (core/client/config-parse.ts) rejected every non-HTTPS CIMD client metadata URL with no loopback exemption, and the same check runs against client.json on disk through refineCimdMetadataUrl → CimdConfigSchema — so it could not be worked around by hand-editing the file either.

Every test server in this repo speaks plain HTTP, so CIMD could not be driven against any local fixture. That is why #2242 shipped verified by unit and integration tests alone, and why reproducing it by hand meant standing up a self-signed HTTPS listener to hold a JSON document plus NODE_TLS_REJECT_UNAUTHORIZED=0 in the test server's environment.

This is option 1 from the issue: accept plain http: on the three literals the SDK itself exempts from its token-endpoint TLS assertion — localhost, 127.0.0.1 and [::1].

  • It matches what the runtime already tolerated: core/auth/cimd.ts notes that an already-stored client_id may be an http:// URL "used by local dev/test metadata servers". The config validation was refusing a value the rest of the stack would happily use.
  • The non-loopback HTTPS requirement is unchanged. Anything outside those three is still rejected — localhost. and tenant.app.localhost included, even though both resolve to loopback on every resolver. Matching the SDK literal for literal is what keeps the two allow-lists from disagreeing about the same URL, and there is a test pinning it.
  • The exemption is a literal set rather than isLoopbackHost from core/node/hostUrl.ts, because config-parse.ts is browser-safe and hostUrl.ts imports node:net. The comment says so.

The field error now names the exemption (must use HTTPS, except on localhost, 127.0.0.1 or [::1]) instead of saying only "must use HTTPS", and the form's hint and input description say the same — the phrasing lesson from the token-endpoint notice in core/auth/oauthUx.ts: telling someone to "use HTTPS" when a local fixture is the whole point sends them off to build a TLS listener rather than fix their URL.

Acceptance

  • A loopback http:// CIMD metadata URL is accepted
  • test-servers/configs/oauth-cimd-http.json driven end to end from the web client with no self-signed HTTPS listener (screenshot below)
  • The non-loopback HTTPS requirement is unchanged, with a test asserting a plain http:// public host is still rejected
  • docs/test-servers.md's CIMD section updated to drop the workaround

Tests

  • clients/web/src/test/core/client/config.test.ts — the three exempt literals accepted inline and through parseClientConfig; a public http:// host still rejected; the path check still applied on an exempt host; the four near-miss hosts still rejected; and http://localhost./… pinned as the invalid-URL error, since isAbsoluteHttpUrl rejects its trailing empty label before the protocol check runs.
  • clients/web/src/test/integration/mcp/oauth-cimd-fixture.test.ts — a new case asserting the URL the live fixture actually serves its document from is legal config as-is, both inline and in client.json. That is the property the fixture's reason for existing rests on, and a re-tightened validator would put the manual repro back out of reach without failing anything else in that file.

Screenshots

Captured at 1280×900, full page, driving the real prod --web bundle against the live oauth-cimd-http.json fixture.

Before — http://localhost:8092/client-metadata.json rejected, and the hint claims HTTPS is the only option:

before

After — the same URL accepted, and the hint and description name the exemption:

after

End to end — Connection Info after a full OAuth round against the fixture, with no HTTPS listener and no NODE_TLS_REJECT_UNAUTHORIZED. Client registration — Client ID Metadata (CIMD), and the Client ID equal to the metadata URL, which is what CIMD means and what distinguishes it from a DCR-issued test_client_… (the fixture has supportDCR: false, so reaching a connected state is the assertion). The fixture walked to 8093 here because 8092 was taken:

connection info

Gate

npm run format then npm run local:gate — green.

⚠️ Three earlier runs went red on three different timing-sensitive tests (SkillsScreen directory browsing, revocation elapsed-ms bound, skillsVerification byte-budget), none of them in files this diff touches. The machine was at a load average of 179 (a Time Machine backup plus other sessions). Each failing test passes on its own, and the run after the load cleared was green end to end.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB

`getCimdClientMetadataUrlError` rejected every non-HTTPS CIMD client metadata
URL with no loopback exemption, and the same check runs against `client.json`
on disk through `refineCimdMetadataUrl`, so it could not be worked around by
hand-editing the file either. Every test server in this repo speaks plain HTTP,
so CIMD could not be driven against any local fixture: #2242 shipped verified by
tests alone, and reproducing it by hand meant standing up a self-signed HTTPS
listener plus `NODE_TLS_REJECT_UNAUTHORIZED=0` in the test server's environment.

Accept plain `http:` on the three literals the SDK itself exempts from its
token-endpoint TLS assertion — `localhost`, `127.0.0.1` and `[::1]`. That is
option 1 in #2305 and matches what the runtime already tolerated:
`core/auth/cimd.ts` notes that an already-stored `client_id` may be an `http://`
URL used by local dev/test metadata servers. Anything outside those three,
`localhost.` and `tenant.app.localhost` included, is still rejected — matching
the SDK literal for literal keeps the two allow-lists from disagreeing about one
URL.

The exemption is a literal set rather than `isLoopbackHost` because
`core/client/config-parse.ts` is browser-safe and `core/node/hostUrl.ts` imports
`node:net`.

The field error now names the exemption instead of saying only "must use
HTTPS", and the form's hint and description say the same, so a developer
pointing the field at a local fixture is told which spellings work.

Closes #2305

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Sep 11, 2026
@cliffhall
cliffhall requested a balanced review from Copilot September 11, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The smoke-testing documentation still contradicts the new loopback HTTP exemption and should be updated.

Pull request overview

Allows plain HTTP CIMD metadata URLs for exact loopback hosts while preserving HTTPS enforcement elsewhere.

Changes:

  • Adds localhost, 127.0.0.1, and [::1] exemptions.
  • Updates UI guidance and test-server documentation.
  • Adds unit and integration coverage.
File summaries
File Reviewed changes Review note
docs/test-servers.md Updates local CIMD fixture instructions. Nit (1 vote): Update specification/v2_auth_smoke_testing.md:513, which still describes the exemption as test-only.
core/client/config-parse.ts Implements literal loopback HTTP exemptions. Nit (1 vote): Update the contradictory smoke-testing guidance at specification/v2_auth_smoke_testing.md:513.
clients/web/src/test/integration/mcp/oauth-cimd-fixture.test.ts Verifies HTTP fixture URL acceptance inline and through client.json. No findings.
clients/web/src/test/core/client/config.test.ts Tests accepted loopback URLs and rejected non-loopback and near-miss hosts. No findings.
clients/web/src/components/groups/ClientSettingsForm/ClientSettingsForm.tsx Updates CIMD URL hints and descriptions. No findings.
Review details

Suppressed comments (2)

core/client/config-parse.ts:123

  • specification/v2_auth_smoke_testing.md:513 still says that ensureCimdClientRegistration permits http://127.0.0.1 metadata URLs "in tests only." This change makes those URLs valid through the persisted client-config path and the web settings UI, so the smoke guidance is now contradictory; update that statement (and any affected local-CIMD instructions) along with this policy change.
    if (url.protocol !== "https:" && !isCimdHttpExemptHost(url.hostname)) {

docs/test-servers.md:573

  • Please update specification/v2_auth_smoke_testing.md:513 as part of this change. It still says ensureCimdClientRegistration permits http://127.0.0.1 metadata URLs “in tests only”; after this validator change those URLs are valid persisted client.json settings and the documented manual fallback, so that guide now contradicts the new workflow and tells users the exemption is test-only.
well as to the settings form), which is the same exemption the SDK applies to token endpoints and what
the runtime already tolerated for an already-stored `client_id`. Give the URL the host the server is
actually listening on; a host outside those three — `localhost.` and `tenant.app.localhost` included,
even though both resolve to loopback — is still rejected, deliberately, so this allow-list and the
SDK's cannot disagree about one URL.
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

…th smoke guide

`specification/v2_auth_smoke_testing.md` said `ensureCimdClientRegistration`
allows `http://127.0.0.1` metadata URLs "in tests only". That was accurate while
the exemption lived only in the runtime's already-stored-`client_id` path; after
this PR a loopback `http://` URL is a valid persisted `client.json` setting and a
valid entry in the settings form, so the sentence contradicted the workflow the
same guide asks a smoke tester to run (Copilot review round 1).

The same paragraph's recipe was stale in two other ways it is cheaper to fix
here than to leave next to a corrected claim: `cd test-servers && npm run build`
names a manifest that does not exist, and `oauth-cimd-only.json` is not a config
in this repo. Both now point at the shipped `oauth-cimd-http.json` fixture and
the real build command.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review round 1 — response

The round generated 0 inline comments; both findings arrived in the Suppressed comments block, which has no thread to reply into, so this comment is the response to each rather than a rollup alongside inline replies.

core/client/config-parse.ts:123 and docs/test-servers.md:573 — the same finding: specification/v2_auth_smoke_testing.md:513 still describes the loopback exemption as test-only. Accepted, fixed in 7b9090c.

The line read: "ensureCimdClientRegistration allows http://127.0.0.1 metadata URLs in tests only." That was accurate while the exemption lived only in the runtime's already-stored-client_id path — which is exactly the asymmetry #2305 is about. After this change a loopback http:// URL is a valid persisted client.json setting and a valid entry in the settings form, so the sentence contradicted the workflow the same guide asks a smoke tester to run. It now states the validator-level exemption, names the three literals, and says what the situation was before, so the paragraph still reads correctly against an older build.

Two further things in that same paragraph were stale, and I fixed them rather than leave them sitting next to a corrected claim:

  • cd test-servers && npm run build names a manifest that does not exist — test-servers/ has no package.json (it is root-owned code). The build is cd clients/web && npm run test-servers:build.
  • oauth-cimd-only.json is not a config in this repo. The shipped fixture is test-servers/configs/oauth-cimd-http.json, which is also the one that hosts the metadata document, so it is what makes the recipe runnable at all.

I also grepped specification/, docs/ and README.md for other statements of the old policy (no loopback exemption, must use HTTPS, self-signed) and found none outside the two files this PR already updates.

npm run format and npm run local:gate re-run green on the amended branch.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Address the hostname-alias validation gap and correct the documented smoke-test paths.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

core/client/config-parse.ts:123

  • URL.hostname is WHATWG-canonicalized before this check, so the implementation does not actually restrict HTTP to the three documented input literals. For example, http://127.1:..., http://2130706433:..., and http://[0:0:0:0:0:0:0:1]:... become 127.0.0.1/[::1] and pass, despite the literal allow-list and its near-miss test. Compare the original authority hostname (or explicitly decide and document these aliases) and add regression cases.
    if (url.protocol !== "https:" && !isCimdHttpExemptHost(url.hostname)) {
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread specification/v2_auth_smoke_testing.md Resolved
…oke recipe's cwd

Copilot review round 2.

The exemption compares the WHATWG-canonicalized `URL.hostname`, so it covers
alternate spellings of three loopback *addresses* rather than three input
strings: `127.1`, `2130706433`, `0x7f.0.0.1`, `[0:0:0:0:0:0:0:1]` and a
root-anchored `127.0.0.1.` all pass. The behavior is right — the security
argument is about the address the request reaches, and all of these are the
loopback interface — but the comment described it as a literal-input match,
which it is not. It now states the contract, and six regression cases pin the
aliases alongside the existing near-miss cases.

This is also still an exact match for the SDK: `assertSecureTokenEndpoint` tests
`url.hostname` against the same three values after the same `new URL`
canonicalization, so an alias accepted here is one the SDK accepts too.

Separately, the smoke guide's fixture recipe left the shell in `clients/web`
after the build line, so the repo-root-relative paths on the next line resolved
under `clients/web` and the copy-pasted setup failed before the server started.
The build now runs in a subshell, and the block notes that the server announces
its URL on stderr and walks past a taken port.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review round 2 — response

One inline comment (replied in its thread) and one suppressed finding, which has no thread and is answered here.

specification/v2_auth_smoke_testing.md — the recipe leaves the shell in clients/web. Accepted, fixed in a21fd0c.

Mirrored from the thread: the build script only exists in clients/web, but the next line's paths are repo-root-relative, so after that cd they resolved under clients/web and the copy-pasted block failed before the fixture started. The build now runs in a subshell. I also noted that the server announces its URL on stderr and walks past a taken port, since this block is the whole local-CIMD recipe and those are the next two things that bite.

Suppressed — core/client/config-parse.ts:123: URL.hostname is canonicalized, so 127.1, 2130706433, [0:0:0:0:0:0:0:1] pass despite the literal allow-list. Correct, and thank you — the documentation was wrong, not the behavior. Fixed in a21fd0c.

You are right about the mechanism, and I verified every alias:

http://127.1:8092/c.json               -> "127.0.0.1"
http://2130706433:8092/c.json          -> "127.0.0.1"
http://0x7f.0.0.1:8092/c.json          -> "127.0.0.1"
http://[0:0:0:0:0:0:0:1]:8092/c.json   -> "[::1]"
http://127.0.0.1.:8092/c.json          -> "127.0.0.1"

Taking your second option — decide and document — rather than comparing the raw authority, for two reasons:

  1. Accepting them is the correct behavior. The security argument in the comment is about the address the authorization server's fetch actually reaches, not about the string someone typed. Every one of these is the loopback interface, so there is no network segment for an attacker to sit on and nothing the HTTPS requirement would be protecting. Rejecting http://127.1/… while accepting http://127.0.0.1/… would be a distinction with no security content behind it.

  2. It keeps the match with the SDK exact, which was the stated goal. I checked @modelcontextprotocol/client:

    function isLoopbackHost(hostname) {
      return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
    }
    function assertSecureTokenEndpoint(tokenEndpoint) {
      const url = new URL(String(tokenEndpoint));
      if (url.protocol !== "https:" && !isLoopbackHost(url.hostname)) throw new InsecureTokenEndpointError(url.href);
      return url;
    }

    It tests url.hostname after the same new URL canonicalization, against the same three values (the fourth arm, bare ::1, is dead — URL.hostname always brackets IPv6). So the SDK accepts these aliases too. Comparing the raw authority instead would have introduced the divergence the comment claims to avoid, not removed it.

What was actually wrong was the comment calling this "the SDK's three-literal list… literal for literal", which describes an input match. It now states the real contract: the comparison is against the canonicalized URL.hostname, so the exemption covers alternate spellings of three loopback addresses, and the SDK does the same.

Six regression cases added, per your request, alongside the existing near-miss ones — including the asymmetry the aliases expose, which I would not have thought to pin otherwise: WHATWG strips a root-anchored dot from an IP literal but not from a name, so http://127.0.0.1./… is accepted while http://localhost./… is not. The near-miss test is renamed from "beyond the three literals" to "beyond those three addresses" to match.

The existing rejections are unchanged and still covered: tenant.app.localhost, localhost., 127.0.0.2, localhost.example.com and any public http:// host.

npm run format and npm run local:gate green on a21fd0c.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The exemption is narrowly implemented, consistently documented, and thoroughly covered by unit and integration tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Documentation and specification guidance need the identified state-reset and URL clarification updates.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (3)

docs/test-servers.md:579

  • This walkthrough also omits the OAuth-state reset needed for its claimed negative control. The Inspector reuses persisted tokens before prompting for authentication, and disabling CIMD does not clear them, so a prior run can make “CIMD off should fail” appear to pass. Add a clear-state step before the off run and again before enabling CIMD.
⚠️ **Before [#2305](https://github.com/modelcontextprotocol/inspector/issues/2305) there was no
loopback exemption at all**, so driving this flow meant standing up a throwaway self-signed HTTPS
listener to hold the document and setting `NODE_TLS_REJECT_UNAUTHORIZED=0` in the *test server's*
environment so its own fetch of that document would succeed. That workaround is no longer needed — if
you find it in a script or an older note, delete it.

specification/v2_auth_smoke_testing.md:526

  • The two outcomes documented here are not deterministic without clearing OAuth state: tokens and client registrations persist independently of the install-wide CIMD toggle, so a previous CIMD run can make the CIMD-off connection reuse stored credentials instead of failing. Add an explicit clear step before the off phase and between the off/on phases, as the other smoke procedures do.
With CIMD off in Client Settings, connect + authenticate should **fail**; with CIMD on and that local metadata URL, it should **succeed**. `docs/test-servers.md` has the full walkthrough, including the `redirect_uris` port trap.

specification/v2_auth_smoke_testing.md:524

  • The composable server does not announce a metadata URL: test-servers/src/server-composable.ts:109 prints the MCP endpoint ending in /mcp. This sentence labels /client-metadata.json as the announced URL; instruct readers to take the origin (host and port) from the announced MCP URL and append /client-metadata.json instead.
Since [#2305](https://github.com/modelcontextprotocol/inspector/issues/2305) a loopback `http://` metadata URL is a **valid persisted `client.json` setting and a valid entry in the settings form**, not a test-only affordance — `getCimdClientMetadataUrlError` exempts `localhost`, `127.0.0.1` and `[::1]`, the same three literals the SDK exempts for token endpoints. So point `clientMetadataUrl` straight at the URL the fixture announced (`http://127.0.0.1:8092/client-metadata.json` on its configured port) with no HTTPS listener. Before that change the exemption existed only in `ensureCimdClientRegistration`, for an already-stored `client_id`, and driving this by hand needed a self-signed HTTPS listener plus `NODE_TLS_REJECT_UNAUTHORIZED=0`.
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread specification/v2_auth_smoke_testing.md Resolved
… claims

Copilot review round 4, four findings, all correct.

The CIMD-off / CIMD-on pair the smoke guide documents is not a control without
clearing OAuth state first: tokens and the registered client persist in
oauth.json independently of the install-wide CIMD toggle, and the Inspector
reuses valid stored tokens before prompting — so a leftover grant from an
earlier CIMD-on run makes the CIMD-off phase connect and the negative control
silently proves nothing. Both the spec's pair and the walkthrough in
docs/test-servers.md now say to clear state (or isolate MCP_STORAGE_DIR) first.

The composable server announces its MCP endpoint, not the metadata document —
`server-composable.ts` prints a URL ending in `/mcp`. The guide called the
announced URL a metadata URL; it now says to take the origin from that line and
append `/client-metadata.json`.

Two general statements elsewhere in the same file still defined CIMD as always
HTTPS (the glossary row, and the Stytch section's opening), so a reader
following them would have rejected the loopback fixture the same file now
documents. Both note the exemption; the Stytch examples stay HTTPS, which they
are.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review round 3 + 4 — response

Round 3 was 🟢 Approval recommended, 0 comments. I requested a fourth round anyway rather than stopping there — a single zero-comment round is not evidence a review is finished — and it produced four findings, all correct. Round 4 is 1 inline comment (replied in its thread) and 3 suppressed, which have no thread and are answered here. All four are fixed in d7f9014.

Suppressed — specification/v2_auth_smoke_testing.md:526 and docs/test-servers.md:579: the off/on pair is not deterministic without clearing OAuth state. Accepted; this is the most valuable finding of the four.

You are right, and the failure mode is worse than non-determinism — it is a negative control that silently passes. Tokens and the registered client persist in ~/.mcp-inspector/storage/oauth.json independently of the install-wide CIMD toggle, and the Inspector reuses valid stored tokens before prompting. So a leftover grant from an earlier CIMD-on run carries the CIMD-off phase to a connected state, and the tester concludes the control held when nothing was exercised. That is the same "it connected, therefore CIMD worked" trap supportDCR: false exists to close, arriving through a different door.

Both files now carry the step. The spec's pair gets it twice, as you asked — before the off phase and again between off and on — and the walkthrough in docs/test-servers.md gets it once, since that one is a single connect rather than a pair. I named both mechanisms: Clear OAuth state and disconnect (Server Settings → Authorization), and pointing MCP_STORAGE_DIR at a throwaway directory, flagged as the stronger option because it also survives the adjacent failure — a restarted fixture has forgotten a client it once issued, and the stale client_id then dies at the consent page with invalid_client.

Suppressed — specification/v2_auth_smoke_testing.md:524: the server does not announce a metadata URL. Accepted, and the citation is exact.

server-composable.ts prints Composable server listening at http://127.0.0.1:${port}/mcp. My sentence called that "the URL the fixture announced" while showing a /client-metadata.json URL, which conflates two different things and would send a reader to paste an MCP endpoint into clientMetadataUrl. Rewritten to instruct exactly what you suggested — take the origin from the announced line and append /client-metadata.json, with a worked example — plus the reminder not to assume 8092, since the fixture walks past a taken port. (It did exactly that during my own end-to-end capture for this PR: it bound 8093, which is why the screenshot shows that port.)

Inline — the file still defines CIMD as always-HTTPS at lines 43 and 398.

Answered in its thread. Both updated; the Stytch section's concrete URLs stay HTTPS, since they are.


No code changed in this round — all four findings were documentation. npm run format and npm run local:gate green on d7f9014.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two moderate issues and one documentation nit remain unresolved.

Review details

Suppressed comments (3)

clients/web/src/components/groups/ClientSettingsForm/ClientSettingsForm.tsx:319

  • The new copy is part of the fix's user-facing contract, but ClientSettingsForm.test.tsx currently verifies only the validation error and does not assert the hint or this input description. A future regression could restore an HTTPS-only instruction while the validator remains permissive, putting the documented local-fixture workflow out of reach for users again. Add a CIMD-enabled render assertion for both pieces of copy.
                    description="HTTPS URL of your OAuth client metadata JSON document (http:// is accepted only on localhost, 127.0.0.1 or [::1])."

core/client/config-parse.ts:105

  • This check is broader than the stated three-literal SDK exemption: because url.hostname is WHATWG-canonicalized, it accepts plain HTTP for aliases such as 127.1, 2130706433, expanded ::1, and 127.0.0.1.. The SDK's isLoopbackHost uses exact url.hostname comparisons and does not accept those aliases, so the claim that the allow-lists match is false (and a CIMD server can also normalize the alias before comparing the required client_id). Restrict the exemption to the exact SDK spellings, or explicitly revise the requirement and end-to-end contract to use address-based acceptance.
const CIMD_HTTP_EXEMPT_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);

docs/test-servers.md:576

  • The preceding sentence correctly notes that the runtime already tolerated an http:// URL when it was an already-stored client_id, so saying there was “no loopback exemption at all” is inaccurate. The pre-#2305 gap was in the config/form validator; narrow this wording so the docs do not imply that the runtime could never use local CIMD URLs.
⚠️ **Before [#2305](https://github.com/modelcontextprotocol/inspector/issues/2305) there was no
loopback exemption at all**, so driving this flow meant standing up a throwaway self-signed HTTPS
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…docs

Copilot review round 5. Two of three findings taken; the third rests on a false
premise about the SDK and is declined with evidence in the PR thread.

The hint and the input description are part of this fix's user-facing contract —
an HTTPS-only instruction there puts the local-fixture workflow back out of
reach even while the validator stays permissive — and nothing asserted them.
Two cases now do, plus one asserting a loopback http URL raises no error in the
form. Each mutation (restoring either piece of old copy) fails exactly one of
them.

The docs said there was "no loopback exemption at all" before #2305, which
contradicts the sentence above it: the runtime already tolerated an `http://`
already-stored `client_id`, and that asymmetry is what the issue is about. The
gap was in the config/form validator, and the wording now says so.

Also added: a note to use the canonical spelling of the host. `127.1` and
`2130706433` are accepted here and by the SDK, since both canonicalize to
`127.0.0.1` — but a CIMD `client_id` is string-compared by the authorization
server against the URL it dereferenced, so an exotic spelling is a real footgun
independent of what either validator allows.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GfHQ8vMm5NBgzbUJ6UwxmB
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review round 5 — response

Three suppressed findings, no inline comments, so this comment is the response to each. Two taken (8baa121), one declined — that one is declined on evidence rather than judgment, detail below.

✅ ClientSettingsForm.tsx:319 — the new copy is part of the contract and nothing asserted it. Taken.

Agreed, and the reasoning is the right one: the validator being permissive is only half the fix. If the hint reverts to an HTTPS-only instruction, a reader is told the local-fixture workflow is impossible and never tries it, with every test still green. Three cases added, and I checked they actually detect that:

Mutation Result
Restore description="Public HTTPS URL of your OAuth client metadata JSON document." 1 failed, 29 passed
Restore the hint's must be served over HTTPS and list this redirect URI 1 failed, 29 passed

One failure each, not two — so the cases are detecting and not redundant with each other. The third new case asserts http://localhost:8092/client-metadata.json renders with no error in the form under revealErrors, which covers the validator through the UI rather than only through getCimdClientMetadataUrlError.

✅ docs/test-servers.md:576 — "no loopback exemption at all" is inaccurate. Taken.

You are right, and it contradicted the sentence directly above it in my own text. The runtime did tolerate an http:// already-stored client_id — that asymmetry is the whole of #2305. The gap was in the config/form validator, and there was no way to get such a value past validation into client.json. Reworded to say exactly that.

❌ core/client/config-parse.ts:105 — "The SDK's isLoopbackHost uses exact url.hostname comparisons and does not accept those aliases, so the claim that the allow-lists match is false." Declined: the SDK does accept them.

This is the same finding as round 2, where I documented the aliases at your suggestion. The new claim is that the SDK rejects them, and that is not what it does. I ran it:

SDK ACCEPTS  http://127.1:9/token
SDK ACCEPTS  http://2130706433:9/token
SDK ACCEPTS  http://[0:0:0:0:0:0:0:1]:9/token
SDK ACCEPTS  http://127.0.0.1.:9/token
SDK REFUSES  http://127.0.0.2:9/token (InsecureTokenEndpointError)
SDK REFUSES  http://localhost.:9/token (InsecureTokenEndpointError)

That is assertSecureTokenEndpoint from the installed @modelcontextprotocol/client, called directly. It accepts every alias and refuses exactly the near-misses this PR's tests pin. The mechanism is in its source:

function assertSecureTokenEndpoint(tokenEndpoint) {
  const url = new URL(String(tokenEndpoint));
  if (url.protocol !== "https:" && !isLoopbackHost(url.hostname)) throw new InsecureTokenEndpointError(url.href);

isLoopbackHost does compare exactly — but it compares url.hostname, which new URL has already canonicalized. new URL("http://127.1/").hostname is the string "127.0.0.1", so the exact comparison succeeds. Mine reads url.hostname from a URL built the same way. The two are identical alias for alias, which is what "the allow-lists match" claims. Restricting to the raw input spelling would introduce the divergence this finding says it would remove — the same conclusion as round 2, now with the behavior measured rather than read.

So the implementation and the comment are unchanged. If I have misread your point and you meant the SDK's validateClientMetadataUrl (which does require HTTPS with no exemption), that one is not on this path: ensureCimdClientRegistration pre-registers the client_id so auth() never runs registration — the mechanism core/auth/cimd.ts documents and this PR does not change.

The parenthetical in your finding is a real point, though, and I took it: "a CIMD server can also normalize the alias before comparing the required client_id." A CIMD client_id is string-compared by the authorization server against the URL it dereferenced, so an exotic spelling can fail that comparison on a server that normalizes differently — regardless of what either validator allows. docs/test-servers.md now says to paste the origin the fixture announced rather than an equivalent you typed. That is a genuine footgun and I would not have documented it without this comment.

npm run format and npm run local:gate green on 8baa121.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The exemption is narrowly implemented, consistently documented, and covered across parsing, UI, persistence, and fixture behavior.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Requested behavior, documentation, and test coverage are complete.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@cliffhall

Copy link
Copy Markdown
Member Author

Review complete — rounds 6 and 7 both 🟢, zero comments

Seven Copilot rounds. The last two are 🟢 Approval recommended with 0 comments and no suppressed findings, which is what I was waiting for rather than the first clean round — round 3 approved with zero comments and round 4 then produced four real findings, so a single quiet round is not evidence a review is finished.

Both inline threads are replied to in-thread and resolved. Every suppressed finding is answered in the round comment above it, since those carry no thread to reply into.

What the review changed

Round Findings Outcome
1 1 (2 suppressed, same issue) Taken — the auth smoke guide still called the loopback exemption test-only
2 2 (1 inline, 1 suppressed) Both taken — documented the canonicalization contract; fixed a cd that broke the fixture recipe
3 0 🟢
4 4 (1 inline, 3 suppressed) All taken — clear-OAuth-state steps, the announced-URL conflation, two HTTPS-only definitions
5 3 suppressed 2 taken (form-copy tests, "no exemption at all" wording), 1 declined on evidence
6 0 🟢
7 0 🟢

The one declined finding claimed the SDK's isLoopbackHost rejects canonicalization aliases, making the "our allow-list matches the SDK's" claim false. It does not — assertSecureTokenEndpoint reads url.hostname off a URL it just constructed, so the input is already canonicalized before the exact comparison. Measured against the installed SDK, it accepts all four aliases and refuses exactly the near-misses this PR pins. Restricting to raw input spellings would have created the divergence the finding wanted removed. Full evidence is in the round 5 comment. Its parenthetical was a real point and was taken as a docs note.

The substance worth flagging to a human reviewer: the round-4 clear-OAuth-state finding was the best one. The CIMD-off/CIMD-on pair the smoke guide documents was not a control, because persisted tokens survive the CIMD toggle and the Inspector reuses them before prompting — so the negative phase could connect and silently prove nothing. That was a latent defect in the procedure, not in this diff.

Final state

Five commits, all signed off. One behavior change (~3 lines in core/client/config-parse.ts), the rest tests and documentation.

npm run format and npm run local:gate green on 8baa121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CIMD client metadata URL must be HTTPS with no loopback exemption, so CIMD cannot be driven against a local fixture

2 participants