@@ -37,27 +37,19 @@ class BombConfiguration extends TaintTracking::Configuration {
37
37
not exists ( source .getALocalSource ( ) .getStringValue ( ) )
38
38
)
39
39
or
40
- exists ( AstNode e |
41
- e =
42
- API:: moduleImport ( "tar" )
43
- .getMember ( [ "x" , "extract" ] )
44
- .getParameter ( 0 )
45
- .asSink ( )
46
- .asExpr ( )
47
- .( ObjectExpr )
48
- .getAChild ( )
49
- .( Property )
50
- |
51
- source .asExpr ( ) = e .getAChild ( ) and
52
- e .getAChild * ( ) .( Label ) .getName ( ) = "file" and
53
- not source .getALocalSource ( ) .mayHaveStringValue ( _)
54
- )
40
+ source =
41
+ API:: moduleImport ( "tar" )
42
+ .getMember ( [ "x" , "extract" ] )
43
+ .getParameter ( 0 )
44
+ .getMember ( "file" )
45
+ .asSink ( ) and
46
+ not source .getALocalSource ( ) .mayHaveStringValue ( _)
55
47
}
56
48
57
49
override predicate isSink ( DataFlow:: Node sink ) {
58
50
// jszip
59
51
exists ( API:: Node loadAsync | loadAsync = API:: moduleImport ( "jszip" ) .getMember ( "loadAsync" ) |
60
- sink = loadAsync .getParameter ( 0 ) .asSink ( ) and jsZipsanitizer ( loadAsync )
52
+ sink = loadAsync .getParameter ( 0 ) .asSink ( ) and not jsZipsanitizer ( loadAsync )
61
53
)
62
54
or
63
55
// node-tar
@@ -69,32 +61,17 @@ class BombConfiguration extends TaintTracking::Configuration {
69
61
sink = tarExtract .getACall ( )
70
62
or
71
63
// tar.x({file: filename})
72
- // and we don't have a "maxReadSize: ANum" option
73
- sink .asExpr ( ) =
74
- tarExtract
75
- .getParameter ( 0 )
76
- .asSink ( )
77
- .asExpr ( )
78
- .( ObjectExpr )
79
- .getAChild ( )
80
- .( Property )
81
- .getAChild * ( ) and
82
- tarExtract
83
- .getParameter ( 0 )
84
- .asSink ( )
85
- .asExpr ( )
86
- .( ObjectExpr )
87
- .getAChild ( )
88
- .( Property )
89
- .getAChild * ( )
90
- .( Label )
91
- .getName ( ) = "file"
64
+ sink = tarExtract .getParameter ( 0 ) .getMember ( "file" ) .asSink ( )
65
+ or
66
+ // tar.x({file: filename})
67
+ sink = tarExtract .getParameter ( 0 ) .getMember ( "file" ) .asSink ( )
92
68
) and
93
- nodeTarSanitizer ( tarExtract )
69
+ // and there shouldn't be a "maxReadSize: ANum" option
70
+ not nodeTarSanitizer ( tarExtract )
94
71
)
95
72
or
96
73
// zlib
97
- // we don 't have a "maxOutputLength: ANum " option
74
+ // there shouldn 't be a "maxOutputLength: ANumber " option
98
75
exists ( API:: Node zlib |
99
76
zlib =
100
77
API:: moduleImport ( "zlib" )
@@ -103,7 +80,7 @@ class BombConfiguration extends TaintTracking::Configuration {
103
80
"createInflateRaw"
104
81
] ) and
105
82
sink = zlib .getACall ( ) and
106
- zlibSanitizer ( zlib , 0 )
83
+ not zlibSanitizer ( zlib . getParameter ( 0 ) )
107
84
or
108
85
zlib =
109
86
API:: moduleImport ( "zlib" )
@@ -112,7 +89,7 @@ class BombConfiguration extends TaintTracking::Configuration {
112
89
"brotliDecompressSync" , "inflateSync" , "inflateRawSync" , "inflate" , "inflateRaw"
113
90
] ) and
114
91
sink = zlib .getACall ( ) .getArgument ( 0 ) and
115
- zlibSanitizer ( zlib , 1 )
92
+ not zlibSanitizer ( zlib . getParameter ( 1 ) )
116
93
)
117
94
or
118
95
// pako
@@ -189,7 +166,6 @@ class BombConfiguration extends TaintTracking::Configuration {
189
166
)
190
167
or
191
168
// pred.pipe(succ)
192
- // I saw many instances like response.pipe(succ) which I couldn't exactly model this pattern
193
169
exists ( DataFlow:: MethodCallNode n |
194
170
n .getMethodName ( ) = "pipe" and
195
171
succ = n .getArgument ( 0 ) and
@@ -200,34 +176,14 @@ class BombConfiguration extends TaintTracking::Configuration {
200
176
}
201
177
202
178
predicate nodeTarSanitizer ( API:: Node tarExtract ) {
203
- not tarExtract
204
- .getParameter ( 0 )
205
- .asSink ( )
206
- .asExpr ( )
207
- .( ObjectExpr )
208
- .getAChild ( )
209
- .( Property )
210
- .getAChild * ( )
211
- .( Label )
212
- .getName ( ) = "maxReadSize"
179
+ exists ( tarExtract .getParameter ( 0 ) .getMember ( "maxReadSize" ) )
213
180
}
214
181
215
182
predicate jsZipsanitizer ( API:: Node loadAsync ) {
216
- not exists ( loadAsync .getASuccessor * ( ) .getMember ( "_data" ) .getMember ( "uncompressedSize" ) )
183
+ exists ( loadAsync .getASuccessor * ( ) .getMember ( "_data" ) .getMember ( "uncompressedSize" ) )
217
184
}
218
185
219
- predicate zlibSanitizer ( API:: Node zlib , int numOfParameter ) {
220
- numOfParameter = [ 0 , 1 ] and
221
- not zlib .getParameter ( numOfParameter )
222
- .asSink ( )
223
- .asExpr ( )
224
- .( ObjectExpr )
225
- .getAChild ( )
226
- .( Property )
227
- .getAChild * ( )
228
- .( Label )
229
- .getName ( ) = "maxOutputLength"
230
- }
186
+ predicate zlibSanitizer ( API:: Node zlib ) { exists ( zlib .getMember ( "maxOutputLength" ) ) }
231
187
232
188
from BombConfiguration cfg , DataFlow:: PathNode source , DataFlow:: PathNode sink
233
189
where cfg .hasFlowPath ( source , sink )
0 commit comments