Description
FastAPI Users allows users to quickly add a registration and authentication system to their FastAPI project. Prior to version 15.0.2, the OAuth login state tokens are completely stateless and carry no per-request entropy or any data that could link them to the session that initiated the OAuth flow. `generate_state_token()` is always called with an empty `state_data` dict, so the resulting JWT only contains the fixed audience claim plus an expiration timestamp. On callback, the library merely checks that the JWT verifies under `state_secret` and is unexpired; there is no attempt to match the state value to the browser that initiated the OAuth request, no correlation cookie, and no server-side cache. Any attacker can hit `/authorize`, capture the server-generated state, finish the upstream OAuth flow with their own provider account, and then trick a victim into loading `.../callback?code=<attacker_code>&state=<attacker_state>`. Because the state JWT is valid for any client for \~1 hour, the victim’s browser will complete the flow. This leads to login CSRF. Depending on the app’s logic, the login CSRF can lead to an account takeover of the victim account or to the victim user getting logged in to the attacker's account. Version 15.0.2 contains a patch for the issue.
Problem types
CWE-285: Improper Authorization
CWE-352: Cross-Site Request Forgery (CSRF)
Product status
References
github.com/...-users/security/advisories/GHSA-5j53-63w8-8625
github.com/...ommit/7cf413cd766b9cb0ab323ce424ddab2c0d235932
github.com/...aead3974a0b5b158/fastapi_users/router/oauth.py
github.com/...aead3974a0b5b158/fastapi_users/router/oauth.py
Data based on CVE®. Copyright © 1999-2025, The MITRE Corporation. All rights reserved.