@@ -15,124 +15,16 @@ import cpp
1515import semmle.code.cpp.ir.dataflow.TaintTracking
1616import semmle.code.cpp.security.FlowSources
1717import semmle.code.cpp.commons.File
18- import Bzip2
19- import Brotli
20- import LibArchive
21- import LibMiniz
22- import ZSTD
2318import MiniZip
24- import XZ
2519import ZlibGzopen
26- import ZlibUncompress
27- import ZlibInflator
28- import Brotli
20+ import DecompressionBomb
2921
3022module DecompressionTaintConfig implements DataFlow:: ConfigSig {
3123 predicate isSource ( DataFlow:: Node source ) { source instanceof FlowSource }
3224
3325 predicate isSink ( DataFlow:: Node sink ) {
34- exists ( FunctionCall fc | fc .getTarget ( ) instanceof BrotliDecoderDecompressStreamFunction |
35- fc .getArgument ( 2 ) = sink .asExpr ( )
36- )
37- or
38- exists ( FunctionCall fc | fc .getTarget ( ) instanceof BrotliDecoderDecompressFunction |
39- fc .getArgument ( 1 ) = sink .asExpr ( )
40- )
41- or
42- exists ( FunctionCall fc | fc .getTarget ( ) instanceof BZ2BzDecompressFunction |
43- fc .getArgument ( 0 ) = sink .asExpr ( )
44- )
45- or
46- exists ( FunctionCall fc | fc .getTarget ( ) instanceof BZ2BzReadFunction |
47- fc .getArgument ( 1 ) = sink .asExpr ( )
48- )
49- or
50- exists ( FunctionCall fc | fc .getTarget ( ) instanceof BZ2BzBuffToBuffDecompressFunction |
51- fc .getArgument ( 2 ) = sink .asExpr ( )
52- )
53- or
54- exists ( FunctionCall fc | fc .getTarget ( ) instanceof Archive_read_data_block |
55- fc .getArgument ( 0 ) = sink .asExpr ( )
56- )
57- or
58- exists ( FunctionCall fc | fc .getTarget ( ) instanceof MzUncompress |
59- fc .getArgument ( 0 ) = sink .asExpr ( )
60- )
61- or
62- exists ( FunctionCall fc | fc .getTarget ( ) instanceof MzZipReaderExtract |
63- fc .getArgument ( 1 ) = sink .asExpr ( )
64- )
65- or
66- exists ( FunctionCall fc | fc .getTarget ( ) instanceof MzInflate |
67- fc .getArgument ( 0 ) = sink .asExpr ( )
68- )
69- or
70- exists ( FunctionCall fc | fc .getTarget ( ) instanceof TinflDecompress |
71- fc .getArgument ( 1 ) = sink .asExpr ( )
72- )
73- or
74- exists ( FunctionCall fc | fc .getTarget ( ) instanceof TinflDecompressMem |
75- fc .getArgument ( 0 ) = sink .asExpr ( )
76- )
77- or
78- exists ( FunctionCall fc | fc .getTarget ( ) instanceof ZSTDDecompressFunction |
79- fc .getArgument ( 2 ) = sink .asExpr ( )
80- )
81- or
82- exists ( FunctionCall fc | fc .getTarget ( ) instanceof ZSTDDecompressDCtxFunction |
83- fc .getArgument ( 3 ) = sink .asExpr ( )
84- )
85- or
86- exists ( FunctionCall fc | fc .getTarget ( ) instanceof ZSTDDecompressStreamFunction |
87- fc .getArgument ( 2 ) = sink .asExpr ( )
88- )
89- or
90- exists ( FunctionCall fc | fc .getTarget ( ) instanceof ZSTDDecompressUsingDictFunction |
91- fc .getArgument ( 3 ) = sink .asExpr ( )
92- )
93- or
94- exists ( FunctionCall fc | fc .getTarget ( ) instanceof ZSTDDecompressUsingDDictFunction |
95- fc .getArgument ( 3 ) = sink .asExpr ( )
96- )
97- or
98- exists ( FunctionCall fc | fc .getTarget ( ) instanceof UnzReadCurrentFileFunction |
99- fc .getArgument ( 0 ) = sink .asExpr ( )
100- )
101- or
102- exists ( FunctionCall fc | fc .getTarget ( ) instanceof Mz_zip_reader_entry |
103- fc .getArgument ( 1 ) = sink .asExpr ( )
104- )
105- or
106- exists ( FunctionCall fc | fc .getTarget ( ) instanceof Mz_zip_entry |
107- fc .getArgument ( 1 ) = sink .asExpr ( )
108- )
109- or
110- exists ( FunctionCall fc | fc .getTarget ( ) instanceof LzmaStreamBufferDecodeFunction |
111- fc .getArgument ( 1 ) = sink .asExpr ( )
112- )
113- or
114- exists ( FunctionCall fc | fc .getTarget ( ) instanceof LzmaCodeFunction |
115- fc .getArgument ( 0 ) = sink .asExpr ( )
116- )
117- or
118- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzReadFunction |
119- fc .getArgument ( 0 ) = sink .asExpr ( )
120- )
121- or
122- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzFreadFunction |
123- sink .asExpr ( ) = fc .getArgument ( 3 )
124- )
125- or
126- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzGetsFunction |
127- sink .asExpr ( ) = fc .getArgument ( 0 )
128- )
129- or
130- exists ( FunctionCall fc | fc .getTarget ( ) instanceof InflateFunction |
131- fc .getArgument ( 0 ) = sink .asExpr ( )
132- )
133- or
134- exists ( FunctionCall fc | fc .getTarget ( ) instanceof UncompressFunction |
135- fc .getArgument ( 0 ) = sink .asExpr ( )
26+ exists ( FunctionCall fc , DecompressionFunction f | fc .getTarget ( ) = f |
27+ fc .getArgument ( f .getArchiveParameterIndex ( ) ) = sink .asExpr ( )
13628 )
13729 }
13830
@@ -158,21 +50,6 @@ module DecompressionTaintConfig implements DataFlow::ConfigSig {
15850 node1 .asExpr ( ) = fc .getArgument ( 0 ) and
15951 node2 .asExpr ( ) = fc
16052 )
161- or
162- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzReadFunction |
163- node1 .asExpr ( ) = fc .getArgument ( 0 ) and
164- node2 .asExpr ( ) = fc .getArgument ( 1 )
165- )
166- or
167- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzFreadFunction |
168- node1 .asExpr ( ) = fc .getArgument ( 3 ) and
169- node2 .asExpr ( ) = fc .getArgument ( 0 )
170- )
171- or
172- exists ( FunctionCall fc | fc .getTarget ( ) instanceof GzGetsFunction |
173- node1 .asExpr ( ) = fc .getArgument ( 0 ) and
174- node1 .asExpr ( ) = fc .getArgument ( 1 )
175- )
17653 }
17754}
17855
0 commit comments