1
1
import java
2
2
import semmle.code.java.dataflow.FlowSources
3
- import semmle.code.java.dataflow.TaintTracking2
4
3
import DataFlow
5
4
6
5
/**
@@ -26,140 +25,22 @@ class SetRevocationEnabledSink extends DataFlow::ExprNode {
26
25
exists ( MethodAccess setRevocationEnabledCall |
27
26
setRevocationEnabledCall .getMethod ( ) instanceof SetRevocationEnabledMethod and
28
27
setRevocationEnabledCall .getArgument ( 0 ) = getExpr ( ) and
29
- not exists (
30
- SettingRevocationCheckerConfig config , DataFlow2:: PathNode source , DataFlow2:: PathNode sink
31
- |
32
- config .hasFlowPath ( source , sink ) and
33
- sink .getNode ( ) .( SettingRevocationCheckerSink ) .getVariable ( ) =
28
+ not exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
29
+ ( m instanceof AddCertPathCheckerMethod or m instanceof SetCertPathCheckersMethod ) and
30
+ ma .getQualifier ( ) .( VarAccess ) .getVariable ( ) =
34
31
setRevocationEnabledCall .getQualifier ( ) .( VarAccess ) .getVariable ( )
35
32
)
36
33
)
37
34
}
38
35
}
39
36
40
- /**
41
- * A dataflow config for tracking a custom revocation checker.
42
- */
43
- class SettingRevocationCheckerConfig extends DataFlow2:: Configuration {
44
- SettingRevocationCheckerConfig ( ) {
45
- this = "DisabledRevocationChecking::SettingRevocationCheckerConfig"
46
- }
47
-
48
- override predicate isSource ( DataFlow:: Node source ) {
49
- source instanceof GetRevocationCheckerSource
50
- }
51
-
52
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof SettingRevocationCheckerSink }
53
-
54
- override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
55
- createSingletonListStep ( node1 , node2 ) or
56
- createListOfElementsStep ( node1 , node2 ) or
57
- convertArrayToListStep ( node1 , node2 ) or
58
- addToListStep ( node1 , node2 )
59
- }
60
-
61
- override int fieldFlowBranchLimit ( ) { result = 0 }
62
- }
63
-
64
- /**
65
- * A source that creates a custom revocation checker,
66
- * i.e. `CertPathValidator.getRevocationChecker()`.
67
- */
68
- class GetRevocationCheckerSource extends DataFlow:: ExprNode {
69
- GetRevocationCheckerSource ( ) {
70
- exists ( MethodAccess ma | ma .getMethod ( ) instanceof GetRevocationCheckerMethod |
71
- ma = asExpr ( ) or ma .getQualifier ( ) = asExpr ( )
72
- )
73
- }
74
- }
75
-
76
- /**
77
- * A sink that sets a custom revocation checker in `PKIXParameters`,
78
- * i.e. `PKIXParameters.addCertPathChecker()` or `PKIXParameters.setCertPathCheckers()`.
79
- */
80
- class SettingRevocationCheckerSink extends DataFlow:: ExprNode {
81
- MethodAccess ma ;
82
-
83
- SettingRevocationCheckerSink ( ) {
84
- (
85
- ma .getMethod ( ) instanceof AddCertPathCheckerMethod or
86
- ma .getMethod ( ) instanceof SetCertPathCheckersMethod
87
- ) and
88
- ma .getArgument ( 0 ) = asExpr ( )
89
- }
90
-
91
- Variable getVariable ( ) { result = ma .getQualifier ( ) .( VarAccess ) .getVariable ( ) }
92
- }
93
-
94
- /**
95
- * Holds if `node1` to `node2` is a dataflow step that creates a singleton list,
96
- * i.e. `Collections.singletonList(element)`.
97
- */
98
- predicate createSingletonListStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
99
- exists ( StaticMethodAccess ma , Method m | m = ma .getMethod ( ) |
100
- m .getDeclaringType ( ) instanceof Collections and
101
- m .hasName ( "singletonList" ) and
102
- ma .getArgument ( 0 ) = node1 .asExpr ( ) and
103
- ma = node2 .asExpr ( )
104
- )
105
- }
106
-
107
- /**
108
- * Holds if `node1` to `node2` is a dataflow step that converts an array to a list
109
- * i.e. `Arrays.asList(element)`.
110
- */
111
- predicate convertArrayToListStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
112
- exists ( StaticMethodAccess ma , Method m | m = ma .getMethod ( ) |
113
- m .getDeclaringType ( ) instanceof Arrays and
114
- m .hasName ( "asList" ) and
115
- ma .getArgument ( 0 ) = node1 .asExpr ( ) and
116
- ma = node2 .asExpr ( )
117
- )
118
- }
119
-
120
- /**
121
- * Holds if `node1` to `node2` is a dataflow step that adds an element to a list,
122
- * i.e. `list.add(element)` or `list.addAll(elements)`.
123
- */
124
- predicate addToListStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
125
- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
126
- m .getDeclaringType ( ) instanceof List and
127
- (
128
- m .hasName ( "add" ) or
129
- m .hasName ( "addAll" )
130
- ) and
131
- ma .getArgument ( 0 ) = node1 .asExpr ( ) and
132
- ma .getQualifier ( ) = node2 .asExpr ( )
133
- )
134
- }
135
-
136
- /**
137
- * Holds if `node1` to `node2` is a dataflow step that creates a list,
138
- * i.e. `List.of(element)`.
139
- */
140
- predicate createListOfElementsStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
141
- exists ( StaticMethodAccess ma , Method m | m = ma .getMethod ( ) |
142
- m .getDeclaringType ( ) instanceof List and
143
- m .hasName ( "of" ) and
144
- ma .getAnArgument ( ) = node1 .asExpr ( ) and
145
- ma = node2 .asExpr ( )
146
- )
147
- }
148
-
149
37
class SetRevocationEnabledMethod extends Method {
150
38
SetRevocationEnabledMethod ( ) {
151
39
getDeclaringType ( ) instanceof PKIXParameters and
152
40
hasName ( "setRevocationEnabled" )
153
41
}
154
42
}
155
43
156
- class GetRevocationCheckerMethod extends Method {
157
- GetRevocationCheckerMethod ( ) {
158
- getDeclaringType ( ) instanceof CertPathValidator and
159
- hasName ( "getRevocationChecker" )
160
- }
161
- }
162
-
163
44
class AddCertPathCheckerMethod extends Method {
164
45
AddCertPathCheckerMethod ( ) {
165
46
getDeclaringType ( ) instanceof PKIXParameters and
@@ -177,22 +58,3 @@ class SetCertPathCheckersMethod extends Method {
177
58
class PKIXParameters extends RefType {
178
59
PKIXParameters ( ) { hasQualifiedName ( "java.security.cert" , "PKIXParameters" ) }
179
60
}
180
-
181
- class CertPathValidator extends RefType {
182
- CertPathValidator ( ) { hasQualifiedName ( "java.security.cert" , "CertPathValidator" ) }
183
- }
184
-
185
- class Collections extends RefType {
186
- Collections ( ) { hasQualifiedName ( "java.util" , "Collections" ) }
187
- }
188
-
189
- class Arrays extends RefType {
190
- Arrays ( ) { hasQualifiedName ( "java.util" , "Arrays" ) }
191
- }
192
-
193
- class List extends RefType {
194
- List ( ) {
195
- this .hasQualifiedName ( "java.util" , "List<>" ) or
196
- this .( ParameterizedInterface ) .getGenericType ( ) .hasQualifiedName ( "java.util" , "List" )
197
- }
198
- }
0 commit comments