This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 7dd1e59135 Do not accept multicast data broadcasts on a secure Tribes
channel
7dd1e59135 is described below
commit 7dd1e5913539ef1abd7c2bb0589bb61d79f9939e
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 30 17:51:46 2026 +0000
Do not accept multicast data broadcasts on a secure Tribes channel
A secure channel cannot send data broadcasts as TLS is not supported for
multicast. Do not register the message listener with the McastService for a
secure channel so that clear text datagrams sent to the membership port
cannot bypass the TLS protection.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
.../catalina/tribes/group/ChannelCoordinator.java | 9 ++-
.../group/TestChannelCoordinatorMcastListener.java | 94 ++++++++++++++++++++++
webapps/docs/changelog.xml | 5 ++
3 files changed, 107 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/tribes/group/ChannelCoordinator.java
b/java/org/apache/catalina/tribes/group/ChannelCoordinator.java
index df96bf8ea4..92bbd03d0d 100644
--- a/java/org/apache/catalina/tribes/group/ChannelCoordinator.java
+++ b/java/org/apache/catalina/tribes/group/ChannelCoordinator.java
@@ -203,7 +203,14 @@ public class ChannelCoordinator extends
ChannelInterceptorBase implements Messag
membershipService.setMembershipListener(this);
membershipService.setChannel(getChannel());
if (membershipService instanceof McastService) {
- ((McastService)
membershipService).setMessageListener(this);
+ /*
+ * Data broadcasts received over multicast are
unauthenticated clear text datagrams. A secure
+ * channel cannot send them (see GroupChannel.send()) so
do not accept them either. Without a
+ * listener the membership service only processes
membership pings. The listener is explicitly
+ * cleared as it may have been set when the membership
service was configured.
+ */
+ boolean secure = getChannel() instanceof GroupChannel &&
((GroupChannel) getChannel()).getSecure();
+ ((McastService)
membershipService).setMessageListener(secure ? null : this);
}
membershipService.start(MembershipService.MBR_RX);
startLevel = startLevel | Channel.MBR_RX_SEQ;
diff --git
a/test/org/apache/catalina/tribes/group/TestChannelCoordinatorMcastListener.java
b/test/org/apache/catalina/tribes/group/TestChannelCoordinatorMcastListener.java
new file mode 100644
index 0000000000..dae52718b7
--- /dev/null
+++
b/test/org/apache/catalina/tribes/group/TestChannelCoordinatorMcastListener.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.tribes.group;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.TesterUtil;
+import org.apache.catalina.tribes.io.ChannelData;
+import org.apache.catalina.tribes.membership.McastService;
+import org.apache.catalina.tribes.membership.MemberImpl;
+
+public class TestChannelCoordinatorMcastListener {
+
+ /*
+ * Data broadcasts received over multicast are unauthenticated clear text
datagrams. A secure channel can't send
+ * them so it must not accept them.
+ */
+ @Test
+ public void testSecureChannelIgnoresMulticastDataBroadcast() throws
Exception {
+ Assert.assertEquals(0, deliveredBroadcasts(true));
+ }
+
+
+ /*
+ * Check the test itself. Without TLS the broadcast must be delivered,
else the secure case proves nothing.
+ */
+ @Test
+ public void testInsecureChannelAcceptsMulticastDataBroadcast() throws
Exception {
+ Assert.assertEquals(1, deliveredBroadcasts(false));
+ }
+
+
+ private int deliveredBroadcasts(boolean secure) throws Exception {
+ AtomicInteger delivered = new AtomicInteger();
+
+ GroupChannel channel = new GroupChannel();
+ channel.setName("TestChannelCoordinatorMcastListener-" +
System.nanoTime());
+ channel.setSecure(secure);
+
+ ChannelCoordinator coordinator = new ChannelCoordinator();
+ coordinator.setChannel(channel);
+ coordinator.setPrevious(new ChannelInterceptorBase() {
+ @Override
+ public void messageReceived(ChannelMessage msg) {
+ delivered.incrementAndGet();
+ }
+ });
+
+ McastService service = new McastService();
+ coordinator.setMembershipService(service);
+
+ Properties props = new Properties();
+ props.setProperty("mcastAddress", "228.0.0.4");
+ props.setProperty("mcastPort",
String.valueOf(TesterUtil.getFreeUdpPort()));
+ props.setProperty("tcpListenHost", "127.0.0.1");
+ props.setProperty("tcpListenPort", "0");
+ props.setProperty("tcpSecurePort", "0");
+ props.setProperty("udpListenPort", "0");
+ props.setProperty("mcastFrequency", "100");
+ props.setProperty("memberDropTime", "3000");
+ service.setProperties(props);
+ coordinator.start(Channel.MBR_RX_SEQ);
+
+ try {
+ // Deliver a data broadcast as McastServiceImpl does when it
receives one from the network
+ ChannelData data = new ChannelData(true);
+ data.setAddress(new MemberImpl("127.0.0.1", 4001, 100));
+ service.messageReceived(data);
+ } finally {
+ coordinator.stop(Channel.MBR_RX_SEQ);
+ }
+ return delivered.get();
+ }
+}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2f583c9b16..702e9c4200 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -449,6 +449,11 @@
Increase visibility of TLS errors when receiving cluster messages.
(markt)
</fix>
+ <fix>
+ When a Tribes channel is configured as secure, do not accept channel
+ messages received as clear text multicast datagrams on the membership
+ port. A secure channel cannot send such messages. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]