Repository navigation
Update dependency oauthlib to v4 [SECURITY] - #1447
Merged
Merged
Conversation
simu
approved these changes
Oct 2, 2026
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate
Bot
force-pushed
the
renovate/pypi-oauthlib-vulnerability
branch
from
October 2, 2026 06:36
9651551 to
56b3dab
Compare
simu
enabled auto-merge
October 2, 2026 06:37
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.0Oauthlib : Unsafe JSONP callback injection in RevocationEndpoint allows arbitrary JavaScript response generation
CVE-2026-49264 / GHSA-hj66-6f7g-4r5v
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 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
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 the GitHub 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.
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.