Repository navigation
fix(auth): don't revive a session that ended during a refresh - #198
Merged
Merged
Conversation
refresh_session read the session, then rotated it in a second step, so a sign-out, password change or passkey removal landing in between left a new token for an ended session. Rotating now fails when the old token is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ
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.
Requested by Adeel · project thread
Description
Before:
auth.refresh_sessionread the login session, checked the account, and then rotated it in a separate step (UPDATE the old row, CREATE the new one). If a sign-out, password change, passkey removal or reuse detection deleted the session in between, the CREATE brought it back under the new token.session_activethen stayed true for a session that should have ended. Someone holding a stolen refresh token and refreshing repeatedly could hit that gap.After: the rotation is one transaction that fails when the old row is no longer there, and the refresh answers "session ended". An ordinary refresh behaves as before.
Motivation and Context
This answers threat-model question Q39: a token minted while its grant or session is being revoked must not outlive the revocation (part of P-AUTH-REQ). OAuth grants and API tokens already held. This was the one race left.
Steps to reproduce (if appropriate):
test_a_refresh_racing_a_sign_out_does_not_bring_the_session_backsigns out between the read and the rotation. It fails on main and passes here. The other auth, account and passkey tests still pass.Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ
Generated by Claude Code