You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* XML validation and summary changes in qhelp file
;
* Encode entities within <code> snippet
* Updated minor descriptions and examples
* Implemented spelling review
Copy file name to clipboardExpand all lines: java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp
+28-19Lines changed: 28 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -2,34 +2,42 @@
2
2
"-//Semmle//qhelp//EN"
3
3
"qhelp.dtd">
4
4
<qhelp>
5
+
5
6
<overview>
6
-
<p>An improperly set environment variable during the creation of an RMI or JMX server can lead
7
-
to an unauthenticated remote code execution vulnerability. This is because the
8
-
RMI/JMX server environment allows attackers to supply arbitrary objects to the authentication
9
-
method, resulting in the attempted deserialization of an attacker-controlled object.
7
+
<p>For special use cases some applications may implement a custom service which handles JMX-RMI connections.</p>
8
+
9
+
<p>When creating such a custom service, a developer should pass a certain environment configuration to the JMX-RMI server initalisation,
10
+
as otherwise the JMX-RMI service is susceptible to an unsafe deserialization vulnerability.</p>
11
+
12
+
<p>This is because the JMX-RMI service allows attackers to supply arbitrary objects to the service authentication
13
+
method, resulting in the attempted deserialization of an attacker-controlled object.
14
+
In the worst case scenario this could allow an attacker to achieve remote code execution within the context of the application server.</p>
15
+
16
+
<p>By setting the appropriate environment, the deserialization can be controlled via a deserialization filter.</p>
17
+
10
18
</overview>
11
19
12
20
<recommendation>
13
-
<p>During the creation/initialization of an RMI or JMX server an environment should be supplied that sets a deserialization filter.
14
-
Ideally this filter only allows the deserialization of <code>java.lang.String</code>.
21
+
<p>During the creation of a custom JMX-RMI service an environment should be supplied that sets a deserialization filter.
22
+
Ideally this filter should be as restrictive as possible, for example to only allow the deserialization of <code>java.lang.String</code>.</p>
15
23
16
-
The filter can be configured by setting the key <code>jmx.remote.rmi.server.credentials.filter.pattern</code> (given by the constant <code>RMIConnectorServer.CREDENTIALS_FILTER_PATTERN</code>).
17
-
The filter should (ideally) only allow java.lang.String and disallow all other classes for deserialization: (<code>"java.lang.String;!*"</code>).
24
+
<p>The filter can be configured by setting the key <code>jmx.remote.rmi.server.credentials.filter.pattern</code> (given by the constant <code>RMIConnectorServer.CREDENTIALS_FILTER_PATTERN</code>).
25
+
The filter should (ideally) only allow java.lang.String and disallow all other classes for deserialization: (<code>"java.lang.String;!*"</code>).</p>
18
26
19
-
The key-value pair can be set as following:
27
+
<p>The key-value pair can be set as following:</p>
20
28
21
29
<code>
22
30
String stringsOnlyFilter = "java.lang.String;!*"; // Deny everything but java.lang.String
23
31
24
-
Map<String, Object> env = new HashMap<String, Object>;
32
+
Map<String, Object> env = new HashMap<String, Object>;
Map<String, Object> env = new HashMap<String, Object>;
40
+
Map<String, Object> env = new HashMap<String, Object>;
33
41
env.put (
34
42
"jmx.remote.rmi.server.credential.types",
35
43
new String[]{
@@ -39,20 +47,20 @@ env.put (
39
47
);
40
48
</code>
41
49
42
-
Please note that the authentication implementation is vulnerable by default.
43
-
For this reason an initialization with a <code>null</code> environment is also vulnerable.
50
+
<p>Please note that the JMX-RMI service is vulnerable in the default configuration.
51
+
For this reason an initialization with a <code>null</code> environment is also vulnerable.</p>
44
52
</recommendation>
45
53
46
54
<example>
47
-
<p>The following examples show how an RMI or JMX server can be initialized securely.
55
+
<p>The following examples show how an JMX-RMI service can be initialized securely.</p>
48
56
49
-
<p>The first example shows how an RMI server can be initialized with a secure environment.</p>
57
+
<p>The first example shows how an JMX server is initialized securely with the <code>JMXConnectorServerFactory.newJMXConnectorServer()</code> call.</p>
50
58
51
-
<samplesrc="CorrectRmiInitialisation.java">
59
+
<samplesrc="CorrectJmxInitialisation.java" />
52
60
53
-
<p>The second example shows how the environment for a JMX server can be initialized securely.</p>
61
+
<p>The second example shows how a JMX Server is initialized securely if the <code>RMIConnectorServer</code> class is used.</p>
54
62
55
-
<samplesrc="CorrectJmxInitialisation.java">
63
+
<samplesrc="CorrectRmiInitialisation.java" />
56
64
57
65
</example>
58
66
@@ -63,4 +71,5 @@ For this reason an initialization with a <code>null</code> environment is also v
63
71
<li>Java 10 API specification for <ahref="https://docs.oracle.com/javase/10/docs/api/javax/management/remote/rmi/RMIConnectorServer.html#CREDENTIALS_FILTER_PATTERN">RMIConnectorServer.CREDENTIALS_FILTER_PATTERN</a></li>
64
72
<li>The Java API specification for <ahref="https://docs.oracle.com/javase/10/docs/api/javax/management/remote/rmi/RMIConnectorServer.html#CREDENTIAL_TYPES">RMIConnectorServer.CREDENTIAL_TYPES</a>. Please note that this field is deprecated since Java 10.</li>
0 commit comments