CVE-2025-68158 — Vulnerability in authlib — CVE Details
Authlib has 1-click Account Takeover vulnerability
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.34%). Schedule for your next planned update.
Does your project use an affected authlib version?
Paste your requirements.txt to check it for CVE-2025-68158 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Security Advisory: Cache-Backed State Storage CSRF in Authlib
The Security Labs team at Snyk has reported a security issue affecting Authlib, identified during a recent research project.
The Snyk Security Labs team has identified a vulnerability that can result in a one-click account takeover in applications that utilize the Authlib library.
Description
Cache-backed state/request-token storage is not tied to the initiating user session, making CSRF possible for any attacker that possesses a valid state value (easily obtainable via an attacker-initiated authentication flow). When a cache is supplied to the OAuth client registry, FrameworkIntegration.set_state_data writes the entire state blob under _state_{app}_{state}, and get_state_data disregards the caller's session entirely. [1][2]
def _get_cache_data(self, key):
value = self.cache.get(key)
if not value:
return None
try:
return json.loads(value)
except (TypeError, ValueError):
return None
[snip]
def get_state_data(self, session, state):
key = f"_state_{self.name}_{state}"
if self.cache:
value = self._get_cache_data(key)
else:
value = session.get(key)
if value:
return value.get("data")
return None
authlib/integrations/base_client/framework_integration.py:12-41
Retrieval in authorize_access_token therefore succeeds for whichever browser presents that opaque value, and the token exchange proceeds with the attacker's authorization code. [3]
def authorize_access_token(self, **kwargs):
"""Fetch access token in one step.
:return: A token dict.
"""
params = request.args.to_dict(flat=True)
state = params.get("oauth_token")
if not state:
raise OAuthError(description='Missing "oauth_token" parameter')
data = self.framework.get_state_data(session, state)
if not data:
raise OAuthError(description='Missing "request_token" in temporary data')
params["request_token"] = data["request_token"]
params.update(kwargs)
self.framework.clear_state_data(session, state)
token = self.fetch_access_token(**params)
self.token = token
return token
authlib/integrations/flask_client/apps.py:57-76
This opens up an avenue for Login CSRF in applications that use cache-backed storage. Depending on the dependent application's implementation (e.g., whether it links accounts in the event of a login CSRF), this could lead to account takeover.
Proof of Concept
Consider a hypothetical application — AwesomeAuthlibApp. Assume that AwesomeAuthlibApp contains internal logic such that, when an already authenticated user performs a callback request, the application links the newly provided SSO identity to the existing user account associated with that request.
Under these conditions, an attacker can achieve account takeover within the application by performing the following actions:
- The attacker initiates an SSO OAuth flow but halts the process immediately before the callback request is made to AwesomeAuthlibApp.
- The attacker then induces a logged-in user (via phishing, a drive-by attack, or similar means) to perform a GET request containing the attacker's state value and authorization code to the AwesomeAuthlibApp callback endpoint. Because Authlib does not verify whether the state token is bound to the session performing the callback, the callback is processed, the authorization code is sent to the provider, and the account linking proceeds.
Once the GET request is executed, the attacker's SSO account becomes permanently linked to the victim's AwesomeAuthlibApp account.
Suggested Fix
Per the OAuth RFC [4], the state parameter should be tied to the user's session to prevent exactly such scenarios. One straightforward method of mitigating this issue is to continue storing the state in the session even when caching is enabled.
An alternative approach would be to hash the session ID (or another per-user secret derived from the session) into the cache key. This ensures the state remains stored in the cache while still being bound to the session of the user that initiated the OAuth flow.
Resources
Advisory Timeline
- First published January 8, 2026 (322 days ago).
- Last revised July 7, 2026 — 180 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "authlib>=1.6.6"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| authlib PyPI · Affected: 1.0.0, 1.0.1, 1.1.0, 1.2.0 (+15 more) | 1.6.6 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-352Cross-Site Request Forgery (CSRF)MITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 5.7 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N
References
- https://github.com/authlib/authlib/security/advisories/GHSA-fg6f-75jq-6523WEB
- https://nvd.nist.gov/vuln/detail/CVE-2025-68158ADVISORY
- https://github.com/authlib/authlib/commit/2808378611dd6fb2532b189a9087877d8f0c0489WEB
- https://github.com/authlib/authlib/commit/7974f45e4d7492ab5f527577677f2770ce423228WEB
- https://github.com/authlib/authlibPACKAGE
Frequently Asked Questions
- What is CVE-2025-68158?
- Authlib has 1-click Account Takeover vulnerability. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.7/10).
- How do I check if my project is affected by CVE-2025-68158?
- CVE-2025-68158 affects authlib. It has a 0.3% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2025-68158 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
This is a below-median EPSS score — only 20.2% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-96760CRITICAL
Authlib: empty signatures validation in JWS JSON deserialization
- CVE-2026-28490HIGH
Authlib Vulnerable to JWE RSA1_5 Bleichenbacher Padding Oracle
- CVE-2026-114615HIGH
Authlib incomplete algorithm-confusion fix permits HMAC forgery with prefixed public keys
- CVE-2026-28802HIGH
Authlib: Setting `alg: none` and a blank signature appears to bypass signature verification
- CVE-2026-114616HIGH
Authlib accepts an empty HMAC key, allowing JWS/JWT signature forgery (HS256/HS384/HS512)
- CVE-2026-114617MEDIUM
Authlib: ID token can disable its own nonce validation via the nonce_supported claim
- CVE-2026-114618MEDIUM
Authlib: Default JWT bearer grant accepts assertions for the wrong audience
- CVE-2026-114614LOW
Authlib: is_secure_transport() loopback exemption can be bypassed with a userinfo component, allowing cleartext-HTTP URLs to non-loopback hosts