@@ -17,6 +17,7 @@ import semmle.code.java.dataflow.SSA
17
17
import semmle.code.java.dataflow.TaintTracking
18
18
import DataFlow
19
19
import PathGraph
20
+ private import semmle.code.java.dataflow.ExternalFlow
20
21
21
22
/**
22
23
* A method that returns the name of an archive entry.
@@ -33,34 +34,6 @@ class ArchiveEntryNameMethod extends Method {
33
34
}
34
35
}
35
36
36
- /**
37
- * An expression that will be treated as the destination of a write.
38
- */
39
- class WrittenFileName extends Expr {
40
- WrittenFileName ( ) {
41
- // Constructors that write to their first argument.
42
- exists ( ConstructorCall ctr | this = ctr .getArgument ( 0 ) |
43
- exists ( Class c | ctr .getConstructor ( ) = c .getAConstructor ( ) |
44
- c .hasQualifiedName ( "java.io" , "FileOutputStream" ) or
45
- c .hasQualifiedName ( "java.io" , "RandomAccessFile" ) or
46
- c .hasQualifiedName ( "java.io" , "FileWriter" )
47
- )
48
- )
49
- or
50
- // Methods that write to their n'th argument
51
- exists ( MethodAccess call , int n | this = call .getArgument ( n ) |
52
- call .getMethod ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.nio.file" , "Files" ) and
53
- (
54
- call .getMethod ( ) .getName ( ) .regexpMatch ( "new.*Reader|newOutputStream|create.*" ) and n = 0
55
- or
56
- call .getMethod ( ) .hasName ( "copy" ) and n = 1
57
- or
58
- call .getMethod ( ) .hasName ( "move" ) and n = 1
59
- )
60
- )
61
- }
62
- }
63
-
64
37
/**
65
38
* Holds if `n1` to `n2` is a dataflow step that converts between `String`,
66
39
* `File`, and `Path`.
@@ -151,7 +124,7 @@ class ZipSlipConfiguration extends TaintTracking::Configuration {
151
124
source .asExpr ( ) .( MethodAccess ) .getMethod ( ) instanceof ArchiveEntryNameMethod
152
125
}
153
126
154
- override predicate isSink ( Node sink ) { sink . asExpr ( ) instanceof WrittenFileName }
127
+ override predicate isSink ( Node sink ) { sinkNode ( sink , "create-file" ) }
155
128
156
129
override predicate isAdditionalTaintStep ( Node n1 , Node n2 ) {
157
130
filePathStep ( n1 , n2 ) or fileTaintStep ( n1 , n2 )
0 commit comments