Repository navigation
Fix NPE in secure-redirect-uris-enforcer during PAR authorization requests - #54053
tatsuya-kurosaka wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies security-sensitive redirect-URI enforcement logic where an incorrect relaxation could enable open-redirect bypasses, so a human should confirm the safety reasoning before approval.
0 open findings
What changed in this PR
This PR fixes a NullPointerException in SecureRedirectUrisEnforcerExecutor that occurred during Pushed Authorization Request (PAR) authorization flows. In a PAR flow, the authorization request sent to the authorization endpoint contains only client_id and request_uri, so redirect_uri is absent from the raw parameters processed during the PRE_AUTHORIZATION_REQUEST client-policy event. The executor previously passed this null value into the URI constructor, throwing an NPE before the request could be resolved. The fix skips the early redirect-URI validation when redirect_uri is not present, relying on the later AUTHORIZATION_REQUEST event (which runs after PAR resolution) to validate the effective redirect URI.
Changes:
- Guard the
PRE_AUTHORIZATION_REQUESTredirect-URI validation with aredirectUriParam != nullcheck. - Add an integration regression test covering the end-to-end PAR authorization flow.
| File | Description |
|---|---|
| services/src/main/java/org/keycloak/services/clientpolicy/executor/SecureRedirectUrisEnforcerExecutor.java | Adds a null check so redirect-URI validation is skipped when redirect_uri is absent during PRE_AUTHORIZATION_REQUEST, deferring enforcement to AUTHORIZATION_REQUEST. |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/client/policies/SecureRedirectUrisEnforcerExecutorTest.java | Adds a regression test verifying a PAR authorization request with only client_id/request_uri succeeds and issues a token without an NPE. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Tatsuya Kurosaka <tatsuya.kurosaka.pf@hitachi.com>
3e68392 to
602c7b1
Compare
|
Thanks for the fix! This addresses #53191 while keeping validation of the resolved redirect URI in |
lhanusov
left a comment
There was a problem hiding this comment.
@tatsuya-kurosaka please check the comment.thanks
Signed-off-by: Tatsuya Kurosaka <tatsuya.kurosaka.pf@hitachi.com>
1704cfa to
2b0eaff
Compare
| @Test | ||
| public void testSecureRedirectUrisEnforcerExecutor_parAuthorizationRequest() throws Exception { |
|
@lhanusov |
|
@tatsuya-kurosaka @mposolda can you please trigger the build to have CI results? feel free to re-review, thank you 👍 |
| throw invalidRedirectUri("Invalid parameter: clientId"); | ||
| } | ||
| if (isAuthFlowWithRedirectEnabled(client)) { | ||
| if (redirectUriParam != null && isAuthFlowWithRedirectEnabled(client)) { |


Closes #53191
Summary
When secure-redirect-uris-enforcer is enabled, PAR authorization requests
may not include
redirect_uriin the raw authorization request parametersduring
PRE_AUTHORIZATION_REQUEST.This causes redirect URI validation to be executed with a null value and
results in a failure before the PAR request parameters are resolved.
This change skips redirect URI validation during
PRE_AUTHORIZATION_REQUESTwhenredirect_uriis not present.The redirect URI is still validated later during
AUTHORIZATION_REQUEST, where the PAR request has already been resolvedand the effective redirect URI is available.
Changes
redirect_uriis absent duringPRE_AUTHORIZATION_REQUESTVerification
Automated
testSecureRedirectUrisEnforcerExecutor_parAuthorizationRequestManual
Verified the following scenarios with
secure-redirect-uris-enforcerenabled.Valid PAR flow
redirect_uriclient_idrequest_uriResult:
Invalid redirect URI
(or one not permitted by the executor configuration)
Result: