|
13 | 13 | */ |
14 | 14 |
|
15 | 15 | import java |
16 | | -import semmle.code.java.controlflow.Guards |
17 | | -import semmle.code.java.dataflow.SSA |
18 | | -import semmle.code.java.dataflow.TaintTracking |
19 | | -import semmle.code.java.security.PathSanitizer |
20 | | -private import semmle.code.java.dataflow.ExternalFlow |
21 | | - |
22 | | -/** |
23 | | - * A method that returns the name of an archive entry. |
24 | | - */ |
25 | | -class ArchiveEntryNameMethod extends Method { |
26 | | - ArchiveEntryNameMethod() { |
27 | | - exists(RefType archiveEntry | |
28 | | - archiveEntry.hasQualifiedName("java.util.zip", "ZipEntry") or |
29 | | - archiveEntry.hasQualifiedName("org.apache.commons.compress.archivers", "ArchiveEntry") |
30 | | - | |
31 | | - this.getDeclaringType().getAnAncestor() = archiveEntry and |
32 | | - this.hasName("getName") |
33 | | - ) |
34 | | - } |
35 | | -} |
36 | | - |
37 | | -module ZipSlipConfig implements DataFlow::ConfigSig { |
38 | | - predicate isSource(DataFlow::Node source) { |
39 | | - source.asExpr().(MethodAccess).getMethod() instanceof ArchiveEntryNameMethod |
40 | | - } |
41 | | - |
42 | | - predicate isSink(DataFlow::Node sink) { sink instanceof FileCreationSink } |
43 | | - |
44 | | - predicate isBarrier(DataFlow::Node node) { node instanceof PathInjectionSanitizer } |
45 | | -} |
46 | | - |
47 | | -module ZipSlipFlow = TaintTracking::Global<ZipSlipConfig>; |
48 | | - |
| 16 | +import semmle.code.java.security.ZipSlipQuery |
49 | 17 | import ZipSlipFlow::PathGraph |
50 | 18 |
|
51 | | -/** |
52 | | - * A sink that represents a file creation, such as a file write, copy or move operation. |
53 | | - */ |
54 | | -private class FileCreationSink extends DataFlow::Node { |
55 | | - FileCreationSink() { sinkNode(this, "create-file") } |
56 | | -} |
57 | | - |
58 | 19 | from ZipSlipFlow::PathNode source, ZipSlipFlow::PathNode sink |
59 | 20 | where ZipSlipFlow::flowPath(source, sink) |
60 | 21 | select source.getNode(), source, sink, |
|
0 commit comments