OAuth 2.0 Refresh Token Rotation and Concurrent Request Limits
0 reputation · 24 Jan 2022, 14:15 UTC
0 reputation · 24 Jan 2022, 14:15 UTC
Implementing Refresh Token Rotation is a common security measure to mitigate the risk of token theft by issuing a new refresh token with every access token renewal. However, this mechanism introduces complexity when handling concurrent requests in high-latency environments or distributed systems.
When multiple asynchronous requests attempt to use the same refresh token simultaneously, the authorization server may trigger reuse detection. According to standard security patterns, reuse detection typically results in the immediate revocation of the entire token family to protect the user session.
There is uncertainty regarding the optimal configuration for a grace period that allows for network retry overlap without compromising the security benefits of rotation.
Industry-standard grace periods for refresh token reuse detection typically range from 10 to 60 seconds. This window allows for network latency, client-side retries, and race conditions in distributed systems without significantly expanding the window of opportunity for an attacker.
To prevent accidental session revocation while maintaining security, the authorization server should transition from a strict "one-time use" model to a "time-bound validity" model during the rotation event:
A system distinguishes legitimate concurrency from theft by analyzing the timing and the requested outcome:
| Scenario | Behavior | System Response |
|---|---|---|
| Race Condition | Multiple requests arrive within milliseconds or seconds of each other. | Return the same new token pair to all concurrent requests within the grace window. |
| Token Theft | A token is reused significantly after the first rotation occurred. | Immediate revocation of all tokens associated with that session (Family Revocation). |
To verify your grace period configuration, use a load-testing tool (such as k6 or JMeter) to execute the following scoped tests:
Diagnostic Requirement: To refine this recommendation, please specify if your authorization server uses a distributed cache (e.g., Redis) or a relational database for token state, as this affects the atomicity of the reuse detection check.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.