Skip to content

Commit 91d7869

Browse files
committed
Switch to an allow list of protocols for JNDI (#2422)
(cherry picked from commit e60a4cd)
1 parent 5b891e8 commit 91d7869

File tree

1 file changed

+5
-2
lines changed
  • rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util

1 file changed

+5
-2
lines changed

rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JndiHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.apache.cxf.transport.jms.util;
2020

21+
import java.util.Arrays;
22+
import java.util.List;
2123
import java.util.Properties;
2224

2325
import javax.naming.Context;
@@ -27,6 +29,8 @@
2729

2830
public class JndiHelper {
2931

32+
private static final List<String> ALLOWED_PROTOCOLS = Arrays.asList(
33+
"vm://", "tcp://", "nio://", "ssl://", "http://", "https://", "ws://", "wss://");
3034
private Properties environment;
3135

3236
/**
@@ -37,8 +41,7 @@ public JndiHelper(Properties environment) {
3741

3842
// Avoid unsafe protocols if they are somehow misconfigured
3943
String providerUrl = environment.getProperty(Context.PROVIDER_URL);
40-
if (providerUrl != null && (providerUrl.startsWith("ldap://")
41-
|| providerUrl.startsWith("rmi://"))) {
44+
if (providerUrl != null && !ALLOWED_PROTOCOLS.stream().anyMatch(providerUrl::startsWith)) {
4245
throw new IllegalArgumentException("Unsafe protocol in JNDI URL: " + providerUrl);
4346
}
4447
}

0 commit comments

Comments
 (0)