[Feature]: Harden the OAuth client role (iss validation, issuer-bound credentials, application_type)
Problem / motivation
mcpproxy is trusted with real OAuth credentials against third-party authorization servers, but its client role accepts responses more loosely than its authorization-server role sends them. Three gaps:
- No
issvalidation. RFC 9207 §2.4 lets the client verify that a redirect carrying an authorization code really came from the expected issuer, closing the authorization-code injection class of attacks. Curiously, the AS role already emitsiss, but the client role never checks it. v1.0.0 of the SDK, which go.mod pins, predates the fix. - Credentials can be replayed across issuers. The persistent DCR credentials are recorded against the server key (config.go#L1185-L1223); a later metadata swap on the same upstream entry could exchange them against a different AS while the fields remain valid.
- DCR omits
application_type: "web". The SDK's registration payload only sendsclient_name,redirect_uris, and the auth-method / grant / response-type defaults (oauth.go, mcp-go v1.0.0); per RFC 7591 servers may default tonative, which changes the redirect rules applied to mcpproxy's loopback flow.
The good news: upstream mcp-go already merged fixes for all three. v1.2.0 added issuer checks on AS metadata, v1.3.0 bound credentials to the issuer, and v1.4.0 added RFC 9207 iss response validation and application_type in DCR (mcp-go v1.4.0 oauth.go).
Proposed solution
Upgrade the mcp-go pin to at least v1.4.0, then verify each path actually engages:
- the loopback redirect handler receives the
issquery param and the validation fires on real AS responses, not solely in unit tests - persisted credentials are keyed by issuer, not just server key, so a metadata swap cannot trigger a cross-AS exchange; migrate existing records on read
- the DCR payload sent from internal/oauth arrives at the real registration endpoints complete
Alternatives considered
Patching the gaps in internal/oauth on top of v1.0.0. Rejected: the fixes already exist upstream, duplicating them would mean more code to delete on the next bump.
Related to #1971, which covers the authorization-server role; this one covers the client direction.
Which edition?
Both / not sure
Pre-submission checklist
- [x] I searched existing issues and discussions for a similar request
Thanks @felipecrs, this was a good catch. I checked all three gaps against main (661ad51d7). The spec is in https://github.com/smart-mcp-proxy/mcpproxy-go/pull/2050 (Spec 135; docs only, implementation follows in later PRs).
Confirmed:
- No RFC 9207
isscheck. The callback server copies the query into amap[string]stringand never readsiss(internal/oauth/config.go:2013-2019). Every login path exchanges the code throughProcessAuthorizationResponse(code, state, verifier)(internal/upstream/core/connection_oauth.go:1678-1688). In mcp-go v1.4.0,ProcessAuthorizationResponsestill doesn't checkiss; only the newProcessAuthorizationCallbackdoes. So the bump alone won't engage it. The spec moves the decision into mcpproxy's callback handler and keeps mcp-go's check as a second line. - Credentials not bound to the issuer. Rows are keyed by
name|urland carry no issuer (internal/storage/models.go:628-657). The stored-credential refresh is mcpproxy's own request (internal/upstream/core/oauth_refresh.go:124-139,client.go:989-1010), so mcp-go's v1.3 binding doesn't cover it. That request also follows redirects. RFC 8414 issuer equality never runs either, because mcpproxy hands mcp-go an explicit metadata URL from its own preflight (internal/oauth/config.go:1385-1545). Existing rows are bound on first use, so nobody is forced to sign in again. - DCR omits
application_type. Confirmed (mcp-go v1.0.0RegisterClient). One correction, though: OIDC DCR defaults towebwhen the field is omitted, and a loopbackhttpredirect is thenativecase. The spec sendsnativefor loopback andwebonly for the non-loopback remote callback.
Not as described: the authorization-server role doesn't currently emit iss. mcplogin.BuildRedirect only orders the key if a caller passes one, and no caller does (internal/mcplogin/redirect.go:131-146). I've listed that as a Spec 132 follow-up.
Found while checking: a client_secret given through oauth.extra_params is copied into the browser-facing authorization URL (internal/upstream/core/oauth_stale_dcr_client.go:38-61). The spec covers that too.
Spec 135 PR-2a merged in #2090: mcpproxy now checks the RFC 9207 iss parameter on every OAuth authorization response before the code is exchanged.
Landed
- An expected issuer is recorded per login flow (discovered, configured or synthetic, plus
authorization_response_iss_parameter_supported) and registered atomically with the callback waiter for thatstate. - The decision runs in the callback handler before the page is chosen and before a provider
erroris reported, and runs again at the exchange.- A wrong or empty
iss, or a missing one when support is advertised, is refused asMCPX_OAUTH_ISSUER_MISMATCH. Nothing is sent to the token endpoint. - For a synthetic issuer (endpoint overrides) any
issis accepted, with a log line when it differs. - In strict mode the exchange uses mcp-go's
ProcessAuthorizationCallback.
- A wrong or empty
- Per-server opt-out
oauth.skip_issuer_validation(*bool, default off). It is request policy, not identity: it never clears a grant, moves the epoch or changes the server id. - New diagnostics code with a catalog entry, classifier case and error doc; feature-page section and configuration row.
Remaining
- PR-2:
- D0 metadata resolver,
SnapshotandGuardedTransport(T015–T017). - D3 discovery issuer equality, the same-origin metadata redirect policy and the policy-keyed cache (T023–T024). Until this lands,
Protectedis provisional and is neither logged nor stored. - D4 issuer-bound rows,
mix_up_protectedpersistence, TOFU and static-client provenance (T025–T030). - The
ISSUER_CHANGEDandMETADATA_ISSUER_MISMATCHcodes.
- D0 metadata resolver,
- PR-3:
- The
PATCHroute plus the Web UI and macOS editor fields for the opt-out. - The broker
isscheck (T033). - Mapping the mismatch to the
loginaction in health, Doctor, the Web UI and the tray. - Surfaces (T034–T036), e2e (T037) and the real-provider check (T038).
- The
- Known residual: a server with an empty
"oauth": {}block gets a new history id whenskip_issuer_validationis added, as anyoauthedit does today. The no-block case keeps its id.