Skip to content

Commit d0478ea

Browse files
authored
XML validation and spelling/ordering changes
* XML validation and summary changes in qhelp file ; * Encode entities within <code> snippet * Updated minor descriptions and examples * Implemented spelling review
1 parent 4ddf455 commit d0478ea

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

java/ql/src/experimental/Security/CWE/CWE-665/InsecureRmiJmxEnvironmentConfiguration.qhelp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,42 @@
22
"-//Semmle//qhelp//EN"
33
"qhelp.dtd">
44
<qhelp>
5+
56
<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+
1018
</overview>
1119

1220
<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>
1523

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>
1826

19-
The key-value pair can be set as following:
27+
<p>The key-value pair can be set as following:</p>
2028

2129
<code>
2230
String stringsOnlyFilter = "java.lang.String;!*"; // Deny everything but java.lang.String
2331

24-
Map<String, Object> env = new HashMap<String, Object>;
32+
Map&lt;String, Object&gt; env = new HashMap&lt;String, Object&gt;;
2533
env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, stringsOnlyFilter);
2634
</code>
2735

28-
For applications using Java 9 or below:
36+
<p>For applications using Java 6u113 to 9:</p>
2937

3038
<code>
3139
// This is deprecated in Java 10+ !
32-
Map<String, Object> env = new HashMap<String, Object>;
40+
Map&lt;String, Object&gt; env = new HashMap&lt;String, Object&gt;;
3341
env.put (
3442
"jmx.remote.rmi.server.credential.types",
3543
new String[]{
@@ -39,20 +47,20 @@ env.put (
3947
);
4048
</code>
4149

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>
4452
</recommendation>
4553

4654
<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>
4856

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>
5058

51-
<sample src="CorrectRmiInitialisation.java">
59+
<sample src="CorrectJmxInitialisation.java" />
5260

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>
5462

55-
<sample src="CorrectJmxInitialisation.java">
63+
<sample src="CorrectRmiInitialisation.java" />
5664

5765
</example>
5866

@@ -63,4 +71,5 @@ For this reason an initialization with a <code>null</code> environment is also v
6371
<li>Java 10 API specification for <a href="https://docs.oracle.com/javase/10/docs/api/javax/management/remote/rmi/RMIConnectorServer.html#CREDENTIALS_FILTER_PATTERN">RMIConnectorServer.CREDENTIALS_FILTER_PATTERN</a></li>
6472
<li>The Java API specification for <a href="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>
6573
</references>
74+
6675
</qhelp>

0 commit comments

Comments
 (0)