Repository navigation
Conversation
…extprotocol#3077) Signed-off-by: bbdu3 <ergouyang854@gamil.com>
🦋 Changeset detectedLatest commit: 96a7000 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
…#3077) Signed-off-by: bbdu3 <ergouyang854@gamil.com>
|
Enforcing RFC 9728 §3.3 resource identity validation directly closes the path containment gap in PRM discovery (#3077). Replacing checkResourceAllowed path containment with exact identifier matching ensures that metadata returned for a sub-resource cannot claim a broader parent resource or drop query parameters during authorization and token exchange. A few key points verified in the implementation:
|
|
Thank you for this PR. The change fixes the problem in my issue ( #3077 ). I am not a TypeScript developer, so I did not examine all of the code. Best notify a CODEOWNER that this change can break existing clients when merged. For example, discoverOAuthProtectedResourceMetadata is public, and now it can throw a mismatch error. The changeset identifies a patch release. Please examine if a minor release is better. |
Summary
The client previously validated Protected Resource Metadata (PRM) using
checkResourceAllowed, which checks same-origin path containment. This allowed metadata for a child endpoint to claim a parent resource, and that broader resource was then sent in both authorization and token requests. The comparison also ignored query parameters.RFC 9728 §3.3 requires the returned resource to match the identifier associated with the discovery request. The comparison target depends on how discovery occurred:
This change validates PRM identity before its authorization-server information is used, preserves legitimate root fallback, and applies the same validation to cached metadata.
Fixes #3077.
Changed
Validate identity before using PRM
authorization_servers, discovering the authorization server, or persisting discovery state.selectResourceURLcalls.Preserve discovery semantics
Validate cached metadata
resourceMetadataRootFallbackdiscovery-state marker.Preserve valid OAuth behavior
validateResourceURLselection after PRM identity validation, with the original server URL passed to the hook.checkResourceAllowedpath-containment helper unchanged.Compatibility: Previously accepted parent-path resources, mismatched queries, and differing trailing path slashes are now rejected. Providing
validateResourceURLno longer bypasses PRM identity validation. These changes are documented in the OAuth guide and a client patch changeset.Test
Regression coverage
Added 26 regression tests covering:
Running these tests against the original implementation produced 22 failures and 4 passes. All 26 pass with the fix.
Existing regression suites
git diff --checkpassed.Validated by Node.js 24.18.0 and pnpm 10.26.1.