Skip to content

Commit 38c9023

Browse files
committed
JS: FlowLabel -> FlowState in ZipSlip
1 parent 0cd01cb commit 38c9023

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/ZipSlipCustomizations.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@ module ZipSlip {
1414
*/
1515
abstract class Source extends DataFlow::Node {
1616
/** Gets a flow label denoting the type of value for which this is a source. */
17-
TaintedPath::Label::PosixPath getAFlowLabel() { result.isRelative() }
17+
TaintedPath::FlowState::PosixPath getAFlowState() { result.isRelative() }
18+
19+
/** DEPRECATED. Use `getAFlowState()` instead. */
20+
deprecated TaintedPath::Label::PosixPath getAFlowLabel() {
21+
result = this.getAFlowState().toFlowLabel()
22+
}
1823
}
1924

2025
/**
2126
* A data flow sink for unsafe archive extraction.
2227
*/
2328
abstract class Sink extends DataFlow::Node {
2429
/** Gets a flow label denoting the type of value for which this is a sink. */
25-
TaintedPath::Label::PosixPath getAFlowLabel() { any() }
30+
TaintedPath::FlowState::PosixPath getAFlowState() { any() }
31+
32+
/** DEPRECATED. Use `getAFlowState()` instead. */
33+
deprecated TaintedPath::Label::PosixPath getAFlowLabel() {
34+
result = this.getAFlowState().toFlowLabel()
35+
}
2636
}
2737

2838
/**

javascript/ql/lib/semmle/javascript/security/dataflow/ZipSlipQuery.qll

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,38 @@ import javascript
1111
import ZipSlipCustomizations::ZipSlip
1212

1313
// Materialize flow labels
14-
private class ConcretePosixPath extends TaintedPath::Label::PosixPath {
14+
deprecated private class ConcretePosixPath extends TaintedPath::Label::PosixPath {
1515
ConcretePosixPath() { this = this }
1616
}
1717

18-
private class ConcreteSplitPath extends TaintedPath::Label::SplitPath {
18+
deprecated private class ConcreteSplitPath extends TaintedPath::Label::SplitPath {
1919
ConcreteSplitPath() { this = this }
2020
}
2121

2222
/** A taint tracking configuration for unsafe archive extraction. */
2323
module ZipSlipConfig implements DataFlow::StateConfigSig {
24-
class FlowState = DataFlow::FlowLabel;
24+
class FlowState = TaintedPath::FlowState;
2525

26-
predicate isSource(DataFlow::Node source, DataFlow::FlowLabel label) {
27-
label = source.(Source).getAFlowLabel()
26+
predicate isSource(DataFlow::Node source, FlowState state) {
27+
state = source.(Source).getAFlowState()
2828
}
2929

30-
predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel label) {
31-
label = sink.(Sink).getAFlowLabel()
32-
}
30+
predicate isSink(DataFlow::Node sink, FlowState state) { state = sink.(Sink).getAFlowState() }
3331

3432
predicate isBarrier(DataFlow::Node node) {
3533
node instanceof TaintedPath::Sanitizer or
3634
node = DataFlow::MakeBarrierGuard<TaintedPath::BarrierGuard>::getABarrierNode()
3735
}
3836

39-
predicate isBarrier(DataFlow::Node node, DataFlow::FlowLabel label) {
40-
node = DataFlow::MakeLabeledBarrierGuard<TaintedPath::BarrierGuard>::getABarrierNode(label)
37+
predicate isBarrier(DataFlow::Node node, FlowState state) {
38+
node =
39+
DataFlow::MakeStateBarrierGuard<FlowState, TaintedPath::BarrierGuard>::getABarrierNode(state)
4140
}
4241

4342
predicate isAdditionalFlowStep(
44-
DataFlow::Node node1, DataFlow::FlowLabel state1, DataFlow::Node node2,
45-
DataFlow::FlowLabel state2
43+
DataFlow::Node node1, FlowState state1, DataFlow::Node node2, FlowState state2
4644
) {
47-
TaintedPath::isAdditionalTaintedPathFlowStep(node1, node2, state1, state2)
45+
TaintedPath::isAdditionalFlowStep(node1, state1, node2, state2)
4846
}
4947
}
5048

@@ -76,6 +74,7 @@ deprecated class Configuration extends DataFlow::Configuration {
7674
DataFlow::Node src, DataFlow::Node dst, DataFlow::FlowLabel srclabel,
7775
DataFlow::FlowLabel dstlabel
7876
) {
79-
ZipSlipConfig::isAdditionalFlowStep(src, srclabel, dst, dstlabel)
77+
ZipSlipConfig::isAdditionalFlowStep(src, TaintedPath::Label::toFlowState(srclabel), dst,
78+
TaintedPath::Label::toFlowState(dstlabel))
8079
}
8180
}

0 commit comments

Comments
 (0)