File tree Expand file tree Collapse file tree
src/experimental/query-tests/Security/CWE/CWE-409
test/experimental/query-tests/Security/CWE/CWE-409 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ module DecompressionTaintConfig implements DataFlow::ConfigSig {
2222
2323 predicate isSink ( DataFlow:: Node sink ) {
2424 exists ( FunctionCall fc , DecompressionFunction f | fc .getTarget ( ) = f |
25- fc .getArgument ( f .getArchiveParameterIndex ( ) ) = sink .asExpr ( )
25+ fc .getArgument ( f .getArchiveParameterIndex ( ) ) = [ sink .asExpr ( ) , sink . asIndirectExpr ( ) ]
2626 )
2727 }
2828
Original file line number Diff line number Diff line change @@ -13,5 +13,5 @@ import DecompressionBomb
1313class UncompressFunction extends DecompressionFunction {
1414 UncompressFunction ( ) { this .hasGlobalName ( [ "uncompress" , "uncompress2" ] ) }
1515
16- override int getArchiveParameterIndex ( ) { result = 0 }
16+ override int getArchiveParameterIndex ( ) { result = 2 }
1717}
Original file line number Diff line number Diff line change 1-
21#define Z_NULL 0
32# define FAR
43typedef unsigned char Byte;
@@ -145,9 +144,32 @@ int UnsafeGzgets(char *fileName) {
145144 return 0 ;
146145}
147146
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+
148168int main (int argc, char **argv) {
149169 UnsafeGzfread (argv[2 ]);
150170 UnsafeGzgets (argv[2 ]);
151171 UnsafeInflate (argv[2 ]);
152172 UnsafeGzread (argv[2 ]);
173+ const unsigned char *output;
174+ InflateString (reinterpret_cast <const unsigned char *>(argv[1 ]), output, 1024 * 1024 * 1024 );
153175}
You can’t perform that action at this time.
0 commit comments