In the OAuth2 authentication process refresh tokens should be used only once. When the refresh_token
is used it will return a new access_token
and a new refresh_token
.
This is also in the RFC6819 spec:
5.2.2.3. Refresh Token Rotation
Refresh token rotation is intended to automatically detect and prevent attempts to use the same refresh token in parallel from different apps/devices. This happens if a token gets stolen from the client and is subsequently used by both the attacker and the legitimate client. The basic idea is to change the refresh token value with every refresh request in order to detect attempts to obtain access tokens using old refresh tokens. Since the authorization server cannot determine whether the attacker or the legitimate client is trying to access, in case of such an access attempt the valid refresh token and the access authorization associated with it are both revoked.
The OAuth specification supports this measure in that the token's response allows the authorization server to return a new refresh token even for requests with grant type "refresh_token".
Note: This measure may cause problems in clustered environments, since usage of the currently valid refresh token must be ensured. In such an environment, other measures might be more appropriate.
This also allows the authentication server to recognize that a refresh_token
was compromised, since it should only be used once. If a new renew request with the same refresh_token
comes in the authentication server knows there is something fishy going on.
I wonder what is the proper way for the server to deal with such a scenario though? My guess would be that at least all the access_tokens
for that particular client should be invalidated directly.
How do OAuth2 servers usually deal with multiple requests using the same refresh_token
?