-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheasyDOMxss.ql
More file actions
66 lines (57 loc) · 1.89 KB
/
Copy patheasyDOMxss.ql
File metadata and controls
66 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import javascript
class DocumentWriteSinks extends DataFlow::Node {
DocumentWriteSinks() {
exists(CallExpr call|
call.getCalleeName() = "write"
and call.getReceiver().toString() = "document"
and this.asExpr() = call.getArgument(0)
)
}
}
class InnerHTMLSinks extends DataFlow::Node {
InnerHTMLSinks(){
exists(DataFlow::PropWrite pw |
pw.getPropertyName().regexpMatch("(innerHTML|outerHTML)")
and pw.getRhs() = this
)
}
}
class LocationHashSource extends DataFlow::Node {
LocationHashSource() {
exists(CallExpr dollarCall, PropAccess pr |
this.asExpr() instanceof CallExpr and
(dollarCall.getCalleeName() = "split"
or dollarCall.getCalleeName() = "substr"
or dollarCall.getCalleeName() = "substring"
) and dollarCall.getReceiver() = pr
and (pr.getBase().toString() = "window.location"
or pr.getBase().toString() = "location")
and this.asExpr() = dollarCall
)
}
}
class DocumentWriteTracker extends TaintTracking::Configuration{
DocumentWriteTracker() {
this = "DocumentWriteTracker"
}
override predicate isSource(DataFlow::Node nd){
nd instanceof LocationHashSource
}
override predicate isSink(DataFlow::Node nd){
nd instanceof DocumentWriteSinks
or nd instanceof InnerHTMLSinks
}
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
exists(CallExpr call |
(call.getCalleeName() = "unescape"
or call.getCalleeName() = "atob"
or call.getCalleeName() = "decodeURI"
or call.getCalleeName() = "decodeURIComponent"
) and succ.asExpr() = call and
pred.asExpr() = call.getArgument(0)
)
}
}
from DocumentWriteTracker pt, DataFlow::Node source, DataFlow::Node sink
where pt.hasFlow(source, sink)
select source,sink