Skip to content

Commit 07b97dc

Browse files
authored
Merge pull request #1672 from asger-semmle/flowlabel-issers
Approved by xiemaisi
2 parents bb4f00d + e09c22e commit 07b97dc

File tree

8 files changed

+29
-14
lines changed

8 files changed

+29
-14
lines changed

javascript/ql/src/Security/Summaries/Shared.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ predicate sourceFlowLabelSpec(DataFlow::FlowLabel lbl, string spec) {
2222
lbl.toString() = spec
2323
or
2424
spec = "" and
25-
lbl = DataFlow::FlowLabel::data()
25+
lbl.isData()
2626
}
2727

2828
/**
@@ -33,7 +33,7 @@ predicate sinkFlowLabelSpec(DataFlow::FlowLabel lbl, string spec) {
3333
lbl.toString() = spec
3434
or
3535
spec = "" and
36-
lbl instanceof DataFlow::StandardFlowLabel
36+
lbl.isDataOrTaint()
3737
}
3838

3939
/**

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ abstract class Configuration extends string {
229229
abstract class FlowLabel extends string {
230230
bindingset[this]
231231
FlowLabel() { any() }
232+
233+
/**
234+
* Holds if this is the standard `FlowLabel::data()` flow label,
235+
* describing values that directly originate from a flow source.
236+
*/
237+
final predicate isData() { this = FlowLabel::data() }
238+
239+
/**
240+
* Holds if this is the standard `FlowLabel::taint()` flow label,
241+
* describing values that are influenced ("tainted") by a flow
242+
* source, but not necessarily directly derived from it.
243+
*/
244+
final predicate isTaint() { this = FlowLabel::taint() }
245+
246+
/**
247+
* Holds if this is one of the standard flow labels `FlowLabel::data()`
248+
* or `FlowLabel::taint()`.
249+
*/
250+
final predicate isDataOrTaint() { isData() or isTaint() }
232251
}
233252

234253
/**

javascript/ql/src/semmle/javascript/security/TaintedObject.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module TaintedObject {
3636
*/
3737
predicate step(Node src, Node trg, FlowLabel inlbl, FlowLabel outlbl) {
3838
// JSON parsers map tainted inputs to tainted JSON
39-
(inlbl = FlowLabel::data() or inlbl = FlowLabel::taint()) and
39+
inlbl.isDataOrTaint() and
4040
outlbl = label() and
4141
exists(JsonParserCall parse |
4242
src = parse.getInput() and

javascript/ql/src/semmle/javascript/security/dataflow/ClientSideUrlRedirect.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module ClientSideUrlRedirect {
4343
) {
4444
queryAccess(pred, succ) and
4545
f instanceof DocumentUrl and
46-
g = DataFlow::FlowLabel::taint()
46+
g.isTaint()
4747
or
4848
// preserve document.url label in step from `location` to `location.href`
4949
f instanceof DocumentUrl and

javascript/ql/src/semmle/javascript/security/dataflow/HardcodedDataInterpretedAsCodeCustomizations.qll

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module HardcodedDataInterpretedAsCode {
1313
*/
1414
abstract class Source extends DataFlow::Node {
1515
/** Gets a flow label for which this is a source. */
16-
DataFlow::FlowLabel getLabel() { result = DataFlow::FlowLabel::data() }
16+
DataFlow::FlowLabel getLabel() { result.isData() }
1717
}
1818

1919
/**
@@ -52,7 +52,7 @@ module HardcodedDataInterpretedAsCode {
5252
private class DefaultCodeInjectionSink extends Sink {
5353
DefaultCodeInjectionSink() { this instanceof CodeInjection::Sink }
5454

55-
override DataFlow::FlowLabel getLabel() { result = DataFlow::FlowLabel::taint() }
55+
override DataFlow::FlowLabel getLabel() { result.isTaint() }
5656

5757
override string getKind() { result = "code" }
5858
}
@@ -63,11 +63,7 @@ module HardcodedDataInterpretedAsCode {
6363
private class RequireArgumentSink extends Sink {
6464
RequireArgumentSink() { this = any(Require r).getAnArgument().flow() }
6565

66-
override DataFlow::FlowLabel getLabel() {
67-
result = DataFlow::FlowLabel::data()
68-
or
69-
result = DataFlow::FlowLabel::taint()
70-
}
66+
override DataFlow::FlowLabel getLabel() { result.isDataOrTaint() }
7167

7268
override string getKind() { result = "an import path" }
7369
}

javascript/ql/src/semmle/javascript/security/dataflow/PostMessageStar.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module PostMessageStar {
5353
src = toString.getArgument(0)
5454
) and
5555
inlbl instanceof PartiallyTaintedObject and
56-
outlbl = DataFlow::FlowLabel::taint()
56+
outlbl.isTaint()
5757
or
5858
// `valueOf` preserves partial taint
5959
trg.(DataFlow::MethodCallNode).calls(src, "valueOf") and

javascript/ql/src/semmle/javascript/security/dataflow/PostMessageStarCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module PostMessageStar {
3434
* Gets either a standard flow label or the partial-taint label.
3535
*/
3636
DataFlow::FlowLabel anyLabel() {
37-
result instanceof DataFlow::StandardFlowLabel or result instanceof PartiallyTaintedObject
37+
result.isDataOrTaint() or result instanceof PartiallyTaintedObject
3838
}
3939

4040
/**

javascript/ql/src/semmle/javascript/security/dataflow/PrototypePollutionCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module PrototypePollution {
6666
private class RemoteFlowAsSource extends Source {
6767
RemoteFlowAsSource() { this instanceof RemoteFlowSource }
6868

69-
override DataFlow::FlowLabel getAFlowLabel() { result = DataFlow::FlowLabel::data() }
69+
override DataFlow::FlowLabel getAFlowLabel() { result.isData() }
7070
}
7171

7272
/**

0 commit comments

Comments
 (0)