Skip to content

Commit a96ad60

Browse files
committed
C#: Re-factor ZipSlip to use the new API.
1 parent 3e4e75c commit a96ad60

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/ZipSlipQuery.qll

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ abstract class Sanitizer extends DataFlow::ExprNode { }
2727
*/
2828
abstract deprecated class SanitizerGuard extends DataFlow::BarrierGuard { }
2929

30-
/** A taint tracking configuration for Zip Slip */
31-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
30+
/**
31+
* DEPRECATED: Use `ZipSlip` instead.
32+
*
33+
* A taint tracking configuration for Zip Slip.
34+
*/
35+
deprecated class TaintTrackingConfiguration extends TaintTracking::Configuration {
3236
TaintTrackingConfiguration() { this = "ZipSlipTaintTracking" }
3337

3438
override predicate isSource(DataFlow::Node source) { source instanceof Source }
@@ -42,6 +46,22 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
4246
}
4347
}
4448

49+
/**
50+
* A taint tracking configuration for Zip Slip.
51+
*/
52+
private module ZipSlipConfig implements DataFlow::ConfigSig {
53+
predicate isSource(DataFlow::Node source) { source instanceof Source }
54+
55+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
56+
57+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
58+
}
59+
60+
/**
61+
* A taint tracking module for Zip Slip.
62+
*/
63+
module ZipSlip = TaintTracking::Global<ZipSlipConfig>;
64+
4565
/** An access to the `FullName` property of a `ZipArchiveEntry`. */
4666
class ArchiveFullNameSource extends Source {
4767
ArchiveFullNameSource() {

csharp/ql/src/Security Features/CWE-022/ZipSlip.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import csharp
1616
import semmle.code.csharp.security.dataflow.ZipSlipQuery
17-
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
17+
import ZipSlip::PathGraph
1818

19-
from TaintTrackingConfiguration zipTaintTracking, DataFlow::PathNode source, DataFlow::PathNode sink
20-
where zipTaintTracking.hasFlowPath(source, sink)
19+
from ZipSlip::PathNode source, ZipSlip::PathNode sink
20+
where ZipSlip::flowPath(source, sink)
2121
select source.getNode(), source, sink,
2222
"Unsanitized archive entry, which may contain '..', is used in a $@.", sink.getNode(),
2323
"file system operation"

0 commit comments

Comments
 (0)