Skip to content

Commit 399fd85

Browse files
authored
Merge pull request github#9748 from erik-krogh/navigation
JS: add navigation.navigate as an XSS / URL sink
2 parents 578a967 + 0e4954a commit 399fd85

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ module ClientSideUrlRedirect {
106106
) and
107107
xss = true
108108
or
109+
// A call to `navigation.navigate`
110+
this = DataFlow::globalVarRef("navigation").getAMethodCall("navigate").getArgument(0) and
111+
xss = true
112+
or
109113
// An assignment to `location`
110114
exists(Assignment assgn | isLocation(assgn.getTarget()) and astNode = assgn.getRhs()) and
111115
xss = true

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/Xss.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,10 @@ nodes
10261026
| tst.js:476:20:476:22 | url |
10271027
| tst.js:486:22:486:24 | url |
10281028
| tst.js:486:22:486:24 | url |
1029+
| tst.js:491:23:491:35 | location.hash |
1030+
| tst.js:491:23:491:35 | location.hash |
1031+
| tst.js:491:23:491:45 | locatio ... bstr(1) |
1032+
| tst.js:491:23:491:45 | locatio ... bstr(1) |
10291033
| typeahead.js:20:13:20:45 | target |
10301034
| typeahead.js:20:22:20:45 | documen ... .search |
10311035
| typeahead.js:20:22:20:45 | documen ... .search |
@@ -2081,6 +2085,10 @@ edges
20812085
| tst.js:471:13:471:36 | documen ... .search | tst.js:471:13:471:46 | documen ... bstr(1) |
20822086
| tst.js:471:13:471:36 | documen ... .search | tst.js:471:13:471:46 | documen ... bstr(1) |
20832087
| tst.js:471:13:471:46 | documen ... bstr(1) | tst.js:471:7:471:46 | url |
2088+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2089+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2090+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2091+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
20842092
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target |
20852093
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target |
20862094
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target |
@@ -2354,6 +2362,7 @@ edges
23542362
| tst.js:475:25:475:27 | url | tst.js:471:13:471:36 | documen ... .search | tst.js:475:25:475:27 | url | Cross-site scripting vulnerability due to $@. | tst.js:471:13:471:36 | documen ... .search | user-provided value |
23552363
| tst.js:476:20:476:22 | url | tst.js:471:13:471:36 | documen ... .search | tst.js:476:20:476:22 | url | Cross-site scripting vulnerability due to $@. | tst.js:471:13:471:36 | documen ... .search | user-provided value |
23562364
| tst.js:486:22:486:24 | url | tst.js:471:13:471:36 | documen ... .search | tst.js:486:22:486:24 | url | Cross-site scripting vulnerability due to $@. | tst.js:471:13:471:36 | documen ... .search | user-provided value |
2365+
| tst.js:491:23:491:45 | locatio ... bstr(1) | tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) | Cross-site scripting vulnerability due to $@. | tst.js:491:23:491:35 | location.hash | user-provided value |
23572366
| typeahead.js:25:18:25:20 | val | typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:25:18:25:20 | val | Cross-site scripting vulnerability due to $@. | typeahead.js:20:22:20:45 | documen ... .search | user-provided value |
23582367
| v-html.vue:2:8:2:23 | v-html=tainted | v-html.vue:6:42:6:58 | document.location | v-html.vue:2:8:2:23 | v-html=tainted | Cross-site scripting vulnerability due to $@. | v-html.vue:6:42:6:58 | document.location | user-provided value |
23592368
| various-concat-obfuscations.js:4:4:4:31 | "<div>" ... </div>" | various-concat-obfuscations.js:2:16:2:39 | documen ... .search | various-concat-obfuscations.js:4:4:4:31 | "<div>" ... </div>" | Cross-site scripting vulnerability due to $@. | various-concat-obfuscations.js:2:16:2:39 | documen ... .search | user-provided value |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/XssWithAdditionalSources.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,10 @@ nodes
10381038
| tst.js:476:20:476:22 | url |
10391039
| tst.js:486:22:486:24 | url |
10401040
| tst.js:486:22:486:24 | url |
1041+
| tst.js:491:23:491:35 | location.hash |
1042+
| tst.js:491:23:491:35 | location.hash |
1043+
| tst.js:491:23:491:45 | locatio ... bstr(1) |
1044+
| tst.js:491:23:491:45 | locatio ... bstr(1) |
10411045
| typeahead.js:9:28:9:30 | loc |
10421046
| typeahead.js:9:28:9:30 | loc |
10431047
| typeahead.js:9:28:9:30 | loc |
@@ -2143,6 +2147,10 @@ edges
21432147
| tst.js:471:13:471:36 | documen ... .search | tst.js:471:13:471:46 | documen ... bstr(1) |
21442148
| tst.js:471:13:471:36 | documen ... .search | tst.js:471:13:471:46 | documen ... bstr(1) |
21452149
| tst.js:471:13:471:46 | documen ... bstr(1) | tst.js:471:7:471:46 | url |
2150+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2151+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2152+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
2153+
| tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) |
21462154
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |
21472155
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |
21482156
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/tst.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,4 +487,6 @@ function urlStuff() {
487487
}
488488

489489
window.open(location.hash.substr(1)); // OK - any JavaScript is executed in another context
490-
}
490+
491+
navigation.navigate(location.hash.substr(1)); // NOT OK
492+
}

0 commit comments

Comments
 (0)