Repository navigation
Conversation
Normalize decoded query and fragment parameter names by stripping leading '?' and '#' so doubled or percent-encoded delimiters cannot bypass the forbidden OIDC response parameter check. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression assertion passes without exercising the new normalization because URI.create rejects the second raw # before parameter validation.
1 open issue
What changed in this PR
Hardens OIDC redirect handling against forbidden response parameters prefixed with literal or encoded ? and #, addressing #55737.
Changes:
- Adds shared normalization for decoded parameter names.
- Applies normalization to redirect validation and parameter removal.
- Adds regression tests while preserving empty-forbidden-set compatibility.
| File | Description |
|---|---|
| services/src/test/java/org/keycloak/protocol/oidc/utils/RedirectUtilsTest.java | Tests rejection of delimiter-prefixed parameters. |
| services/src/test/java/org/keycloak/protocol/oidc/utils/OIDCRedirectUriBuilderTest.java | Tests query and fragment cleanup. |
| services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java | Normalizes names before forbidden-parameter checks. |
| services/src/main/java/org/keycloak/protocol/oidc/utils/OIDCRedirectUriBuilder.java | Normalizes names during fragment cleanup. |
| common/src/test/java/org/keycloak/common/util/KeycloakUriBuilderTest.java | Tests normalization and parameter removal. |
| common/src/main/java/org/keycloak/common/util/UriUtils.java | Adds the delimiter-stripping helper. |
| common/src/main/java/org/keycloak/common/util/KeycloakUriBuilder.java | Applies normalization to query and fragment removal. |
Review effort: Balanced
URI.create rejects a second raw '#', so ##state never reached normalization; use #%23state instead. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression assertion passes even without delimiter normalization because callback/* rejects the truncated URI, leaving a bypassed forbidden-parameter check undetected.
1 open issue
1 resolved since last review
Review effort: Balanced
matchesRedirects truncates at the first '?', so callback#?code failed allowlist matching under callback/* even without delimiter normalization. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
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.

Closes #55777
Incomplete forbidden-parameter checks still accepted doubled or percent-encoded query/fragment delimiters on OIDC response parameter names.
Decisions and assumptions
?/#in validation and when stripping params from redirect buildersAI used to help reproduce the bypass and draft the patch.