File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
src/experimental/query-tests/Security/CWE/CWE-409
test/experimental/query-tests/Security/CWE/CWE-409 Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ module DecompressionTaintConfig implements DataFlow::ConfigSig {
22
22
23
23
predicate isSink ( DataFlow:: Node sink ) {
24
24
exists ( FunctionCall fc , DecompressionFunction f | fc .getTarget ( ) = f |
25
- fc .getArgument ( f .getArchiveParameterIndex ( ) ) = sink .asExpr ( )
25
+ fc .getArgument ( f .getArchiveParameterIndex ( ) ) = [ sink .asExpr ( ) , sink . asIndirectExpr ( ) ]
26
26
)
27
27
}
28
28
Original file line number Diff line number Diff line change @@ -13,5 +13,5 @@ import DecompressionBomb
13
13
class UncompressFunction extends DecompressionFunction {
14
14
UncompressFunction ( ) { this .hasGlobalName ( [ "uncompress" , "uncompress2" ] ) }
15
15
16
- override int getArchiveParameterIndex ( ) { result = 0 }
16
+ override int getArchiveParameterIndex ( ) { result = 2 }
17
17
}
Original file line number Diff line number Diff line change 1
-
2
1
#define Z_NULL 0
3
2
# define FAR
4
3
typedef unsigned char Byte;
@@ -145,9 +144,32 @@ int UnsafeGzgets(char *fileName) {
145
144
return 0 ;
146
145
}
147
146
147
+ typedef unsigned long uLong;
148
+ typedef long unsigned int size_t ;
149
+ typedef uLong uLongf;
150
+ typedef unsigned char Bytef;
151
+ #define Z_OK 0
152
+
153
+ int uncompress (Bytef *dest, uLongf *destLen,
154
+ const Bytef *source, uLong sourceLen) { return 0 ; }
155
+
156
+ bool InflateString (const unsigned char *input, const unsigned char *output, size_t output_length) {
157
+ uLong source_length;
158
+ source_length = (uLong) 500 ;
159
+ uLong destination_length;
160
+ destination_length = (uLong) output_length;
161
+
162
+ int result = uncompress ((Bytef *) output, &destination_length,
163
+ (Bytef *) input, source_length);
164
+
165
+ return result == Z_OK;
166
+ }
167
+
148
168
int main (int argc, char **argv) {
149
169
UnsafeGzfread (argv[2 ]);
150
170
UnsafeGzgets (argv[2 ]);
151
171
UnsafeInflate (argv[2 ]);
152
172
UnsafeGzread (argv[2 ]);
173
+ const unsigned char *output;
174
+ InflateString (reinterpret_cast <const unsigned char *>(argv[1 ]), output, 1024 * 1024 * 1024 );
153
175
}
You can’t perform that action at this time.
0 commit comments