Learn how to use Attack Protection with Custom Token Exchange.
Custom Token Exchange (CTE) is currently available in Early Access for all Auth0 Enterprise and B2B Pro customers. By using this feature, you agree to the applicable Free Trial terms in Okta’s Master Subscription Agreement. To learn more about Auth0’s product release cycle, read Product Release Stages. To learn more about subscription types, review the Auth0 pricing page.
To protect against spoofing and replay attacks, which involve unauthorized attempts to compromise or reuse a subject_token, Custom Token Exchange supports Suspicious IP Throttling. This enables you to indicate in your Actions code when a subject token is invalid, allowing Auth0 to count the number of failed attempts sent from that external IP.When the number of failed attempts from an IP address reaches a pre-configured threshold, Auth0 blocks traffic for a Custom Token Exchange request coming from that IP with the following error:
Report incorrect code
Copy
Ask AI
HTTP/1.1 429 Too Many RequestsContent-Type: application/json{ "error": "too_many_attempts", "error_description": "We have detected suspicious login behavior and further attempts will be blocked. Please contact the administrator."}
The IP address can start making requests again after a configured period of time.We recommend you use Suspicious IP Throttling for all Custom Token Exchange use cases, especially with native applications and single-page applications (SPAs). Because non-confidential applications like native applications and SPAs can’t securely store secrets to authenticate themselves, attackers can more easily re-use stolen or leaked subject tokens.
To implement Suspicious IP Throttling protection, use api.access.rejectInvalidSubjectToken in your Actions code whenever the received subject token does not pass strong validation.
Suspicious IP Throttling is activated by default for Auth0 tenants. When activated, the default settings for Custom Token Exchange will be applied:
Threshold: 10. Maximum number of failed attempts for an IP address.
Throttling rate: 6 per hour. One additional attempt will become available after every 10 minutes until the threshold is refilled.
Use the following PATCH request to update the pre-custom-token-exchange stage with the needed values. Note that the rate is the interval of time in milliseconds at which new attempts are granted.