Summary
OAuth state management relies on a shared state cookie that can be overwritten by concurrent authentication attempts.
Opening multiple OAuth flows simultaneously can invalidate earlier flows and cause authentication failures.
Affected Files
Root Cause
The OAuth state value is stored in a shared cookie without isolation by provider or authentication attempt.
Starting a second OAuth flow replaces the previous state value.
When the first flow returns, state validation fails because the stored value no longer matches.
Reproduction
- Open GitHub OAuth in one tab.
- Before completing it, open Google OAuth in another tab.
- Complete the first OAuth flow.
- Observe state validation failures or incorrect authentication behavior.
Expected Behavior
Independent OAuth flows should maintain isolated state values.
Actual Behavior
Concurrent authentication attempts overwrite one another.
Why This Is Difficult To Detect
Single-tab testing behaves correctly.
The issue appears only under realistic multi-tab usage.
Production Impact
- Failed logins
- Invalid OAuth callbacks
- User confusion
- Authentication instability
Suggested Fix
Scope OAuth state storage by provider and authentication attempt.
Severity
High
Summary
OAuth state management relies on a shared state cookie that can be overwritten by concurrent authentication attempts.
Opening multiple OAuth flows simultaneously can invalidate earlier flows and cause authentication failures.
Affected Files
Root Cause
The OAuth state value is stored in a shared cookie without isolation by provider or authentication attempt.
Starting a second OAuth flow replaces the previous state value.
When the first flow returns, state validation fails because the stored value no longer matches.
Reproduction
Expected Behavior
Independent OAuth flows should maintain isolated state values.
Actual Behavior
Concurrent authentication attempts overwrite one another.
Why This Is Difficult To Detect
Single-tab testing behaves correctly.
The issue appears only under realistic multi-tab usage.
Production Impact
Suggested Fix
Scope OAuth state storage by provider and authentication attempt.
Severity
High