[Fix] Replayed MCP OAuth refresh tokens leave the rest of the token family valid - #1237
Merged
mrubens merged 1 commit intoAug 12, 2026
Merged
Conversation
When a presented refresh token no longer resolves to an active session, check for the rotated: marker left by a prior rotation and revoke the whole session family (session record plus current token hash), per the OAuth 2.0 Security BCP. Previously the route's active-session pre-check returned invalid_grant before the reuse-detection path could run, so a replayed rotated token was rejected but the family's current token kept working. Unknown or malformed tokens still cannot revoke a live family.
Contributor
mrubens
approved these changes
Aug 12, 2026
mrubens
marked this pull request as ready for review
August 12, 2026 04:04
mrubens
deleted the
fix/mcp-refresh-token-replay-revocation-0v0fmqdabiz5y
branch
August 12, 2026 04:04
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.
Related issue
Found during an internal security review of the remote MCP OAuth flow shipped in #1219 — no external issue; this is internal Roomote work.
Why this PR exists
What changed
Replaying an already-rotated remote MCP OAuth refresh token now revokes the entire session family, per the OAuth 2.0 Security BCP refresh-token reuse-detection guidance. Previously the token route's refresh path called
getRemoteMcpRefreshSession()first, which returns null for an already-rotated token, and returnedinvalid_grantbefore ever reachingrotateRemoteMcpRefreshToken()— the only place the reuse-detection Lua branch ran. The result: the replayed token was rejected, but the family's current token kept working, so a stolen-token signal never disabled the remaining tokens.The route now falls through to a new
revokeRemoteMcpRefreshSessionOnReplayhelper when the presented token does not resolve to an active session. The helper only fires on therotated:<sessionId>marker left behind by a successful rotation (keyed by the SHA-256 of the presented token), then deletes the session record and its current token hash, killing every descendant token. Unknown, malformed, or still-current tokens cannot revoke a live family.How it was tested
mcp-remote-oauth.test.tsand the token route tests;tsc --noEmit, oxlint, and oxfmt are clean.invalid_grant, and the family's current token is then also rejected (previously it exchanged successfully). A garbage-token replay against a separate live family did not affect it.Checklist
[Fix],[Feat],[Improve],[Refactor],[Docs], or[Chore]followed by a user-facing descriptionpnpm lintandpnpm check-typespass locallypnpm changeset