Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7021ff

Browse files
timolessmowton
andauthored
Apply suggestions from code review
More clear or precise wording within the documentation Co-authored-by: Chris Smowton <[email protected]>
1 parent a65481d commit e7021ff

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

java/ql/src/experimental/Security/CWE/CWE-665/CorrectJmxEnvironmentInitialisation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void initAndStartJmxServer() throws IOException{
2020
String my_filter = "java.lang.String;!*"; // Deny everything but java.lang.String
2121
env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter);
2222

23-
/* Old way
23+
/* Java 9 or below:
2424
env.put("jmx.remote.rmi.server.credential.types",
2525
new String[] { String[].class.getName(), String.class.getName() });
2626
*/

java/ql/src/experimental/Security/CWE/CWE-665/CorrectRmiEnvironmentInitialisation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public void initAndStartRmiServer(int port, String hostname, boolean local) {
1010
String my_filter = "java.lang.String;!*"; // Deny everything but java.lang.String
1111
env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter);
1212

13-
/* Old way
13+
/* Java 9 or below
1414
env.put("jmx.remote.rmi.server.credential.types",
1515
new String[] { String[].class.getName(), String.class.getName() });
1616
*/

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<qhelp>
55
<overview>
66
<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 due to the fact that the
7+
to an unauthenticated remote code execution vulnerability. This is because the
88
RMI/JMX server environment allows attackers to supply arbitrary objects to the authentication
99
method, resulting in the attempted deserialization of an attacker-controlled object.
1010
</overview>
@@ -15,7 +15,7 @@ to be passed as second parameter.
1515
In order to disallow the deserialization of arbitrary objects the passed environment needs to set a deserialization filter.
1616
Ideally this filter only allows the deserialization to <code>java.lang.String</code>.
1717

18-
The filter can be configured by setting the key <code>jmx.remote.rmi.server.credentials.filter.pattern</code> (CONST variable <code>RMIConnectorServer.CREDENTIALS_FILTER_PATTERN</code>).
18+
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>).
1919
The filter should (ideally) only allow java.lang.String and disallow all other classes for deserialization: (<code>"java.lang.String;!*"</code>).
2020

2121
The key-value pair can be set as following:
@@ -27,7 +27,7 @@ Map<String, Object> env = new HashMap<String, Object>;
2727
env.put(RMIConnectorServer.CREDENTIALS_FILTER_PATTERN, my_filter);
2828
</code>
2929

30-
For applications using &lt; Java 10:
30+
For applications using Java 9 or below:
3131

3232
<code>
3333
// This is deprecated in Java 10+ !

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name InsecureRmiJmxAuthenticationEnvironment
3-
* @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.
3+
* @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.
44
* @kind path-problem
55
* @problem.severity error
66
* @tags security
@@ -17,14 +17,14 @@ import DataFlow::PathGraph
1717
import semmle.code.java.dataflow.NullGuards
1818
import semmle.code.java.dataflow.Nullness
1919

20-
/** Predicate which detects vulnerable Constructors */
20+
/** Holds if `constructor` instantiates an RMI or JMX server. */
2121
predicate isRmiOrJmxServerCreateConstructor(Constructor constructor) {
2222
constructor
2323
.getDeclaringType()
2424
.hasQualifiedName("javax.management.remote.rmi", "RMIConnectorServer")
2525
}
2626

27-
/** Predicate which detects vulnerable server creations via methods */
27+
/** Holds if `method` creates an RMI or JMX server. */
2828
predicate isRmiOrJmxServerCreateMethod(Method method) {
2929
method.getName() = "newJMXConnectorServer" and
3030
method.getDeclaringType().hasQualifiedName("javax.management.remote", "JMXConnectorServerFactory")

0 commit comments

Comments
 (0)