GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — OAuth client: keep refresh_token on non-rotating refresh; restore same-origin issuer binding by maxisbey · Pull Request #2946 · modelcontextprotocol/python-sdk Conversation
Contributor
Two small follow-ups to #2936, from review on that PR. Motivation and ContextCarry an omitted Restore the SEP-2352 issuer stamp for same-origin fallback registrations. #2936 stopped recording the issuer when dynamic client registration fell back to the resource origin's How Has This Been Tested?
Breaking ChangesNone. Types of changes
Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsA refresh response may omit `refresh_token` when the AS does not rotate refresh tokens; the client is expected to keep using the previously issued one. The handler was overwriting the stored token wholesale, dropping the prior `refresh_token` and forcing a full re-authorization at the next expiry. Carry it forward alongside the existing scope carry-forward. Also stamp the SEP-2352 issuer on a same-origin fallback registration #2936 stopped recording the issuer when DCR fell back to the resource origin's `/register`, to avoid binding a registration to a PRM-advertised AS we never reached. That over-suppressed the legacy same-origin embedded-AS case (no PRM, root ASM at the resource origin without `registration_endpoint`), where the fallback `/register` is on the discovered issuer's own host and the binding was genuinely established. Restore the stamp when the fallback origin matches the discovered issuer's origin so a later AS migration still triggers discard and re-registration.
maxisbey
marked this pull request as ready for review
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't find any bugs — both changes look consistent with RFC 6749 §6 and the SEP-2352 binding semantics, and the new tests cover the carry-forward, rotation, and same-origin stamping cases — but since this adjusts OAuth credential-binding behavior it's worth a human pass. Extended reasoning...OverviewThis PR makes two small follow-up changes to the OAuth client ( Security risksThe changes are in OAuth client auth code. The refresh_token carry-forward only persists a token the client already held, and a returned (rotated) refresh_token still takes precedence — low risk. The issuer-stamp change broadens when stored client credentials are bound to a discovered issuer; the gate requires the fallback origin to equal the discovered issuer's origin, which matches the binding actually established. Stamping more precisely strengthens (rather than weakens) the SEP-2352 protection against silently reusing credentials after an AS migration. No injection, data-exposure, or auth-bypass vectors are apparent. Level of scrutinyAlthough the diff is small, well-reasoned, and well-tested, it modifies authorization/credential-binding logic in a widely used client library, which per policy warrants a human reviewer's sign-off rather than automated approval — especially the issuer-binding condition, which encodes nuanced SEP-2352 semantics that a maintainer familiar with that SEP should confirm. Other factorsThe bug-hunting pass found no issues. The new tests exercise the changed paths directly, and the PR description notes the existing cross-origin parametrized test still asserts the issuer is left unset when the fallback hits a different host, guarding against a regression in the opposite direction.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
maxisbey
enabled auto-merge (squash)
felixweinberger
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
This was referenced
This was referenced
9 of 11 tasks
maxisbey
added a commit
that referenced
this pull request
…r metadata Backport of the discovery half of #3398, together with the SEP-2352 credential binding that main has had since 2.0 and that change relies on (the parts of #2921, #2933, #2936, #2946 and #3181 it needs). The discovery step now knows which issuer the authorization server metadata must carry before fetching it: the PRM-advertised server, or on the 2025-03-26 no-PRM fallback the resource server's origin, which is what that well-known URL is built from (RFC 8414 section 3.3). On this line there was no issuer check at all; it now runs on both paths (`validate_metadata_issuer`, with `issuers_match`: exact, except that a root issuer with and without its trailing slash is the same server, which matters here because every parsed issuer renders with the slash). Stored client credentials gain the binding main has: the SDK records the issuer a registration was made with (`OAuthClientInformationFull.issuer`, never read from the registration response), and before any metadata is fetched a registration bound to a different issuer is discarded together with its tokens so the flow re-registers instead of presenting another server's credentials (`credentials_match_issuer`); newly registered clients are bound to the expected issuer when metadata for it was found and the registration actually went to that server. When no protected resource metadata location answers and one of them failed with a server error (or 429), the flow stops rather than reading that as "no such metadata". A 403 insufficient_scope step-up takes the same path as a 401: it discovers first when no metadata is held (extract_resource_metadata_from_www_auth also reads the `resource_metadata` hint from a 403 challenge) and then re-authorizes with the challenged scope; metadata already discovered in this process is reused as before. A 403 that is not a scope challenge is handed back to the caller instead of being retried unchanged. The conformance harness pinned on this line (0.1.13) still serves, in its two path-based authorization server scenarios, metadata whose `issuer` omits the advertised tenant path; those two scenarios are listed as expected failures until the pin moves past conformance 0.1.15, where the mock was corrected. Differences from the main change: - RFC 9207 `iss` validation is not included; the callback contract on 1.x stays `tuple[str, str | None]`. - 1.x has no SEP-2350 scope union, so a step-up asks for the challenged scope as it did before. - The root-slash allowance lives in `validate_metadata_issuer` itself (new on this line) rather than only on the legacy path.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |