GitHub advisory · PyPI
Authlib: Unvalidated request_uri fetch in JWT-secured authorization request (JAR) leading to SSRF
Description
Authlib's RFC 9101 (JAR) extension passes the attacker-controlled request_uri authorization parameter straight to the get_request_object() fetch hook with no validation, at a pre-authentication endpoint. Authlib already defines the pre-registration allowlist for this (request_uris client metadata and require_request_uri_registration server metadata) but the extension never consults it, and both docstrings instruct integrators to implement the hook as an unrestricted requests.get(request_uri). Deployments following the documented pattern get an unauthenticated SSRF primitive.
Verified against authlib 1.7.2 and current main. All line numbers below are from authlib/oauth2/rfc9101/authorization_server.py.
The extension registers itself on the before_get_authorization_grant hook (lines 62-65), so it runs on every authorization request before any user or client authentication. support_request_uri defaults to True (line 58).
The only gate before the sink is that client_id names an existing client (lines 91-103). A client_id is a public, non-secret identifier.
The sink at line 159 forwards the raw parameter with no scheme, host, or allowlist check:
def _get_raw_request_object(self, request: OAuth2Request) -> str:
if "request_uri" in request.payload.data:
raw_request_object = self.get_request_object(
request.payload.data["request_uri"]
)
if not raw_request_object:
raise InvalidRequestUriError(state=request.payload.state)
get_request_object is abstract (line 213, raise NotImplementedError() at line 225), so authlib itself performs no outbound request. The defect is that authlib supplies unvalidated attacker input to that extension point and then documents the insecure implementation twice — in the class docstring (lines 34-38) and in the hook's own docstring (lines 218-223):
def get_request_object(self, request_uri: str):
try:…
Manual fix · PyPI
pip install --upgrade "authlib>=1.9.0"Sources