Skip to content

Commit 21b5571

Browse files
committed
V1.1 add additional steps for read methods which I can summarize every single declared sanitizer on the sink whitin isSink predicate
1 parent 7354db8 commit 21b5571

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

java/ql/src/experimental/Security/CWE/CWE-522-DecompressionBombs/DecompressionBombStateConfigSig.ql

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ module XserialSnappy {
2929

3030
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
3131
exists(Call call |
32-
call.getCallee().getDeclaringType() instanceof TypeInputStream and
32+
(
33+
call.getCallee().getDeclaringType() instanceof TypeInputStream or
34+
call.(MethodAccess).getReceiverType() instanceof TypeInputStream
35+
) and
3336
call.getArgument(0) = n1.asExpr() and
3437
call = n2.asExpr()
3538
)
@@ -106,7 +109,10 @@ module ApacheCommons {
106109

107110
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
108111
exists(Call call |
109-
call.getCallee().getDeclaringType() instanceof TypeCompressors and
112+
(
113+
call.getCallee().getDeclaringType() instanceof TypeCompressors or
114+
call.(MethodAccess).getReceiverType() instanceof TypeCompressors
115+
) and
110116
call.getArgument(0) = n1.asExpr() and
111117
call = n2.asExpr()
112118
)
@@ -143,9 +149,22 @@ module ApacheCommons {
143149
}
144150
}
145151

152+
/**
153+
*```java
154+
* ZipArchiveInputStream n2 = new ZipArchiveInputStream(n1);
155+
* ZipArchiveInputStream n = new ZipArchiveInputStream(inputStream);
156+
* n2 = n.read(n1);
157+
*```
158+
*/
146159
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
147160
exists(Call call |
148-
call.getCallee().getDeclaringType() instanceof TypeArchivers and
161+
(
162+
// constructors
163+
call.getCallee().getDeclaringType() instanceof TypeArchivers
164+
or
165+
// Method calls
166+
call.(MethodAccess).getReceiverType() instanceof TypeArchivers
167+
) and
149168
n1.asExpr() = call.getArgument(0) and
150169
n2.asExpr() = call
151170
)
@@ -179,12 +198,24 @@ module ApacheCommons {
179198
}
180199
}
181200

201+
/**
202+
* ```java
203+
*CompressorInputStream n2 = new CompressorStreamFactory().createCompressorInputStream(n1)
204+
*ArchiveInputStream n2 = new ArchiveStreamFactory().createArchiveInputStream(n1)
205+
* ```
206+
*/
182207
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
183208
exists(Call call |
184209
(
185-
call.getCallee().getDeclaringType() instanceof TypeCompressors
210+
// Constructors
211+
call.getCallee().getDeclaringType() = any(TypeCompressors t)
186212
or
187-
call.getCallee().getDeclaringType() instanceof TypeArchivers
213+
call.getCallee().getDeclaringType() = any(TypeArchivers t)
214+
or
215+
// Method calls
216+
call.(MethodAccess).getReceiverType() = any(TypeArchiveInputStream t)
217+
or
218+
call.(MethodAccess).getReceiverType() = any(TypeCompressorInputStream t)
188219
) and
189220
n1.asExpr() = call.getArgument(0) and
190221
n2.asExpr() = call
@@ -257,7 +288,10 @@ module Zip4j {
257288
*/
258289
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
259290
exists(Call call |
260-
call.getCallee().getDeclaringType() instanceof TypeZipInputStream and
291+
(
292+
call.getCallee().getDeclaringType() instanceof TypeZipInputStream or
293+
call.(MethodAccess).getReceiverType() instanceof TypeZipInputStream
294+
) and
261295
call.getCallee().hasName(["read", "readNBytes", "readAllBytes"]) and
262296
call.getArgument(0) = n1.asExpr() and
263297
call = n2.asExpr()
@@ -276,7 +310,10 @@ module Zip {
276310

277311
predicate inputStreamAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
278312
exists(Call call |
279-
call.getCallee().getDeclaringType() instanceof TypeZipInputStream and
313+
(
314+
call.getCallee().getDeclaringType() instanceof TypeZipInputStream or
315+
call.(MethodAccess).getReceiverType() instanceof TypeZipInputStream
316+
) and
280317
call.getArgument(0) = n1.asExpr() and
281318
call = n2.asExpr()
282319
)

0 commit comments

Comments
 (0)