Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh token can be used INDEFINITELY and UNLIMITED times without any restrictions #1901

Open
godlin-gh opened this issue Jan 3, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@godlin-gh
Copy link

Describe the bug

I discovered that refresh tokens can always be used, even after multiple repeated uses, and even after exceeding the project's configured refresh token reuse interval (default is 10 seconds).

To Reproduce

Use the following command without time or usage limitations:

curl -X POST https://{project-id}.supabase.co/auth/v1/token?grant_type=refresh_token \
-H "apikey: {apikey}" \
-H "Content-Type: application/json" \
-d '{"refresh_token":"{refresh_token}"}'
@godlin-gh godlin-gh added the bug Something isn't working label Jan 3, 2025
@hf
Copy link
Contributor

hf commented Jan 3, 2025

@hf hf transferred this issue from supabase/supabase Jan 3, 2025
@hf
Copy link
Contributor

hf commented Jan 3, 2025

Anyway a refresh token can be re-used within 10 seconds of last use. So if you re-use it continuously every 9 seconds, it will continue to work.

This is intentional per document linked above.

https://github.com/supabase/auth/blob/master/internal/api/token_refresh.go#L187-L188

@godlin-gh
Copy link
Author

I re-use it at 02:53 UTC, but I can still re-use it now (19:48+08:00 which is equivalent to 11:48 UTC)

image image

@hf
Copy link
Contributor

hf commented Jan 3, 2025

Then it should be falling under this exemption

If the parent of the currently active refresh token for the user's session is being used, the active token will be returned.

Can you confirm?

@godlin-gh
Copy link
Author

Yes,I am using the 'the parent of the currently active refresh token'...

Let me take another careful look at the documentation, thanks for your reply

@hf
Copy link
Contributor

hf commented Jan 3, 2025

In any case, we can't really adjust the algorithm to be more strict as that causes early session termination issues at scale (only visible over 100k+ users with high activity) as some of these edge cases happen infrequently (but still a lot).

If there's any other finding please email [email protected] as these findings might constitute a security problem so we should have a proper disclosure procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants