CVE-2026-118669
OAuthLib 4.0‑pre allows token grants to be authorized using a different client_id.
- CVSS 8.4
- CWE-863
- Authentication, Authorization, and Session Management
- Remote
OAuthLib is an implementation of the OAuth request-signing logic for Python 3.6+. Prior to 4.0.0, the client_credentials and Resource Owner Password Credentials token grant handlers can authenticate request.client as one confidential client while retaining an attacker-supplied request.client_id for validate_grant_type and validate_scopes. A lower-privilege authenticated client can therefore cause grant and scope authorization to use another client's identity when an application validator relies on the documented client_id argument, potentially issuing tokens with unauthorized grants or scopes. Validators that authorize exclusively from request.client may not be affected. This issue is fixed in version 4.0.0.
- CWE
- CWE-863
- CVSS base score
- 8.4
- Published
- 2026-10-28
- OWASP
- A07 Identification and Authentication Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Privilege Escalation
- Accessibility scope
- Remote
- Impact
- Privilege Escalation
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade OAuthLib to version 4.0.0 or later.
Vulnerable code sample
from oauthlib.oauth2 import RequestValidator
class MyValidator(RequestValidator):
# VULNERABLE: uses attacker‑supplied client_id for grant validation
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
# client_id comes from the request parameters, not the authenticated client
allowed = self._allowed_grants.get(client_id, [])
return grant_type in allowed
def validate_scopes(self, client_id, scopes, client, request):
# client_id again taken from request parameters
allowed_scopes = self._client_scopes.get(client_id, [])
return all(s in allowed_scopes for s in scopes)
# placeholder data
_allowed_grants = {
"confidential_app": ["client_credentials", "password"],
"lowpriv_app": ["authorization_code"]
}
_client_scopes = {
"confidential_app": ["read", "write", "admin"],
"lowpriv_app": ["read"]
}Patched code sample
from oauthlib.oauth2 import RequestValidator
class MyValidator(RequestValidator):
# FIX: validates against the authenticated client object, not the supplied client_id
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
# Use the authenticated client object's identifier
auth_client_id = request.client.client_id
allowed = self._allowed_grants.get(auth_client_id, [])
return grant_type in allowed
def validate_scopes(self, client_id, scopes, client, request):
# Use the authenticated client object's identifier
auth_client_id = request.client.client_id
allowed_scopes = self._client_scopes.get(auth_client_id, [])
return all(s in allowed_scopes for s in scopes)
# placeholder data
_allowed_grants = {
"confidential_app": ["client_credentials", "password"],
"lowpriv_app": ["authorization_code"]
}
_client_scopes = {
"confidential_app": ["read", "write", "admin"],
"lowpriv_app": ["read"]
}Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Organized validate_client functions for all grant to avoid mistake in grnat implementation (oauthlib/oauthlib)
oauthlib/oauth2/rfc6749/grant_types/authorization_code.py · AuthorizationCodeGrant.validate_token_request,oauthlib/oauth2/rfc6749/grant_types/base.py,oauthlib/oauth2/rfc6749/grant_types/base.py · GrantTypeBase.validate_client_authentication,oauthlib/oauth2/rfc6749/grant_types/client_credentials.py · ClientCredentialsGrant.validate_token_request,oauthlib/oauth2/rfc6749/grant_types/refresh_token.py · RefreshTokenGrant.validate_token_request,oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py · ResourceOwnerPasswordCredentialsGrant.create_token_response,oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py · ResourceOwnerPasswordCredentialsGrant.validate_token_request,oauthlib/oauth2/rfc6749/request_validator.py · RequestValidator.authenticate_client_id,oauthlib/oauth2/rfc6749/request_validator.py · RequestValidator.validate_client_id,oauthlib/oauth2/rfc8628/grant_types/device_code.py · DeviceCodeGrant.validate_token_request
Cite this entry
@misc{vaitp:cve2026118669,
title = {{OAuthLib 4.0‑pre allows token grants to be authorized using a different client_id.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-118669},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-118669/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
