Skip to content

[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 into
apache:camel-4.18.xfrom
oscerd:backport/25578-to-camel-4.18.x
Aug 27, 2026
Merged

[backport camel-4.18.x] CAMEL-24412: camel-netty-http - evaluate the security constraint against the same normalized target as dispatch#25762
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/25578-to-camel-4.18.x

Conversation

@oscerd

@oscerd oscerd commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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

…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>
@oscerd oscerd added this to the 4.23.0 milestone Aug 26, 2026
@oscerd oscerd added the backport indicate that a Pull request is a backport from a fix from the main branch label Aug 26, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

@oscerd oscerd added the bug Something isn't working label Aug 27, 2026
@oscerd oscerd self-assigned this Aug 27, 2026
@oscerd oscerd modified the milestones: 4.23.0, 4.18.5 Aug 27, 2026
@oscerd
oscerd merged commit 1d280e8 into apache:camel-4.18.x Aug 27, 2026
3 checks passed
@oscerd
oscerd deleted the backport/25578-to-camel-4.18.x branch August 27, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport indicate that a Pull request is a backport from a fix from the main branch bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants