@@ -17,6 +17,22 @@ module DecompressionBomb {
1717 class AdditionalStep extends Unit {
1818 abstract predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) ;
1919 }
20+
21+ abstract class BombReadInputStreamCall extends MethodCall { }
22+
23+ private class ReadInputStreamQualifierSink extends DecompressionBomb:: Sink {
24+ ReadInputStreamQualifierSink ( ) { this .asExpr ( ) = any ( BombReadInputStreamCall r ) .getQualifier ( ) }
25+ }
26+
27+ abstract class BombTypeInputStream extends RefType { }
28+
29+ private class TypeInputStreamConstructorArgumentSink extends DecompressionBomb:: Sink {
30+ TypeInputStreamConstructorArgumentSink ( ) {
31+ exists ( ConstructorCall call | call .getConstructedType ( ) instanceof BombTypeInputStream |
32+ this .asExpr ( ) = call .getArgument ( 0 )
33+ )
34+ }
35+ }
2036}
2137
2238/**
@@ -26,7 +42,7 @@ module XerialSnappy {
2642 /**
2743 * A type that is responsible for `SnappyInputStream` Class
2844 */
29- class TypeInputStream extends RefType {
45+ class TypeInputStream extends DecompressionBomb :: BombTypeInputStream {
3046 TypeInputStream ( ) {
3147 this .getASupertype * ( ) .hasQualifiedName ( "org.xerial.snappy" , "SnappyInputStream" )
3248 }
@@ -35,7 +51,7 @@ module XerialSnappy {
3551 /**
3652 * The methods that read bytes and belong to `SnappyInputStream` Types
3753 */
38- class ReadInputStreamCall extends MethodCall {
54+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
3955 ReadInputStreamCall ( ) {
4056 this .getReceiverType ( ) instanceof TypeInputStream and
4157 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -127,7 +143,7 @@ module ApacheCommons {
127143 /**
128144 * The methods that read bytes and belong to `*CompressorInputStream` Types
129145 */
130- class ReadInputStreamCall extends MethodCall {
146+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
131147 ReadInputStreamCall ( ) {
132148 this .getReceiverType ( ) instanceof TypeCompressors and
133149 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -172,7 +188,7 @@ module ApacheCommons {
172188 /**
173189 * The methods that read bytes and belong to `*ArchiveInputStream` Types
174190 */
175- class ReadInputStreamCall extends MethodCall {
191+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
176192 ReadInputStreamCall ( ) {
177193 this .getReceiverType ( ) instanceof TypeArchivers and
178194 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -240,7 +256,7 @@ module ApacheCommons {
240256 /**
241257 * The methods that read bytes and belong to `CompressorInputStream` or `ArchiveInputStream` Types
242258 */
243- class ReadInputStreamCall extends MethodCall {
259+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
244260 ReadInputStreamCall ( ) {
245261 (
246262 this .getReceiverType ( ) instanceof TypeArchiveInputStream
@@ -282,7 +298,7 @@ module Zip4j {
282298 /**
283299 * The methods that read bytes and belong to `CompressorInputStream` or `ArchiveInputStream` Types
284300 */
285- class ReadInputStreamCall extends MethodCall {
301+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
286302 ReadInputStreamCall ( ) {
287303 this .getReceiverType ( ) instanceof TypeZipInputStream and
288304 this .getMethod ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
@@ -307,7 +323,7 @@ module Zip {
307323 /**
308324 * The Types that are responsible for `ZipInputStream`, `GZIPInputStream`, `InflaterInputStream` Classes
309325 */
310- class TypeInputStream extends RefType {
326+ class TypeInputStream extends DecompressionBomb :: BombTypeInputStream {
311327 TypeInputStream ( ) {
312328 this .getASupertype * ( )
313329 .hasQualifiedName ( "java.util.zip" ,
@@ -318,7 +334,7 @@ module Zip {
318334 /**
319335 * The methods that read bytes and belong to `*InputStream` Types
320336 */
321- class ReadInputStreamCall extends MethodCall {
337+ class ReadInputStreamCall extends DecompressionBomb :: BombReadInputStreamCall {
322338 ReadInputStreamCall ( ) {
323339 this .getReceiverType ( ) instanceof TypeInputStream and
324340 this .getCallee ( ) .hasName ( [ "read" , "readNBytes" , "readAllBytes" ] )
0 commit comments