@@ -13,27 +13,32 @@ abstract class LdapInjectionSink extends DataFlow::Node { }
13
13
/** A sanitizer that prevents LDAP injection attacks. */
14
14
abstract class LdapInjectionSanitizer extends DataFlow:: Node { }
15
15
16
- /** Holds if the JNDI method parameter at index is susceptible to a LDAP injection attack. */
17
- private predicate jndiLdapInjectionSinkMethod ( Method m , int index ) {
18
- m .getDeclaringType ( ) .getAnAncestor ( ) instanceof TypeDirContext and
19
- m .hasName ( "search" ) and
20
- index in [ 0 .. 1 ]
21
- }
22
-
23
- /**
24
- * JNDI sink for LDAP injection vulnerabilities, i.e. 1st (DN) or 2nd (filter) argument to
25
- * `search` method from `DirContext`.
26
- */
27
- private class JndiLdapInjectionSink extends LdapInjectionSink {
28
- JndiLdapInjectionSink ( ) {
16
+ /** Default sink for LDAP injection vulnerabilities. */
17
+ private class DefaultLdapInjectionSink extends LdapInjectionSink {
18
+ DefaultLdapInjectionSink ( ) {
29
19
exists ( MethodAccess ma , Method m , int index |
30
20
ma .getMethod ( ) = m and
31
21
ma .getArgument ( index ) = this .asExpr ( ) and
32
- jndiLdapInjectionSinkMethod ( m , index )
22
+ ldapInjectionSinkMethod ( m , index )
33
23
)
34
24
}
35
25
}
36
26
27
+ /** Holds if the method parameter at index is susceptible to a LDAP injection attack. */
28
+ private predicate ldapInjectionSinkMethod ( Method m , int index ) {
29
+ jndiLdapInjectionSinkMethod ( m , index ) or
30
+ unboundIdLdapInjectionSinkMethod ( m , index ) or
31
+ springLdapInjectionSinkMethod ( m , index ) or
32
+ apacheLdapInjectionSinkMethod ( m , index )
33
+ }
34
+
35
+ /** Holds if the JNDI method parameter at index is susceptible to a LDAP injection attack. */
36
+ private predicate jndiLdapInjectionSinkMethod ( Method m , int index ) {
37
+ m .getDeclaringType ( ) .getAnAncestor ( ) instanceof TypeDirContext and
38
+ m .hasName ( "search" ) and
39
+ index in [ 0 .. 1 ]
40
+ }
41
+
37
42
/** Holds if the UnboundID method parameter at `index` is susceptible to a LDAP injection attack. */
38
43
private predicate unboundIdLdapInjectionSinkMethod ( Method m , int index ) {
39
44
exists ( Parameter param | m .getParameter ( index ) = param and not param .isVarargs ( ) |
@@ -43,20 +48,6 @@ private predicate unboundIdLdapInjectionSinkMethod(Method m, int index) {
43
48
)
44
49
}
45
50
46
- /**
47
- * UnboundID sink for LDAP injection vulnerabilities,
48
- * i.e. LDAPConnection.search, LDAPConnection.asyncSearch or LDAPConnection.searchForEntry method.
49
- */
50
- private class UnboundedIdLdapInjectionSink extends LdapInjectionSink {
51
- UnboundedIdLdapInjectionSink ( ) {
52
- exists ( MethodAccess ma , Method m , int index |
53
- ma .getMethod ( ) = m and
54
- ma .getArgument ( index ) = this .asExpr ( ) and
55
- unboundIdLdapInjectionSinkMethod ( m , index )
56
- )
57
- }
58
- }
59
-
60
51
/** Holds if the Spring method parameter at `index` is susceptible to a LDAP injection attack. */
61
52
private predicate springLdapInjectionSinkMethod ( Method m , int index ) {
62
53
// LdapTemplate.authenticate, LdapTemplate.find* or LdapTemplate.search* method
@@ -80,20 +71,6 @@ private predicate springLdapInjectionSinkMethod(Method m, int index) {
80
71
)
81
72
}
82
73
83
- /**
84
- * Spring LDAP sink for LDAP injection vulnerabilities,
85
- * i.e. LdapTemplate.authenticate, LdapTemplate.find* or LdapTemplate.search* method.
86
- */
87
- private class SpringLdapInjectionSink extends LdapInjectionSink {
88
- SpringLdapInjectionSink ( ) {
89
- exists ( MethodAccess ma , Method m , int index |
90
- ma .getMethod ( ) = m and
91
- ma .getArgument ( index ) = this .asExpr ( ) and
92
- springLdapInjectionSinkMethod ( m , index )
93
- )
94
- }
95
- }
96
-
97
74
/** Holds if the Apache LDAP API method parameter at `index` is susceptible to a LDAP injection attack. */
98
75
private predicate apacheLdapInjectionSinkMethod ( Method m , int index ) {
99
76
exists ( Parameter param | m .getParameter ( index ) = param and not param .isVarargs ( ) |
@@ -102,17 +79,6 @@ private predicate apacheLdapInjectionSinkMethod(Method m, int index) {
102
79
)
103
80
}
104
81
105
- /** Apache LDAP API sink for LDAP injection vulnerabilities, i.e. LdapConnection.search method. */
106
- private class ApacheLdapInjectionSink extends LdapInjectionSink {
107
- ApacheLdapInjectionSink ( ) {
108
- exists ( MethodAccess ma , Method m , int index |
109
- ma .getMethod ( ) = m and
110
- ma .getArgument ( index ) = this .asExpr ( ) and
111
- apacheLdapInjectionSinkMethod ( m , index )
112
- )
113
- }
114
- }
115
-
116
82
/** A sanitizer that clears the taint on primitive types. */
117
83
private class PrimitiveTypeLdapSanitizer extends LdapInjectionSanitizer {
118
84
PrimitiveTypeLdapSanitizer ( ) { this .getType ( ) instanceof PrimitiveType }
0 commit comments