Auth0 Refresh Token Rotation Automatic Reuse Detection Issue in iOS App
Last Updated:
Overview
An issue occurs with automatic reuse detection when enabling refresh token rotation for an iOS application, resulting in Failed Exchange of Rotating Refresh Token (ferrt) error logs. Application code bugs, such as calling the store method manually or creating multiple versions of the Credentials Manager, cause this issue. Resolve this by verifying the SDK version and ensuring the application code does not trigger breach detection. The tenant logs display ferrt events, even with a high leeway time.
Applies To
- Auth0
- Refresh Token Rotation
- Automatic Reuse Detection
- iOS Application
Cause
One of the following application code configurations causes the issue:
- Calling the
storemethod manually. - Creating multiple versions of the
CredentialsManager, such as from a computed property. - Calling the renew method from the Auth API client separately from the Credentials Manager.
- Exchanging a token older than the previous token. Only the previous token can be reused. If the application exchanges the second-to-last token, Auth0 triggers breach detection regardless of the leeway time. The tenant logs indicate this when the
tokenCounteris not exactly one less than thelatestCounter. An example of this log detail is as follows:
"details": {
"familyId": "<REDACTED>",
"tokenCounter": 4,
"latestCounter": 6
}
Solution
How is the automatic reuse detection issue resolved?
Verify the application code, check the Swift SDK version, and review the tenant logs to ensure the token exchange process functions correctly.
- Verify the Swift SDK version used for the iOS application. Auth0.Swift versions starting from v2.0.0 include a thread-safe Credentials Manager.
- Review the application code to ensure the
storemethod is not called manually. Review the Auth0.swift Pull Request 693 for more details. - Ensure the application code does not create multiple versions of the
CredentialsManager. - Verify the renew method from the Auth API client is not called separately from the Credentials Manager.
- Review the tenant logs to confirm the
tokenCounteris exactly one less than thelatestCounter. - If the issue persists and testing proves it is an SDK bug rather than an application code bug, create a reproducible example using the Quickstart sample application and submit a GitHub issue in the SDK repository.