[backport camel-4.18.x] CAMEL-24412: camel-netty-http - evaluate the security constraint against the same normalized target as dispatch - #25762
Merged
oscerd merged 1 commit intoAug 27, 2026
Conversation
…nst the same normalized target as dispatch (apache#25578) HttpServerChannelHandler.extractTarget() strips the endpoint context-path from the request target so the security constraint is evaluated relative to the endpoint. The strip was guarded by a case-sensitive startsWith: if (path != null && target.startsWith(path)) { // need to match by lower case as we want to ignore case on context-path path = path.toLowerCase(Locale.US); String match = target.toLowerCase(Locale.US); if (match.startsWith(path)) { so the inner case-insensitive comparison could never change the outcome - it was dead code. A request whose context-path differed only by case was evaluated against the unstripped target. Dispatch does not share that property: RestConsumerContextPathMatcher.matchPath() compares with equalsIgnoreCase and a lower-cased prefix, so the request still reaches the route. Authorization and dispatch therefore disagreed about which endpoint a request belongs to. With matchOnUriPrefix=true and a securityConstraint whose inclusions are specific sub-paths rather than a catch-all, the miscased target matched no inclusion, and an unmatched target counts as unrestricted. The strip now uses the case-insensitive comparison directly. The added test covers both directions against a constraint with a specific /admin/* inclusion: the exact-case path is challenged as before, and the differently-cased path - which reaches the route either way - is now challenged too. Without this fix the second case returns 200 with no challenge. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
gnodet
approved these changes
Aug 26, 2026
gnodet
left a comment
Contributor
There was a problem hiding this comment.
Clean backport of #25578 (CAMEL-24412) onto camel-4.18.x. The security fix simplifies the case-insensitive context-path comparison in extractTarget() so the security constraint matches the same normalized target as consumer dispatch. The test covers both exact-case and differently-cased context paths.
Conflict resolution is minimal — upgrade guide entry dropped (correct, guides live on main). The core fix is identical to the original.
CI green on JDK 17 and 21.
AI-generated review on behalf of Guillaume Nodet. Feedback? Let us know!
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.
Backport of #25578
Cherry-pick of #25578 onto
camel-4.18.x.Original PR: #25578
Original author: @oscerd
Resolution: the 4.23 upgrade-guide entry is dropped, since the guides for every release line live on
main.Verified: cherry-pick applied with the conflicts resolved as above, and the branch builds on
camel-4.18.x.Claude Code on behalf of oscerd