Skip to content

Commit 6b507c6

Browse files
committed
add urlSuffix support to DomBasedXSS
1 parent a850616 commit 6b507c6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,33 @@ module DomBasedXss {
2323
or
2424
node instanceof Sanitizer
2525
}
26+
27+
override predicate isAdditionalLoadStoreStep(
28+
DataFlow::Node pred, DataFlow::Node succ, string predProp, string succProp
29+
) {
30+
exists(DataFlow::PropRead read |
31+
pred = read.getBase() and
32+
succ = read and
33+
read.getPropertyName() = "hash" and
34+
predProp = "hash" and
35+
succProp = urlSuffixPseudoProperty()
36+
)
37+
}
38+
39+
override predicate isAdditionalLoadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
40+
exists(DataFlow::MethodCallNode call, string name |
41+
name = "substr" or name = "substring" or name = "slice"
42+
|
43+
call.getMethodName() = name and
44+
not call.getArgument(0).getIntValue() = 0 and
45+
pred = call.getReceiver() and
46+
succ = call and
47+
prop = urlSuffixPseudoProperty()
48+
)
49+
}
50+
}
51+
52+
private string urlSuffixPseudoProperty() {
53+
result = "$UrlSuffix$"
2654
}
2755
}

0 commit comments

Comments
 (0)