Fix: Transaction-keyed cookies to prevent multi-tab OAuth state race …#231
Open
tanya732 wants to merge 1 commit into
Open
Fix: Transaction-keyed cookies to prevent multi-tab OAuth state race …#231tanya732 wants to merge 1 commit into
tanya732 wants to merge 1 commit into
Conversation
kishore7snehil
requested changes
May 21, 2026
| * Max-Age for transaction cookies in seconds (10 minutes). | ||
| * Orphaned cookies from abandoned login flows will auto-expire. | ||
| */ | ||
| static final int TRANSACTION_COOKIE_MAX_AGE = 600; |
kishore7snehil
requested changes
May 21, 2026
| @@ -81,27 +81,29 @@ public void shouldSetAudience() { | |||
| @Test | |||
There was a problem hiding this comment.
Could we add a few more tests to strengthen coverage of the multi-tab scenario for nonce?
- A nonce isolation test (similar to shouldIsolateMultipleTransactions but for nonce) - store two nonces keyed by different states, retrieve each independently, confirm they don't interfere.
- A nonce preference test (similar to shouldPreferTransactionKeyedOverLegacy but for nonce) - when both com.auth0.nonce.stateA and legacy com.auth0.nonce exist, confirm the transaction-keyed one wins.
- An end-to-end multi-tab test that combines state + nonce together - two concurrent login flows storing their cookies, then each callback retrieves its own state and nonce correctly without affecting the other.
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.
Summary
com.auth0.state.{state}), isolating each login flowcom.auth0.state,com.auth0.nonce) for in-flight transactions during rolling upgradesProblem
The SDK stored state and nonce in fixed-name cookies (
com.auth0.state,com.auth0.nonce). When a user opens multiple tabs, each login overwrites the previous tab's cookie. On callback,getOnce()destructively reads and deletes the cookie — if the "wrong" tab's callback arrives first, it consumes the other tab's state, causing both flows to fail.This mirrors a fix already shipped in auth0.js and auth0-server-python.
Changes
StorageUtils.javatransactionStateKey(state),transactionNonceKey(state), andTRANSACTION_COOKIE_MAX_AGEconstantTransientCookieStore.javastoreState/storeNoncenow write transaction-keyed cookies;getState/getNoncelook up by state param with legacy fallbackAuthorizeUrl.javastatetostoreNonce()(nonce cookie is keyed by state, not nonce)RequestProcessor.javastatetogetVerifiedTokens()→getNonce()