@@ -7,9 +7,11 @@ import semmle.code.java.frameworks.SpringLdap
77import semmle.code.java.security.JndiInjection
88
99/**
10+ * DEPRECATED: Use `JndiInjectionFlow` instead.
11+ *
1012 * A taint-tracking configuration for unvalidated user input that is used in JNDI lookup.
1113 */
12- class JndiInjectionFlowConfig extends TaintTracking:: Configuration {
14+ deprecated class JndiInjectionFlowConfig extends TaintTracking:: Configuration {
1315 JndiInjectionFlowConfig ( ) { this = "JndiInjectionFlowConfig" }
1416
1517 override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -27,14 +29,32 @@ class JndiInjectionFlowConfig extends TaintTracking::Configuration {
2729 }
2830}
2931
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+
3052/**
3153 * A method that does a JNDI lookup when it receives a `SearchControls` argument with `setReturningObjFlag` = `true`
3254 */
3355private class UnsafeSearchControlsSink extends JndiInjectionSink {
3456 UnsafeSearchControlsSink ( ) {
35- exists ( UnsafeSearchControlsConf conf , MethodAccess ma |
36- conf .hasFlowTo ( DataFlow:: exprNode ( ma .getAnArgument ( ) ) )
37- |
57+ exists ( MethodAccess ma | UnsafeSearchControlsFlow:: hasFlowToExpr ( ma .getAnArgument ( ) ) |
3858 this .asExpr ( ) = ma .getArgument ( 0 )
3959 )
4060 }
@@ -44,14 +64,14 @@ private class UnsafeSearchControlsSink extends JndiInjectionSink {
4464 * Find flows between a `SearchControls` object with `setReturningObjFlag` = `true`
4565 * and an argument of an `LdapOperations.search` or `DirContext.search` call.
4666 */
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 }
5169
52- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeSearchControlsArgument }
70+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeSearchControlsArgument }
5371}
5472
73+ private module UnsafeSearchControlsFlow = DataFlow:: Make< UnsafeSearchControlsConfig > ;
74+
5575/**
5676 * An argument of type `SearchControls` of an `LdapOperations.search` or `DirContext.search` call.
5777 */
0 commit comments