Skip to content

Commit 6a09a56

Browse files
authored
Merge pull request github#5931 from atorralba/atorralba/promote-jndi-injection
Java: Promote JNDI Injection query from experimental
2 parents fe654dc + 989afb4 commit 6a09a56

File tree

25 files changed

+725
-691
lines changed

25 files changed

+725
-691
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* The query "JNDI lookup with user-controlled name" (`java/jndi-injection`) has been promoted from experimental to the main query pack. Its results will now appear by default. This query was originally [submitted as an experimental query by @ggolawski](https://github.com/github/codeql/pull/3288).

java/ql/src/experimental/Security/CWE/CWE-074/JndiInjection.qhelp renamed to java/ql/src/Security/CWE/CWE-074/JndiInjection.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ code execution.</p>
1111
</overview>
1212

1313
<recommendation>
14-
<p>The general recommendation is to not pass untrusted data to the <code>InitialContext.lookup
14+
<p>The general recommendation is to avoid passing untrusted data to the <code>InitialContext.lookup
1515
</code> method. If the name being used to look up the object must be provided by the user, make
1616
sure that it's not in the form of an absolute URL or that it's the URL pointing to a trused server.
1717
</p>

java/ql/src/experimental/Security/CWE/CWE-074/JndiInjection.ql renamed to java/ql/src/Security/CWE/CWE-074/JndiInjection.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name JNDI lookup with user-controlled name
3-
* @description Doing a JNDI lookup with user-controlled name can lead to download an untrusted
3+
* @description Performing a JNDI lookup with a user-controlled name can lead to the download of an untrusted
44
* object and to execution of arbitrary code.
55
* @kind path-problem
66
* @problem.severity error
@@ -11,8 +11,7 @@
1111
*/
1212

1313
import java
14-
import semmle.code.java.dataflow.FlowSources
15-
import JndiInjectionLib
14+
import semmle.code.java.security.JndiInjectionQuery
1615
import DataFlow::PathGraph
1716

1817
from DataFlow::PathNode source, DataFlow::PathNode sink, JndiInjectionFlowConfig conf

java/ql/src/experimental/Security/CWE/CWE-074/JndiInjectionLib.qll

Lines changed: 0 additions & 261 deletions
This file was deleted.

java/ql/src/experimental/Security/CWE/CWE-522/InsecureLdapAuth.ql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class InsecureLdapUrlLiteral extends StringLiteral {
3030
}
3131
}
3232

33-
/** The interface `javax.naming.Context`. */
34-
class TypeNamingContext extends Interface {
35-
TypeNamingContext() { this.hasQualifiedName("javax.naming", "Context") }
36-
}
37-
3833
/** The class `java.util.Hashtable`. */
3934
class TypeHashtable extends Class {
4035
TypeHashtable() { this.getSourceDeclaration().hasQualifiedName("java.util", "Hashtable") }

java/ql/src/experimental/semmle/code/java/frameworks/Jndi.qll

Lines changed: 0 additions & 16 deletions
This file was deleted.

java/ql/src/experimental/semmle/code/java/frameworks/Shiro.qll

Lines changed: 0 additions & 6 deletions
This file was deleted.

java/ql/src/experimental/semmle/code/java/frameworks/spring/SpringJndi.qll

Lines changed: 0 additions & 6 deletions
This file was deleted.

java/ql/src/semmle/code/java/JMX.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,20 @@ class JMXRegistrationMethod extends Method {
8686
)
8787
}
8888
}
89+
90+
/** The class `javax.management.remote.JMXConnectorFactory`. */
91+
class TypeJMXConnectorFactory extends Class {
92+
TypeJMXConnectorFactory() {
93+
this.hasQualifiedName("javax.management.remote", "JMXConnectorFactory")
94+
}
95+
}
96+
97+
/** The class `javax.management.remote.JMXServiceURL`. */
98+
class TypeJMXServiceURL extends Class {
99+
TypeJMXServiceURL() { this.hasQualifiedName("javax.management.remote", "JMXServiceURL") }
100+
}
101+
102+
/** The class `javax.management.remote.rmi.RMIConnector`. */
103+
class TypeRMIConnector extends Class {
104+
TypeRMIConnector() { this.hasQualifiedName("javax.management.remote.rmi", "RMIConnector") }
105+
}

0 commit comments

Comments
 (0)