Skip to content

Commit c1b9310

Browse files
committed
add comments for modules & remote local sources
1 parent 9877294 commit c1b9310

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import RemoteSource
2020
import CommandLineSource
2121
import java
2222

23+
/**
24+
* Providing Decompression sinks and additional taint steps for `org.xerial.snappy` package
25+
*/
2326
module XserialSnappy {
2427
class TypeInputStream extends RefType {
2528
TypeInputStream() {
@@ -51,6 +54,9 @@ module XserialSnappy {
5154
}
5255
}
5356

57+
/**
58+
* Providing Decompression sinks and additional taint steps for `org.apache.commons.compress` package
59+
*/
5460
module ApacheCommons {
5561
class TypeArchiveInputStream extends RefType {
5662
TypeArchiveInputStream() {
@@ -240,6 +246,9 @@ module ApacheCommons {
240246
}
241247
}
242248

249+
/**
250+
* Providing Decompression sinks and additional taint steps for `net.lingala.zip4j.io` package
251+
*/
243252
module Zip4j {
244253
class TypeZipInputStream extends RefType {
245254
TypeZipInputStream() {
@@ -299,6 +308,9 @@ module Zip4j {
299308
}
300309
}
301310

311+
/**
312+
* Providing sinks that can be related to reading uncontrolled buffer and bytes for `org.apache.commons.io` package
313+
*/
302314
module CommonsIO {
303315
class IOUtils extends MethodAccess {
304316
IOUtils() {
@@ -312,6 +324,9 @@ module CommonsIO {
312324
}
313325
}
314326

327+
/**
328+
* Providing Decompression sinks and additional taint steps for `java.util.zip` package
329+
*/
315330
module Zip {
316331
class TypeInputStream extends RefType {
317332
TypeInputStream() {
@@ -418,6 +433,9 @@ module Zip {
418433
}
419434
}
420435

436+
/**
437+
* Providing InputStream and it subClasses as Local Decompression sources
438+
*/
421439
module InputStream {
422440
class TypeInputStream extends RefType {
423441
TypeInputStream() { this.getASupertype*().hasQualifiedName("java.io", "InputStream") }
@@ -458,8 +476,6 @@ module DecompressionBombsConfig implements DataFlow::StateConfigSig {
458476
class FlowState = DataFlow::FlowState;
459477

460478
predicate isSource(DataFlow::Node source, FlowState state) {
461-
// any()
462-
// or
463479
(
464480
source instanceof RemoteFlowSource
465481
or
@@ -468,26 +484,15 @@ module DecompressionBombsConfig implements DataFlow::StateConfigSig {
468484
source instanceof FormRemoteFlowSource
469485
or
470486
source instanceof FileUploadRemoteFlowSource
471-
or
472-
// TODO: we have to add Zip*InputStreams instead of general inputStream because of Flow State
473-
source = any(InputStream::Source i).getInputArgument()
474-
or
475-
source.asExpr() instanceof Zip::Inflatorsource
476487
) and
477-
state = ["Zip4j", "inflator", "Zip", "ApacheCommons", "XserialSnappy"]
478-
or
479-
source.asExpr() instanceof Zip::ZipFilesource and
480-
state = "ZipFile"
488+
state = ["ZipFile", "Zip4j", "inflator", "Zip", "ApacheCommons", "XserialSnappy"]
481489
}
482490

483491
predicate isSink(DataFlow::Node sink, FlowState state) {
484492
(
485-
// any() and
486-
// state = "Zip"
487-
// or
488493
exists(CommonsIO::IOUtils ma |
489494
sink.asExpr() = ma.getArgument(0) and
490-
state = ["Zip4j", "inflator", "Zip", "ApacheCommons", "XserialSnappy"]
495+
state = ["Zip4j", "inflator", "Zip", "ApacheCommons", "XserialSnappy", "ZipFile"]
491496
)
492497
or
493498
sink.asExpr() = any(Zip4j::ReadInputStreamCall r).getAWriteArgument() and

0 commit comments

Comments
 (0)