Skip to content

fix(auth): retain state until issuer validation - #1167

Merged
DaleSeo merged 1 commit into
modelcontextprotocol:mainfrom
stevenlee-oai:dev/stevenlee/rmcp-delete-state-after-issuer-validation
Aug 12, 2026
Merged

fix(auth): retain state until issuer validation#1167
DaleSeo merged 1 commit into
modelcontextprotocol:mainfrom
stevenlee-oai:dev/stevenlee/rmcp-delete-state-after-issuer-validation

Conversation

@stevenlee-oai

Copy link
Copy Markdown
Contributor

Summary

  • validate the RFC 9207 authorization response issuer before deleting the stored authorization state
  • keep valid callbacks one-time by deleting state immediately after issuer validation succeeds
  • add regression coverage for missing and mismatched required iss

Why

The returned OAuth state is only the lookup key. An unknown state loads no StoredAuthorizationState and deletes nothing. But an authorization server that received the authorization request can send a callback with the correct state and a forged or missing required iss. Previously RMCP loaded and deleted the real stored state before issuer validation rejected that callback. That consumed the PKCE verifier, so the later legitimate callback could not complete.

The new order is load state, validate iss, delete state, then exchange the code. Invalid issuer callbacks do not reach the token endpoint or consume state; a valid callback still consumes the one-time state before token exchange.

Tests

  • cargo fmt --check
  • cargo test -p rmcp --lib --features auth invalid_issuer_does_not_consume_authorization_state
  • cargo test -p rmcp --lib --features auth

@github-actions github-actions Bot added T-core Core library changes T-transport Transport layer changes labels Aug 12, 2026
@stevenlee-oai
stevenlee-oai marked this pull request as ready for review August 12, 2026 04:01
@stevenlee-oai
stevenlee-oai requested a review from a team as a code owner August 12, 2026 04:01

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @stevenlee-oai!

@DaleSeo
DaleSeo merged commit a50a73f into modelcontextprotocol:main Aug 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants