@@ -10,18 +10,12 @@ module ResourceExhaustion {
10
10
/**
11
11
* A data flow source for resource exhaustion vulnerabilities.
12
12
*/
13
- abstract class Source extends DataFlow:: Node {
14
- /** Gets a flow label denoting the type of value for which this is a source. */
15
- DataFlow:: FlowLabel getAFlowLabel ( ) { result .isTaint ( ) }
16
- }
13
+ abstract class Source extends DataFlow:: Node { }
17
14
18
15
/**
19
16
* A data flow sink for resource exhaustion vulnerabilities.
20
17
*/
21
18
abstract class Sink extends DataFlow:: Node {
22
- /** Gets a flow label denoting the type of value for which this is a sink. */
23
- DataFlow:: FlowLabel getAFlowLabel ( ) { result instanceof Label:: Number }
24
-
25
19
/**
26
20
* Gets a description of why this is a problematic sink.
27
21
*/
@@ -33,59 +27,19 @@ module ResourceExhaustion {
33
27
*/
34
28
abstract class Sanitizer extends DataFlow:: Node { }
35
29
36
- /**
37
- * Provides data flow labels for resource exhaustion vulnerabilities.
38
- */
39
- module Label {
40
- /**
41
- * A number data flow label.
42
- */
43
- class Number extends DataFlow:: FlowLabel {
44
- Number ( ) { this = "number" }
45
- }
46
- }
47
-
48
30
/**
49
31
* A sanitizer that blocks taint flow if the size of a number is limited.
50
32
*/
51
- class UpperBoundsCheckSanitizerGuard extends TaintTracking:: LabeledSanitizerGuardNode ,
33
+ class UpperBoundsCheckSanitizerGuard extends TaintTracking:: SanitizerGuardNode ,
52
34
DataFlow:: ValueNode {
53
35
override RelationalComparison astNode ;
54
36
55
- override predicate sanitizes ( boolean outcome , Expr e , DataFlow:: FlowLabel label ) {
56
- label instanceof Label:: Number and
57
- (
58
- true = outcome and
59
- e = astNode .getLesserOperand ( )
60
- or
61
- false = outcome and
62
- e = astNode .getGreaterOperand ( )
63
- )
64
- }
65
- }
66
-
67
- /**
68
- * A test of form `typeof x === "something"`, preventing `x` from being a number in some cases.
69
- */
70
- class TypeTestGuard extends TaintTracking:: LabeledSanitizerGuardNode , DataFlow:: ValueNode {
71
- override EqualityTest astNode ;
72
- Expr x ;
73
- boolean polarity ;
74
-
75
- TypeTestGuard ( ) {
76
- // typeof x === "number" sanitizes `x` when it evaluates to false
77
- TaintTracking:: isTypeofGuard ( astNode , x , "number" ) and
78
- polarity = astNode .getPolarity ( ) .booleanNot ( )
37
+ override predicate sanitizes ( boolean outcome , Expr e ) {
38
+ true = outcome and
39
+ e = astNode .getLesserOperand ( )
79
40
or
80
- // typeof x === "string" sanitizes `x` when it evaluates to true
81
- TaintTracking:: isTypeofGuard ( astNode , x , any ( string s | s != "number" ) ) and
82
- polarity = astNode .getPolarity ( )
83
- }
84
-
85
- override predicate sanitizes ( boolean outcome , Expr e , DataFlow:: FlowLabel label ) {
86
- polarity = outcome and
87
- e = x and
88
- label instanceof Label:: Number
41
+ false = outcome and
42
+ e = astNode .getGreaterOperand ( )
89
43
}
90
44
}
91
45
@@ -94,60 +48,6 @@ module ResourceExhaustion {
94
48
RemoteFlowSourceAsSource ( ) { this instanceof RemoteFlowSource }
95
49
}
96
50
97
- /**
98
- * A node that determines the size of a buffer, considered as a data flow sink for resource exhaustion vulnerabilities.
99
- */
100
- class BufferSizeSink extends Sink {
101
- BufferSizeSink ( ) {
102
- exists ( DataFlow:: SourceNode clazz , DataFlow:: InvokeNode invk , int index |
103
- clazz = DataFlow:: globalVarRef ( "Buffer" ) and this = invk .getArgument ( index )
104
- |
105
- exists ( string name |
106
- invk = clazz .getAMemberCall ( name ) and
107
- (
108
- name = "from" and index = 2
109
- or
110
- name = [ "alloc" , "allocUnsafe" , "allocUnsafeSlow" ] and index = 0
111
- )
112
- )
113
- or
114
- invk = clazz .getAnInvocation ( ) and
115
- (
116
- invk .getNumArgument ( ) = 1 and
117
- index = 0
118
- or
119
- invk .getNumArgument ( ) = 3 and index = 2
120
- )
121
- )
122
- or
123
- this = DataFlow:: globalVarRef ( "SlowBuffer" ) .getAnInstantiation ( ) .getArgument ( 0 )
124
- }
125
-
126
- override string getProblemDescription ( ) {
127
- result = "This creates a buffer with a user-controlled size"
128
- }
129
- }
130
-
131
- /**
132
- * A node that determines the size of an array, considered as a data flow sink for resource exhaustion vulnerabilities.
133
- */
134
- class DenseArraySizeSink extends Sink {
135
- DenseArraySizeSink ( ) {
136
- // Arrays are sparse by default, so we must also look at how the array is used
137
- exists ( DataFlow:: ArrayConstructorInvokeNode instance |
138
- this = instance .getArgument ( 0 ) and
139
- instance .getNumArgument ( ) = 1
140
- |
141
- exists ( instance .getAMethodCall ( [ "map" , "fill" , "join" , "toString" ] ) ) or
142
- instance .flowsToExpr ( any ( AddExpr p ) .getAnOperand ( ) )
143
- )
144
- }
145
-
146
- override string getProblemDescription ( ) {
147
- result = "This creates an array with a user-controlled length"
148
- }
149
- }
150
-
151
51
/**
152
52
* A node that determines the repetitions of a string, considered as a data flow sink for resource exhaustion vulnerabilities.
153
53
*/
@@ -159,8 +59,6 @@ module ResourceExhaustion {
159
59
)
160
60
}
161
61
162
- override DataFlow:: FlowLabel getAFlowLabel ( ) { any ( ) }
163
-
164
62
override string getProblemDescription ( ) {
165
63
result = "This creates a string with a user-controlled length"
166
64
}
@@ -175,8 +73,6 @@ module ResourceExhaustion {
175
73
this = LodashUnderscore:: member ( [ "delay" , "throttle" , "debounce" ] ) .getACall ( ) .getArgument ( 1 )
176
74
}
177
75
178
- override DataFlow:: FlowLabel getAFlowLabel ( ) { any ( ) }
179
-
180
76
override string getProblemDescription ( ) {
181
77
result = "This creates a timer with a user-controlled duration"
182
78
}
0 commit comments