This is an automated email from the ASF dual-hosted git repository.

oscerd pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new 2b15fe82d4c5 CAMEL-23588: camel-undertow - extend 
UndertowHeaderFilterStrategy to filter the legacy websocket.* exchange-header 
prefix (#23993)
2b15fe82d4c5 is described below

commit 2b15fe82d4c5459119584b402c9140c85a702fc6
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Jun 12 18:33:29 2026 +0200

    CAMEL-23588: camel-undertow - extend UndertowHeaderFilterStrategy to filter 
the legacy websocket.* exchange-header prefix (#23993)
    
    Backport to camel-4.14.x of the main-branch change (d5a717dd0f8). On 4.14.x 
the
    UndertowHeaderFilterStrategy is the (deprecated) 
DefaultHeaderFilterStrategy-based
    implementation, so the change is adapted rather than copied verbatim: the 
existing
    initialize() now adds the legacy websocket.* prefix to the in/out filter 
prefixes
    (alongside Camel/camel). The lowerCase fallback in 
DefaultHeaderFilterStrategy.doFiltering
    matches the prefix case-insensitively, giving behaviour equivalent to main. 
Documents
    the change in the 4.14 upgrade guide alongside the CAMEL-23532 websocket 
family.
---
 .../undertow/UndertowHeaderFilterStrategy.java     | 21 ++++++++--
 .../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc    | 47 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
index 75e3de61a370..8b66fd8933e0 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
@@ -25,6 +25,18 @@ import org.apache.camel.support.http.HttpUtil;
  */
 public class UndertowHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
 
+    /**
+     * Legacy {@code websocket.*} Exchange-header prefix used by {@code 
UndertowConstants} for the dispatch and event
+     * headers ({@code websocket.connectionKey}, {@code 
websocket.connectionKey.list}, {@code websocket.sendToAll},
+     * {@code websocket.eventType}, {@code websocket.eventTypeEnum}, {@code 
websocket.channel},
+     * {@code websocket.exchange}). Added to the in/out filter prefixes 
(CAMEL-23588) so the undertow boundary does not
+     * propagate these values onto outbound wire frames or map them in from 
inbound HTTP-style headers. This is
+     * defence-in-depth — cross-component routes that flow an untrusted 
message into an undertow producer should also
+     * {@code .removeHeaders("websocket.*")} at the trust boundary, because 
the producer reads these headers via
+     * {@code in.getHeader(...)} which bypasses the {@code 
HeaderFilterStrategy}.
+     */
+    static final String WEBSOCKET_FILTER_STARTS_WITH = "websocket.";
+
     public UndertowHeaderFilterStrategy() {
         initialize();
     }
@@ -34,9 +46,10 @@ public class UndertowHeaderFilterStrategy extends 
DefaultHeaderFilterStrategy {
 
         setLowerCase(true);
 
-        // filter headers begin with "Camel" or "org.apache.camel"
-        // must ignore case for Http based transports
-        setOutFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
-        setInFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
+        // filter headers that begin with "Camel" / "camel" (ignoring case for 
HTTP-based
+        // transports) and the legacy "websocket." prefix used by 
UndertowConstants
+        // (CAMEL-23588), in both the inbound and outbound directions
+        setOutFilterStartsWith("Camel", "camel", WEBSOCKET_FILTER_STARTS_WITH);
+        setInFilterStartsWith("Camel", "camel", WEBSOCKET_FILTER_STARTS_WITH);
     }
 }
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index b7d9d5ec2e26..3f388880f43e 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -1047,6 +1047,53 @@ default `HttpHeaderFilterStrategy` filters headers 
starting with `Camel` / `came
 (case-insensitive). Routes that relied on receiving `Camel`-prefixed header 
names from WebSocket
 query parameters can supply a custom `headerFilterStrategy` to restore the 
previous behaviour.
 
+=== camel-undertow - potential breaking change
+
+`UndertowHeaderFilterStrategy` now also filters the legacy `websocket.*`
+Exchange-header prefix (in addition to the `Camel*` / `camel*` /
+`org.apache.camel.*` prefixes it already filtered). This applies to both the
+in (wire -> exchange) and out (exchange -> wire) directions and follows the
+dedicated-filter-strategy shape used by CAMEL-23532 for
+`camel-vertx-websocket` / `camel-atmosphere-websocket` / `camel-iggy`.
+
+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`, etc.) because they are
+part of the undertow component's externally-visible API contract; routes
+referencing them (symbolically or by literal value) continue to work
+unchanged within an undertow route.
+
+The behaviour change applies at undertow's transport boundary:
+
+* Outbound (exchange -> wire): if an exchange ends up at an undertow producer
+  carrying an Exchange header whose name starts with `websocket.`, that
+  header will no longer be propagated onto the outbound HTTP/websocket
+  request as a wire-level header.
+* Inbound (wire -> exchange): if an undertow consumer receives a request
+  whose wire-level headers include a name starting with `websocket.`, that
+  header will no longer be mapped into the resulting Camel exchange.
+
+Note that the `HeaderFilterStrategy` only governs the transport boundary; it
+does not prevent cross-component header injection (for example, an
+`http -> undertow` route where the HTTP consumer maps an attacker-supplied
+`websocket.connectionKey` header into the exchange and the undertow producer
+then reads it via `in.getHeader(...)` to dispatch to a specific peer). For
+defence in depth at the trust boundary, route authors should explicitly strip
+these headers from untrusted inbound traffic, for example:
+
+[source,java]
+----
+from("jetty:http://0.0.0.0:8080/api";)
+    .removeHeaders("websocket.*")
+    .to("undertow:ws://internal-broker/notifications");
+----
+
+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.
+
+
 === camel-aws2-sqs
 
 `Sqs2HeaderFilterStrategy` now also configures an inbound filter aligned with 
the existing

Reply via email to