Repository navigation
chore(deps): update dependency oauthlib to v4 [security] - #773
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/pypi-oauthlib-vulnerability
branch
from
October 31, 2026 09:23
8553edd to
c258a51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==3.3.1→==4.0.0Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
OAuthLib: Bearer token can be retrieved as long as client knows a valid client ID for device workflow
CVE-2026-49272 / GHSA-3jp2-3mrg-2vxc
More information
Details
Summary
A call to the token endpoint with a grant type of
"urn:ietf:params:oauth:grant-type:device_code"and a bogusdevice_codeis able to get a bearer token as long as they know a valid client ID enabled for the device workflow.Details
Section 3.4 of the RFC 8628 spec says that the token endpoint should take in
device_codeas a required parameter.DeviceCodeGrant.validate_token_requestdoes not perform any validation ofdevice_code.DeviceCodeGrant.validate_token_requestshould be validating thatdevice_codewas passed in as a parameter and that it is valid, similar to howAuthorizationCodeGrant.validate_token_requestdoes the checks here and here.I would like to propose a new method be added to
RequestValidatorcalledvalidate_device_codethat is similar to thevalidate_codemethod and is called inside ofDeviceCodeGrant.validate_token_request.PoC
Create an implementation of
RequestValidation.authenticate_clientthat returnsTrueif the client'sclient_typeis"public". You would find yourself in this scenario because there's another issue withDeviceCodeGrant.validate_token_requestwhere it doesn't properly handle public clients (see https://github.com/oauthlib/oauthlib/issues/919).Create a client that has a
client_typeof"public"and set it'sgrant_typeto"urn:ietf:params:oauth:grant-type:device_code".With this implementation of
RequestValidation.authenticate_clientdone, use that validator for your token endpoint. Call the token endpoint with a body ofYou now have a bearer token for the client without a valid
device_code.Impact
Anyone using the RFC 8628 device workflow in oauthlib that doesn't realize the
device_codeparameter is not being validated.Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
OAuthLib: Token grants can use attacker-supplied client_id for authorization after authenticating a different client
CVE-2026-118669 / GHSA-7984-qgvg-3j9c
More information
Details
Summary
OAuthlib's token grant handlers can authenticate one client while authorizing the grant type and requested scopes using a different, attacker-supplied
client_idfrom the request body.In affected token grant flows,
authenticate_client(request)setsrequest.clientto the authenticated client object, but OAuthlib does not requirerequest.client_idto matchrequest.client.client_id. If the request body already containsclient_id=..., OAuthlib keeps that value and passes it tovalidate_grant_type()andvalidate_scopes().As a result, an authenticated low-privilege confidential client can authenticate as itself, submit another client's
client_idin 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 CredentialsThe issue is relevant to OAuthlib provider deployments where:
client_idargument passed by OAuthlib invalidate_grant_type()orvalidate_scopes(), as theRequestValidatorAPI is designed to support.Deployments whose validators ignore the
client_idargument and authorize only fromrequest.clientmay not be affected.Details
Requestparses query and body parameters into request attributes, includingclient_id:The
RequestValidator.authenticate_client()contract requires the integrator to authenticate the client and setrequest.client:For the
client_credentialsgrant, OAuthlib authenticates the client, verifies thatrequest.clienthas aclient_id, then performs grant and scope validation before normalizingrequest.client_idfromrequest.client.client_id:The problematic order is:
Because OAuthlib only fills
request.client_idwhen it is missing, an attacker-supplied body value such asclient_id=highsurvives even whenrequest.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-L176The 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_idfromrequest.client.client_id:This creates an inconsistent identity state:
OAuthlib then calls application authorization hooks with both values, but uses the attacker-controlled
request.client_idas the first-classclient_idargument.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
RequestValidatorAPI and authorizes by theclient_idargument.Concrete impact can include:
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:repro.py:Run:
python -m venv .venv . .venv/bin/activate python -m pip install -r requirements.txt python repro.pyExpected result:
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-suppliedclient_id=high.Suggested Remediation
After client authentication succeeds, OAuthlib should reject a token request if an explicit request
client_idis present and does not matchrequest.client.client_id.For authenticated confidential-client flows, a safer invariant is:
This should happen before
validate_grant_type()andvalidate_scopes()are called.Reporters:
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:H/SI:H/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Oauthlib : Unsafe JSONP callback injection in RevocationEndpoint allows arbitrary JavaScript response generation
CVE-2026-49264 / GHSA-hj66-6f7g-4r5v / PYSEC-2026-4113
More information
Details
Summary
When
enable_jsonp=True, oauthlib'sRevocationEndpointreflects the user-suppliedcallbackparameter directly into JavaScript response bodies on both success and error paths without validating that it is a legal JSONP callback name. This allows arbitrary JavaScript response generation instead of a restricted function call, making the documented JSONP revocation feature unsafe for browser-based JSONP consumption when attackers can influencecallback.Details
The issue is in
oauthlib/oauth2/rfc6749/endpoints/revocation.py.When
enable_jsonp=Trueis passed to theRevocationEndpointconstructor, two code paths wrap the response body using the user-suppliedrequest.callbackparameter:The
request.callbackvalue comes from HTTP request parameters, either the query string or POST body, via theRequestclass inoauthlib/common.py(lines 394-395), which merges query and body parameters into_params. Any value the client sends ascallbackis used verbatim.There is no validation of any kind on the callback parameter:
A safe JSONP implementation must validate that the callback is a legal JavaScript function name (e.g., matching
^[a-zA-Z_$][a-zA-Z0-9_$.]*$). Without this, the attacker controls the JavaScript code returned in the response body. This is the standard mitigation used by jQuery, Express.js, Google APIs, and other major JSONP implementations.How the injection works:
An attacker sends a revocation request with a crafted callback value:
The server responds with:
This is syntactically valid JavaScript.
alert(document.cookie)executes as a statement, and//comments out the rest of the line. The attacker has full control over the code that appears before the//.Execution context and attack surface:
JSONP works by having a browser load a remote script via
<script src="...">. The loaded script executes in the origin of the including page, not the remote server. This means a<script src="https://auth.example.com/revoke?token=x&callback=payload">tag onevil.comwould execute the payload inevil.com's context, not the auth server's context.The impact comes from client-side integrations that consume this endpoint as trusted JSONP. If a legitimate OAuth client includes
<script src>pointed at the revocation endpoint and an attacker can influence the callback value (e.g., via query parameter injection, a reflected value, or a man-in-the-middle downgrade), the attacker controls what code runs in the client application's origin. The authorization server becomes a source of attacker-controlled JavaScript that client applications trust and execute.Note: the
enable_jsonpparameter defaults toFalse, so only deployments that explicitly opt in are affected. However, this is a supported, documented library feature, not a debug flag. The client-side library includesprepare_token_revocation_request()with an explicitcallbackparameter (oauthlib/oauth2/rfc6749/parameters.py, line 174), and the documentation shows JSONP revocation as a use case (oauthlib/oauth2/rfc6749/clients/base.py, lines 351-358). The existing test suite tests JSONP callback reflection with a benign value (test_revocation_endpoint.py, lines 91-101) but does not test for injection. Deployments that enable JSONP typically do so to support older browsers or cross-origin revocation from JavaScript clients, these are exactly the environments most sensitive to script injection.PoC
Requirements: Python 3.x with oauthlib installed (
pip install oauthlib).Expected output:
Both paths reflect the attacker's payload verbatim into the response body.
Impact
Any oauthlib-based authorization server that enables JSONP on the revocation endpoint (
enable_jsonp=True) returns attacker-controlled JavaScript in its response body.Any page or application that loads this endpoint's response as JSONP and exposes attacker influence over the
callbackparameter will execute attacker-controlled code in its own origin. If a legitimate OAuth client uses JSONP revocation (as documented by oauthlib's client-side API) and an attacker can influence the callback value, the attacker controls what code runs in the client application, including access to the client page's DOM and any data normally accessible to scripts running in that origin.The JSONP feature is intended for legacy cross-origin browser support. Deployments that need it are typically JavaScript-heavy clients, exactly the environment most sensitive to script injection.
Affected versions: oauthlib >= 0.6.1 through 3.3.1 (current) and master. The unsanitized callback has been present since the revocation endpoint was first introduced in 2013 (commit
da775de). Theenable_jsonpgate was added in 2014 (commitb85f89a) but no validation of the callback value was ever added.Suggested fix
Validate the
callbackparameter against a strict pattern for legal JavaScript identifiers before using it in the response. Reject or ignore values that do not match:This is the standard mitigation for JSONP callback injection and is the approach used by jQuery, Express.js, and Google APIs. It ensures only syntactically valid function names like
package.hello_worldare accepted, while blocking payloads likealert(document.cookie)//.As a secondary hardening measure, when JSONP is enabled, the response should set
Content-Type: application/javascript(notapplication/jsonor empty) to ensure correct browser handling. Currently the success path returns no Content-Type at all, and the error path returnsapplication/json.Alternatively, if JSONP is no longer considered a necessary feature, consider deprecating and removing the
enable_jsonpoption entirely. CORS is now supported by all modern browsers and is the standard mechanism for cross-origin API access.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Oauthlib: Timing Attack Vulnerability in PKCE code_verifier Comparison (CWE-208)
CVE-2026-49265 / GHSA-xpv3-w29h-x7cv / PYSEC-2026-4114
More information
Details
Summary
A timing side-channel vulnerability exists in the PKCE (RFC 7636) implementation
of the Authorization Code Grant flow. The
code_challenge_method_plainfunctionuses Python's standard
==operator for string comparison instead of aconstant-time comparison function, potentially allowing timing-based attacks.
Affected Component
oauthlib/oauth2/rfc6749/grant_types/authorization_code.pycode_challenge_method_plain,code_challenge_method_s256Technical Details
Python's
==operator uses short-circuit evaluation when comparing strings:Falseimmediately if lengths differThis means comparison time varies linearly with the length of the common prefix
between the attacker-supplied verifier and the stored challenge, creating a
measurable timing oracle.
Proof of Concept
Tested locally against oauthlib source (network jitter eliminated to isolate
pure Python execution time):
B+A*49)A*49 +B)The ~37ms delta over 10M iterations corresponds to nanosecond-level differences
per call, which are statistically exploitable under controlled conditions.
Attack Scenario
authorization_codevia Custom URI Scheme Hijackingcode_verifier/tokenendpoint measuring response timescode_verifiercharacter by characterRecommended Fix
Replace
==withhmac.compare_digest()for constant-time comparison:cr: Elvin Latifli
Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Oauthlib : Unsafe JSONP callback injection in RevocationEndpoint allows arbitrary JavaScript response generation
CVE-2026-49264 / GHSA-hj66-6f7g-4r5v / PYSEC-2026-4113
More information
Details
Summary
When
enable_jsonp=True, oauthlib'sRevocationEndpointreflects the user-suppliedcallbackparameter directly into JavaScript response bodies on both success and error paths without validating that it is a legal JSONP callback name. This allows arbitrary JavaScript response generation instead of a restricted function call, making the documented JSONP revocation feature unsafe for browser-based JSONP consumption when attackers can influencecallback.Details
The issue is in
oauthlib/oauth2/rfc6749/endpoints/revocation.py.When
enable_jsonp=Trueis passed to theRevocationEndpointconstructor, two code paths wrap the response body using the user-suppliedrequest.callbackparameter:The
request.callbackvalue comes from HTTP request parameters, either the query string or POST body, via theRequestclass inoauthlib/common.py(lines 394-395), which merges query and body parameters into_params. Any value the client sends ascallbackis used verbatim.There is no validation of any kind on the callback parameter:
A safe JSONP implementation must validate that the callback is a legal JavaScript function name (e.g., matching
^[a-zA-Z_$][a-zA-Z0-9_$.]*$). Without this, the attacker controls the JavaScript code returned in the response body. This is the standard mitigation used by jQuery, Express.js, Google APIs, and other major JSONP implementations.How the injection works:
An attacker sends a revocation request with a crafted callback value:
The server responds with:
This is syntactically valid JavaScript.
alert(document.cookie)executes as a statement, and//comments out the rest of the line. The attacker has full control over the code that appears before the//.Execution context and attack surface:
JSONP works by having a browser load a remote script via
<script src="...">. The loaded script executes in the origin of the including page, not the remote server. This means a<script src="https://auth.example.com/revoke?token=x&callback=payload">tag onevil.comwould execute the payload inevil.com's context, not the auth server's context.The impact comes from client-side integrations that consume this endpoint as trusted JSONP. If a legitimate OAuth client includes
<script src>pointed at the revocation endpoint and an attacker can influence the callback value (e.g., via query parameter injection, a reflected value, or a man-in-the-middle downgrade), the attacker controls what code runs in the client application's origin. The authorization server becomes a source of attacker-controlled JavaScript that client applications trust and execute.Note: the
enable_jsonpparameter defaults toFalse, so only deployments that explicitly opt in are affected. However, this is a supported, documented library feature, not a debug flag. The client-side library includesprepare_token_revocation_request()with an explicitcallbackparameter (oauthlib/oauth2/rfc6749/parameters.py, line 174), and the documentation shows JSONP revocation as a use case (oauthlib/oauth2/rfc6749/clients/base.py, lines 351-358). The existing test suite tests JSONP callback reflection with a benign value (test_revocation_endpoint.py, lines 91-101) but does not test for injection. Deployments that enable JSONP typically do so to support older browsers or cross-origin revocation from JavaScript clients, these are exactly the environments most sensitive to script injection.PoC
Requirements: Python 3.x with oauthlib installed (
pip install oauthlib).Expected output:
Both paths reflect the attacker's payload verbatim into the response body.
Impact
Any oauthlib-based authorization server that enables JSONP on the revocation endpoint (
enable_jsonp=True) returns attacker-controlled JavaScript in its response body.Any page or application that loads this endpoint's response as JSONP and exposes attacker influence over the
callbackparameter will execute attacker-controlled code in its own origin. If a legitimate OAuth client uses JSONP revocation (as documented by oauthlib's client-side API) and an attacker can influence the callback value, the attacker controls what code runs in the client application, including access to the client page's DOM and any data normally accessible to scripts running in that origin.The JSONP feature is intended for legacy cross-origin browser support. Deployments that need it are typically JavaScript-heavy clients, exactly the environment most sensitive to script injection.
Affected versions: oauthlib >= 0.6.1 through 3.3.1 (current) and master. The unsanitized callback has been present since the revocation endpoint was first introduced in 2013 (commit
da775de). Theenable_jsonpgate was added in 2014 (commitb85f89a) but no validation of the callback value was ever added.Suggested fix
Validate the
callbackparameter against a strict pattern for legal JavaScript identifiers before using it in the response. Reject or ignore values that do not match:This is the standard mitigation for JSONP callback injection and is the approach used by jQuery, Express.js, and Google APIs. It ensures only syntactically valid function names like
package.hello_worldare accepted, while blocking payloads likealert(document.cookie)//.As a secondary hardening measure, when JSONP is enabled, the response should set
Content-Type: application/javascript(notapplication/jsonor empty) to ensure correct browser handling. Currently the success path returns no Content-Type at all, and the error path returnsapplication/json.Alternatively, if JSONP is no longer considered a necessary feature, consider deprecating and removing the
enable_jsonpoption entirely. CORS is now supported by all modern browsers and is the standard mechanism for cross-origin API access.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:NReferences
This data is provided by OSV and the PyPI Advisory Database (CC-BY 4.0).
Oauthlib: Timing Attack Vulnerability in PKCE code_verifier Comparison (CWE-208)
CVE-2026-49265 / GHSA-xpv3-w29h-x7cv / PYSEC-2026-4114
More information
Details
Summary
A timing side-channel vulnerability exists in the PKCE (RFC 7636) implementation
of the Authorization Code Grant flow. The
code_challenge_method_plainfunctionuses Python's standard
==operator for string comparison instead of aconstant-time comparison function, potentially allowing timing-based attacks.
Affected Component
oauthlib/oauth2/rfc6749/grant_types/authorization_code.pycode_challenge_method_plain,code_challenge_method_s256Technical Details
Python's
==operator uses short-circuit evaluation when comparing strings:Falseimmediately if lengths differThis means comparison time varies linearly with the length of the common prefix
between the attacker-supplied verifier and the stored challenge, creating a
measurable timing oracle.
Proof of Concept
Tested locally against oauthlib source (network jitter eliminated to isolate
pure Python execution time):
B+A*49)A*49 +B)The ~37ms delta over 10M iterations corresponds to nanosecond-level differences
per call, which are statistically exploitable under controlled conditions.
Attack Scenario
authorization_codevia Custom URI Scheme Hijackingcode_verifier/tokenendpoint measuring response timescode_verifiercharacter by characterRecommended Fix
Replace
==withhmac.compare_digest()for constant-time comparison:cr: Elvin Latifli
Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:NReferences
This data is provided by OSV and the PyPI Advisory Database (CC-BY 4.0).
Release Notes
oauthlib/oauthlib (oauthlib)
v4.0.0Compare Source
OAuth2.0 Provider:
JSONP has been superseded by CORS for cross-origin requests.
The
enable_jsonpparameter has been removed fromRevocationEndpointand the
callbackparameter has been removed fromprepare_token_revocation_request.DeviceCodeGrant.validate_token_requesttrying to authenticate public clients.
Client authentication validation has been reorganized and is now shared
across
AuthorizationCodeGrant,DeviceCodeGrant,RefreshTokenGrantand
ResourceOwnerPasswordCredentialsGrant: thegrant_typeparameteris validated before client authentication, so requests missing
grant_typenow return400 invalid_requestinstead of401 invalid_client.Misc:
examplesintosite-packages.management.
This PR was generated by Mend Renovate. View the repository job log.