CAMEL-23588: camel-undertow - extend UndertowHeaderFilterStrategy to filter the legacy websocket.* exchange-header prefix#23522
CAMEL-23588: camel-undertow - extend UndertowHeaderFilterStrategy to filter the legacy websocket.* exchange-header prefix#23522oscerd wants to merge 1 commit into
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (2 modules)
|
|
CI failure (
|
gnodet
left a comment
There was a problem hiding this comment.
Good defense-in-depth: extending UndertowHeaderFilterStrategy to filter the websocket.* prefix on both inbound and outbound. This prevents untrusted WebSocket clients from injecting headers that could be interpreted as configuration by downstream processors.
Adding WEBSOCKET_FILTER_STARTS_WITH = "websocket." to both in-filter and out-filter prefix lists is consistent with the existing pattern for Camel* and org.apache.camel.* prefixes. Upgrade guide with defense-in-depth guidance is well written.
LGTM.
Fully automatic review from Claude Code
…filter the legacy websocket.* exchange-header prefix
Adds "websocket." to both setOutFilterStartsWith and setInFilterStartsWith on
UndertowHeaderFilterStrategy, in addition to the existing Camel*/camel*
prefixes inherited from HttpHeaderFilterStrategy. This follows the
dedicated-HeaderFilterStrategy fix shape used by CAMEL-23532 for
camel-vertx-websocket / camel-atmosphere-websocket / camel-iggy and is the
camel-undertow follow-on called out by CAMEL-23577.
The constants in UndertowConstants (CONNECTION_KEY, CONNECTION_KEY_LIST,
SEND_TO_ALL, EVENT_TYPE, EVENT_TYPE_ENUM, CHANNEL, EXCHANGE) keep their
existing string values (websocket.connectionKey, websocket.connectionKey.list,
websocket.sendToAll, ...) because they are part of undertow's
externally-visible API contract; renaming them would break a documented
protocol surface that route authors and downstream consumers rely on.
The behaviour change applies only at undertow's transport boundary:
- Outbound (exchange -> wire): exchange headers whose name starts with
websocket. are no longer propagated onto the outbound HTTP/websocket request
as wire-level headers.
- Inbound (wire -> exchange): wire-level headers whose name starts with
websocket. are no longer mapped into the resulting Camel exchange.
The undertow consumer's programmatic setHeader(CONNECTION_KEY, ...) and the
producer's in.getHeader(CONNECTION_KEY, ...) operate on the exchange directly
and are unaffected by the filter strategy. All 161 existing tests pass.
Note: the HeaderFilterStrategy does NOT prevent cross-component header
injection (e.g. http -> undertow with attacker-supplied websocket.connectionKey
in the HTTP request). The upgrade-guide entry documents the residual gap and
recommends .removeHeaders("websocket.*") at trust boundaries as the
defence-in-depth pattern.
Routes that intentionally relied on undertow mapping websocket.* wire headers
in or out can supply a custom headerFilterStrategy endpoint option to restore
the previous behaviour.
Tracker: CAMEL-23577
Reported by Claude Code on behalf of Andrea Cosentino
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
@apupier — rebased onto current Will re-request your review once the new Claude Code on behalf of Andrea Cosentino |
|
LGTM |
|
so the new push retriggered a build (which is passing) but now there is a conflict to resolve the old job is still stuck in the queue. I tried to cancel it but there is an error and i cannot. I hope this will be cleared when the PR will be merged |
Summary
Adds
"websocket."to bothsetOutFilterStartsWithandsetInFilterStartsWithon
UndertowHeaderFilterStrategy, in addition to the existingCamel*/camel*prefixes inherited fromHttpHeaderFilterStrategy. This follows thededicated-HeaderFilterStrategy fix shape used by CAMEL-23532 for
camel-vertx-websocket/camel-atmosphere-websocket/camel-iggyand isthe
camel-undertowfollow-on called out by CAMEL-23577.Why not rename the constants
The constants in
UndertowConstants(CONNECTION_KEY,CONNECTION_KEY_LIST,SEND_TO_ALL,EVENT_TYPE,EVENT_TYPE_ENUM,CHANNEL,EXCHANGE) keeptheir existing string values (
websocket.connectionKey,websocket.connectionKey.list,websocket.sendToAll, ...) because they arepart of undertow's externally-visible API contract — they appear in the
component docs and route examples. The CAMEL-23577 epic explicitly cites
websocket.connectionKeyas the canonical case for thededicated-filter-strategy shape rather than the rename shape.
Behaviour change (transport-boundary only)
websocket.are no longer propagated onto the outbound HTTP/websocketrequest as wire-level headers.
websocket.are no longer mapped into the resulting Camel exchange.The undertow consumer's programmatic
setHeader(CONNECTION_KEY, ...)and theproducer's
in.getHeader(CONNECTION_KEY, ...)operate on the exchangedirectly and are unaffected by the filter strategy.
Residual gap and defence-in-depth recommendation
The
HeaderFilterStrategyonly governs the transport boundary; it does notprevent cross-component header injection (for example,
from("jetty:...").to("undertow:ws://...")— an attacker-suppliedwebsocket.connectionKeyHTTP header is mapped into the exchange by jetty andthen read by the undertow producer to target a specific peer). The
upgrade-guide entry documents the residual gap and recommends
.removeHeaders("websocket.*")at trust boundaries as thedefence-in-depth pattern:
Opt-out
Routes that intentionally relied on undertow mapping
websocket.*wireheaders in or out can supply a custom
headerFilterStrategyendpoint optionto restore the previous behaviour.
Backports
camel-4.18.x—UndertowHeaderFilterStrategyhas the same shape (extendsHttpHeaderFilterStrategy); backport applies cleanly.camel-4.14.x—UndertowHeaderFilterStrategyextendsDefaultHeaderFilterStrategy(notHttpHeaderFilterStrategy) and alreadysets
CAMEL_FILTER_STARTS_WITHexplicitly; backport needs a smalladaptation. Will be filed as follow-up PR.
Test plan
mvn testincomponents/camel-undertow— 161 tests pass (1 skipped)origin/mainis purely additive (65 insertions, 0 deletions)=== camel-undertow - potential breaking changedocumenting the behaviour change, the cross-component-injectionresidual gap, and the recommended
.removeHeaders("websocket.*")mitigation
Tracker: CAMEL-23577
Reported by Claude Code on behalf of Andrea Cosentino