Vulnerability record · PyPI
PYSEC-2026-4113
Description
When enable_jsonp=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.
The issue is in oauthlib/oauth2/rfc6749/endpoints/revocation.py.
When enable_jsonp=True is passed to the RevocationEndpoint constructor, two code paths wrap the response body using the user-supplied request.callback parameter:
# Error response path (line 72-73):
if self.enable_jsonp and request.callback:
response_body = '{}({});'.format(request.callback, response_body)
# Success response path (line 81-82):
if self.enable_jsonp and request.callback:
response_body = 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:
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…
Manual fix · PyPI
pip install --upgrade "oauthlib>=4.0.0"Sources