@@ -17,8 +17,6 @@ import semmle.code.java.controlflow.Guards
1717import semmle.code.java.dataflow.SSA
1818import semmle.code.java.dataflow.TaintTracking
1919import semmle.code.java.security.PathSanitizer
20- import DataFlow
21- import PathGraph
2220private import semmle.code.java.dataflow.ExternalFlow
2321
2422/**
@@ -36,27 +34,29 @@ class ArchiveEntryNameMethod extends Method {
3634 }
3735}
3836
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 ) {
4339 source .asExpr ( ) .( MethodAccess ) .getMethod ( ) instanceof ArchiveEntryNameMethod
4440 }
4541
46- override predicate isSink ( Node sink ) { sink instanceof FileCreationSink }
42+ predicate isSink ( DataFlow :: Node sink ) { sink instanceof FileCreationSink }
4743
48- override predicate isSanitizer ( Node node ) { node instanceof PathInjectionSanitizer }
44+ predicate isBarrier ( DataFlow :: Node node ) { node instanceof PathInjectionSanitizer }
4945}
5046
47+ module ZipSlipFlow = TaintTracking:: Make< ZipSlipConfiguration > ;
48+
49+ import ZipSlipFlow:: PathGraph
50+
5151/**
5252 * A sink that represents a file creation, such as a file write, copy or move operation.
5353 */
5454private class FileCreationSink extends DataFlow:: Node {
5555 FileCreationSink ( ) { sinkNode ( this , "create-file" ) }
5656}
5757
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 )
6060select source .getNode ( ) , source , sink ,
6161 "Unsanitized archive entry, which may contain '..', is used in a $@." , sink .getNode ( ) ,
6262 "file system operation"
0 commit comments