Skip to content

Conversation

@ahus1
Copy link
Contributor

@ahus1 ahus1 commented Oct 28, 2025

Closes #43763

@ahus1 ahus1 self-assigned this Oct 28, 2025
@ahus1 ahus1 force-pushed the is-43763-only-allow-normalized-urls branch from a96522d to 6ffc54f Compare October 28, 2025 13:42
@ahus1 ahus1 force-pushed the is-43763-only-allow-normalized-urls branch from 6ffc54f to fb72910 Compare October 28, 2025 15:06
@ahus1 ahus1 marked this pull request as ready for review October 28, 2025 16:33
@ahus1 ahus1 requested review from a team as code owners October 28, 2025 16:33
Copy link
Contributor

@mabartos mabartos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahus1 Nice work! Just added 2 comments for improvement.

Copy link
Contributor

@mabartos mabartos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last comments, otherwise LGTM.

Comment on lines 156 to 157
.description("If the server should accept paths that are not normalized according to RFC3986 or that contain a double slash ('//'). While accepting those requests might be relevant for legacy applications, it is recommended to disable it to allow for more concise URL filtering.")
.buildTime(true)
.deprecated()
Copy link
Contributor

@mabartos mabartos Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.description("If the server should accept paths that are not normalized according to RFC3986 or that contain a double slash ('//'). While accepting those requests might be relevant for legacy applications, it is recommended to disable it to allow for more concise URL filtering.")
.buildTime(true)
.deprecated()
.description("If the server should accept paths that are not normalized according to RFC3986 or that contain a double slash ('//'). While accepting those requests might be relevant for legacy applications, it is recommended to disable it to allow for more concise URL filtering.")
.deprecated()

It might not be necessary to have it as a build-time option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding the filter to a build time option ... so I'd assume it is build time? Or do you suggest to always add the filter, and then parameterize it?

Copy link
Contributor

@mabartos mabartos Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahus1 These filters are actually added during the static init phase (Record(ExecutionTime.STATIC_INIT)) and not created during the augmentation.

It's always better to have an option configurable at runtime if it's only some marker of behavior checked in runtime anyway.

If you remove the buildTime(true) here and add the @Consume(ConfigBuildItem.class) as described in the additional comments, it should be fine :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it a try, and then the test did no longer pass. I reverted the change.

Comment on lines 156 to 157
.description("If the server should accept paths that are not normalized according to RFC3986 or that contain a double slash ('//'). While accepting those requests might be relevant for legacy applications, it is recommended to disable it to allow for more concise URL filtering.")
.buildTime(true)
.deprecated()
Copy link
Contributor

@mabartos mabartos Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahus1 These filters are actually added during the static init phase (Record(ExecutionTime.STATIC_INIT)) and not created during the augmentation.

It's always better to have an option configurable at runtime if it's only some marker of behavior checked in runtime anyway.

If you remove the buildTime(true) here and add the @Consume(ConfigBuildItem.class) as described in the additional comments, it should be fine :)

@ahus1 ahus1 force-pushed the is-43763-only-allow-normalized-urls branch from 57a9e46 to ed95fc3 Compare October 29, 2025 15:23
Copy link
Contributor

@vmuzikar vmuzikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahus1 Thank you for the PR.

I'm not sure if I'm doing something wrong (probably yes as the tests pass) but if I do something as simple as curl -v http://localhost:8080/realms/xxx/../master/, I get 200 response instead of 400.

"Specify a list of comma-separated values defined in milliseconds. Example with buckets from 5ms to 10s: 5,10,25,50,250,500,1000,2500,5000,10000")
.build();

public static final Option<Boolean> HTTP_ACCEPT_NON_NORMALIZED_PATHS = new OptionBuilder<>("http-accept-non-normalized-paths", Boolean.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to make it configurable? It's a breaking change but to fix a security issue. What would be a real and valid use case for the non-normalized paths?

Sorry if this has been already discussed somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a real and valid use case for the non-normalized paths?

I would say adding .. to the path is not a valid use case, maybe someone used it as a workaround for some issue in a machine-to-machine communication.

The most common thing I could think of is a double // in the URL, where someone might have concatenated URLs, and they end up with two //. We would break those setups. And to back out of such a setup, there is this option to revert it. And it is deprecated, so we can remove it again soon - like in 27.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say if someone uses // it's probably an oversight and a misconfiguration. So having it configurable is more like a convenience feature. But it's not a blocker for me, let's keep it there.

@shawkins
Copy link
Contributor

@ahus1 Thank you for the PR.

I'm not sure if I'm doing something wrong (probably yes as the tests pass) but if I do something as simple as curl -v http://localhost:8080/realms/xxx/../master/, I get 200 response instead of 400.

curl needs --path-as-is otherwise it will do the normalization.

@vmuzikar
Copy link
Contributor

curl needs --path-as-is otherwise it will do the normalization.

Thanks, sorry for the noise. What confused me is that even browser normalized the path (did not get 400).

@ahus1 ahus1 force-pushed the is-43763-only-allow-normalized-urls branch from ed95fc3 to b9d2ae0 Compare October 29, 2025 20:41
vmuzikar
vmuzikar previously approved these changes Oct 30, 2025
Copy link
Contributor

@vmuzikar vmuzikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the fix.

@mabartos Are you ok with the changes as is?

@mabartos
Copy link
Contributor

@ahus1 We should ensure the build chain execution order to prevent any issues + would be good to have the property runtime.

Sent a PR to your fork: ahus1#434

Closes keycloak#43763

Co-authored-by: Martin Bartoš <[email protected]>
Signed-off-by: Martin Bartoš <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
@ahus1 ahus1 force-pushed the is-43763-only-allow-normalized-urls branch from f25b740 to 9274d24 Compare October 30, 2025 11:37
@ahus1 ahus1 requested a review from mabartos October 30, 2025 11:37
Copy link
Contributor

@mabartos mabartos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahus1 LGTM, thanks!

@ahus1
Copy link
Contributor Author

ahus1 commented Oct 30, 2025

@mabartos - thank you for the PR. I merge it to this branch, rebased it, and fixed the help test. Let's wait for the build to be green.

@vmuzikar vmuzikar merged commit 0f01444 into keycloak:main Oct 30, 2025
83 checks passed
@pohjanoksajukka
Copy link

@ahus1 @mabartos, is this the fix for CVE-2025-10939?

@ahus1
Copy link
Contributor Author

ahus1 commented Nov 4, 2025

is this the fix for CVE-2025-10939?

Yes.

ahus1 added a commit to ahus1/keycloak that referenced this pull request Nov 5, 2025
Closes keycloak#43763

Signed-off-by: Martin Bartoš <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
Co-authored-by: Martin Bartoš <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalizing of Keycloak URLs not documented

5 participants