diff --git a/java/ql/src/experimental/Security/CWE/CWE-665/CorrectJmxEnvironmentInitialisation.java b/java/ql/src/experimental/Security/CWE/CWE-665/CorrectJmxEnvironmentInitialisation.java index d2f8e3dbe98..4152e97ddd0 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-665/CorrectJmxEnvironmentInitialisation.java +++ b/java/ql/src/experimental/Security/CWE/CWE-665/CorrectJmxEnvironmentInitialisation.java @@ -20,7 +20,7 @@ public class CorrectJmxInitialisation { String my_filter = "java.lang.String;!*"; // Deny everything but java.lang.String env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter); - /* Old way + /* Java 9 or below: env.put("jmx.remote.rmi.server.credential.types", new String[] { String[].class.getName(), String.class.getName() }); */ diff --git a/java/ql/src/experimental/Security/CWE/CWE-665/CorrectRmiEnvironmentInitialisation.java b/java/ql/src/experimental/Security/CWE/CWE-665/CorrectRmiEnvironmentInitialisation.java index 61d01afa097..724427ef597 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-665/CorrectRmiEnvironmentInitialisation.java +++ b/java/ql/src/experimental/Security/CWE/CWE-665/CorrectRmiEnvironmentInitialisation.java @@ -10,7 +10,7 @@ public class CorrectRmiInitialisation { String my_filter = "java.lang.String;!*"; // Deny everything but java.lang.String env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter); - /* Old way + /* Java 9 or below env.put("jmx.remote.rmi.server.credential.types", new String[] { String[].class.getName(), String.class.getName() }); */ diff --git a/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp b/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp index 4bd71587177..83bf7519ebd 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp +++ b/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp @@ -4,7 +4,7 @@

An improperly set environment variable during the creation of an RMI or JMX server can lead -to an unauthenticated remote code execution vulnerability. This is due to the fact that the +to an unauthenticated remote code execution vulnerability. This is because the RMI/JMX server environment allows attackers to supply arbitrary objects to the authentication method, resulting in the attempted deserialization of an attacker-controlled object. @@ -15,7 +15,7 @@ to be passed as second parameter. In order to disallow the deserialization of arbitrary objects the passed environment needs to set a deserialization filter. Ideally this filter only allows the deserialization to java.lang.String. -The filter can be configured by setting the key jmx.remote.rmi.server.credentials.filter.pattern (CONST variable RMIConnectorServer.CREDENTIALS_FILTER_PATTERN). +The filter can be configured by setting the key jmx.remote.rmi.server.credentials.filter.pattern (given by the constant RMIConnectorServer.CREDENTIALS_FILTER_PATTERN). The filter should (ideally) only allow java.lang.String and disallow all other classes for deserialization: ("java.lang.String;!*"). The key-value pair can be set as following: @@ -27,7 +27,7 @@ Map env = new HashMap; env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter); -For applications using < Java 10: +For applications using Java 9 or below: // This is deprecated in Java 10+ ! diff --git a/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql b/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql index 7448f49784e..9bf195548c2 100644 --- a/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql +++ b/java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.ql @@ -1,6 +1,6 @@ /** * @name InsecureRmiJmxAuthenticationEnvironment - * @description This query detects if a JMX/RMI server is created with a potentially dangerous environment, which could lead to code execution through insecure deserialization. + * @description Creating a JMX/RMI server could lead to code execution through insecure deserialization if its environment does not restrict the types that can be deserialized. * @kind path-problem * @problem.severity error * @tags security @@ -17,14 +17,14 @@ import DataFlow::PathGraph import semmle.code.java.dataflow.NullGuards import semmle.code.java.dataflow.Nullness -/** Predicate which detects vulnerable Constructors */ +/** Holds if `constructor` instantiates an RMI or JMX server. */ predicate isRmiOrJmxServerCreateConstructor(Constructor constructor) { constructor .getDeclaringType() .hasQualifiedName("javax.management.remote.rmi", "RMIConnectorServer") } -/** Predicate which detects vulnerable server creations via methods */ +/** Holds if `method` creates an RMI or JMX server. */ predicate isRmiOrJmxServerCreateMethod(Method method) { method.getName() = "newJMXConnectorServer" and method.getDeclaringType().hasQualifiedName("javax.management.remote", "JMXConnectorServerFactory")