@@ -7,9 +7,11 @@ import semmle.code.java.frameworks.SpringLdap
7
7
import semmle.code.java.security.JndiInjection
8
8
9
9
/**
10
+ * DEPRECATED: Use `JndiInjectionFlow` instead.
11
+ *
10
12
* A taint-tracking configuration for unvalidated user input that is used in JNDI lookup.
11
13
*/
12
- class JndiInjectionFlowConfig extends TaintTracking:: Configuration {
14
+ deprecated class JndiInjectionFlowConfig extends TaintTracking:: Configuration {
13
15
JndiInjectionFlowConfig ( ) { this = "JndiInjectionFlowConfig" }
14
16
15
17
override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -27,14 +29,32 @@ class JndiInjectionFlowConfig extends TaintTracking::Configuration {
27
29
}
28
30
}
29
31
32
+ /**
33
+ * A taint-tracking configuration for unvalidated user input that is used in JNDI lookup.
34
+ */
35
+ private module JndiInjectionFlowConfig implements DataFlow:: ConfigSig {
36
+ predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
37
+
38
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof JndiInjectionSink }
39
+
40
+ predicate isBarrier ( DataFlow:: Node node ) {
41
+ node .getType ( ) instanceof PrimitiveType or node .getType ( ) instanceof BoxedType
42
+ }
43
+
44
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
45
+ any ( JndiInjectionAdditionalTaintStep c ) .step ( node1 , node2 )
46
+ }
47
+ }
48
+
49
+ /** Tracks flow of unvalidated user input that is used in JNDI lookup */
50
+ module JndiInjectionFlow = TaintTracking:: Make< JndiInjectionFlowConfig > ;
51
+
30
52
/**
31
53
* A method that does a JNDI lookup when it receives a `SearchControls` argument with `setReturningObjFlag` = `true`
32
54
*/
33
55
private class UnsafeSearchControlsSink extends JndiInjectionSink {
34
56
UnsafeSearchControlsSink ( ) {
35
- exists ( UnsafeSearchControlsConf conf , MethodAccess ma |
36
- conf .hasFlowTo ( DataFlow:: exprNode ( ma .getAnArgument ( ) ) )
37
- |
57
+ exists ( MethodAccess ma | UnsafeSearchControlsFlow:: hasFlowToExpr ( ma .getAnArgument ( ) ) |
38
58
this .asExpr ( ) = ma .getArgument ( 0 )
39
59
)
40
60
}
@@ -44,14 +64,14 @@ private class UnsafeSearchControlsSink extends JndiInjectionSink {
44
64
* Find flows between a `SearchControls` object with `setReturningObjFlag` = `true`
45
65
* and an argument of an `LdapOperations.search` or `DirContext.search` call.
46
66
*/
47
- private class UnsafeSearchControlsConf extends DataFlow2:: Configuration {
48
- UnsafeSearchControlsConf ( ) { this = "UnsafeSearchControlsConf" }
49
-
50
- override predicate isSource ( DataFlow:: Node source ) { source instanceof UnsafeSearchControls }
67
+ private module UnsafeSearchControlsConfig implements DataFlow:: ConfigSig {
68
+ predicate isSource ( DataFlow:: Node source ) { source instanceof UnsafeSearchControls }
51
69
52
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeSearchControlsArgument }
70
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeSearchControlsArgument }
53
71
}
54
72
73
+ private module UnsafeSearchControlsFlow = DataFlow:: Make< UnsafeSearchControlsConfig > ;
74
+
55
75
/**
56
76
* An argument of type `SearchControls` of an `LdapOperations.search` or `DirContext.search` call.
57
77
*/
0 commit comments