Repository navigation
Conversation
Keep the release/1.x OAuth client fail-closed when PKCE support cannot be verified from authorization server metadata. Retain the historical no-metadata fallback only behind an explicit process-wide compatibility switch, with a warning and deployment requirements. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport #1700 (7369a26) to
release/1.x, with an explicitly approved 1.x security-default adaptation for metadata-free legacy servers.The first commit preserves #1700's production change and four regression tests, with cherry-pick attribution. Two test-file conflicts were resolved without importing unrelated scope-selection/offline-access changes. The second commit adds the opt-in compatibility switch described below.
S256incode_challenge_methods_supported; no longer synthesize that field for discovered documents.This supersedes the proposed state-validation backport #1948 with a focused 1.x approach, rather than importing the callback architecture from #1605/#1726.
Deliberate 1.x security-default adaptation
Original #1700 retains the MCP 2025-03-26 default-endpoint fallback when protected resource metadata is unavailable and authorization server metadata discovery finds no usable document. That fallback synthesizes
S256, which does not establish PKCE support. Because the existing 1.x callback API returns only a code and cannot provide response state for SDK validation, this backport makes that fallback disabled by default.ModelContextProtocol.Authentication.AllowLegacyOAuthMetadataFallbackis a default-off, process-wide AppContext switch. When absent orfalse, the client rejects that metadata-free path before requesting an authorization code or exchanging tokens. A host can explicitly restore only the original eligible fallback at startup:The switch retains the original
resourceUri is nullguard,/authorize,/token, and/registerdefaults, and unchangedS256challenge/verifier behavior. It cannot bypass discovered metadata that omitsS256, and the client logs a warning whenever it actually uses this unverified fallback.Enabling the switch is not verification of PKCE support and does not add state validation. Hosts must independently establish that a trusted deployment correctly enforces PKCE, including downgrade defenses. This is not a per-server allowlist: it affects all OAuth clients in the process. Do not enable it in a process that also connects to untrusted authorization servers or toggle it around individual requests.
The API remarks, transport guide, and protected-client sample documentation explain configuration and security requirements. The conformance client opts in only for its trusted
auth/2025-03-26-oauth-endpoint-fallbackfixture; other scenarios retain the secure default.Security rationale
RFC 9700 §2.1 and §4.7.1 permit relying on PKCE for CSRF protection when authorization-server support has been ensured. #1700 strengthens that prerequisite for existing code-only callbacks without importing a new callback API.
This verifies advertised support, not the server's actual verifier or downgrade implementation. Authorization servers must correctly enforce PKCE, including the §4.8.2 downgrade defenses. This is not a claim that state validation is universally unnecessary or that this approach is security-equivalent to every state-validation design.
Release note
Compatibility tightening: OAuth authentication now requires discovered authorization server metadata to advertise
S256PKCE support, even if the server implements PKCE without advertising it. Metadata-free legacy authentication is also rejected by default. Trusted 2025-03-26 deployments with independently established PKCE support can explicitly restore the historical no-metadata fallback using the process-wideModelContextProtocol.Authentication.AllowLegacyOAuthMetadataFallbackAppContext switch; enabling it emits a warning and never bypasses PKCE validation of discovered metadata.Validation
dotnet build --no-restore --nologo --verbosity quiet: zero warnings/errors.Local process tests used a test-process-only current-directory PATH entry for Windows executable lookup. Pinned npm dependencies were installed by the existing test harness. No machine-wide settings or repository test behavior were weakened.