@@ -17,8 +17,6 @@ import semmle.code.java.controlflow.Guards
17
17
import semmle.code.java.dataflow.SSA
18
18
import semmle.code.java.dataflow.TaintTracking
19
19
import semmle.code.java.security.PathSanitizer
20
- import DataFlow
21
- import PathGraph
22
20
private import semmle.code.java.dataflow.ExternalFlow
23
21
24
22
/**
@@ -36,27 +34,29 @@ class ArchiveEntryNameMethod extends Method {
36
34
}
37
35
}
38
36
39
- class ZipSlipConfiguration extends TaintTracking:: Configuration {
40
- ZipSlipConfiguration ( ) { this = "ZipSlip" }
41
-
42
- override predicate isSource ( Node source ) {
37
+ private module ZipSlipConfiguration implements DataFlow:: ConfigSig {
38
+ predicate isSource ( DataFlow:: Node source ) {
43
39
source .asExpr ( ) .( MethodAccess ) .getMethod ( ) instanceof ArchiveEntryNameMethod
44
40
}
45
41
46
- override predicate isSink ( Node sink ) { sink instanceof FileCreationSink }
42
+ predicate isSink ( DataFlow :: Node sink ) { sink instanceof FileCreationSink }
47
43
48
- override predicate isSanitizer ( Node node ) { node instanceof PathInjectionSanitizer }
44
+ predicate isBarrier ( DataFlow :: Node node ) { node instanceof PathInjectionSanitizer }
49
45
}
50
46
47
+ module ZipSlipFlow = TaintTracking:: Make< ZipSlipConfiguration > ;
48
+
49
+ import ZipSlipFlow:: PathGraph
50
+
51
51
/**
52
52
* A sink that represents a file creation, such as a file write, copy or move operation.
53
53
*/
54
54
private class FileCreationSink extends DataFlow:: Node {
55
55
FileCreationSink ( ) { sinkNode ( this , "create-file" ) }
56
56
}
57
57
58
- from PathNode source , PathNode sink
59
- where any ( ZipSlipConfiguration c ) . hasFlowPath ( source , sink )
58
+ from ZipSlipFlow :: PathNode source , ZipSlipFlow :: PathNode sink
59
+ where ZipSlipFlow :: hasFlowPath ( source , sink )
60
60
select source .getNode ( ) , source , sink ,
61
61
"Unsanitized archive entry, which may contain '..', is used in a $@." , sink .getNode ( ) ,
62
62
"file system operation"
0 commit comments