Skip to content

Commit 19db418

Browse files
committed
JS: Add missing store step in Xss query
1 parent e00a8f7 commit 19db418

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ module DomBasedXss {
2828
guard instanceof SanitizerGuard
2929
}
3030

31+
override predicate isAdditionalStoreStep(
32+
DataFlow::Node pred, DataFlow::SourceNode succ, string prop
33+
) {
34+
exists(DataFlow::PropRead read |
35+
pred = read.getBase() and
36+
succ = read and
37+
read.getPropertyName() = "hash" and
38+
prop = urlSuffixPseudoProperty()
39+
)
40+
}
41+
3142
override predicate isAdditionalLoadStoreStep(
3243
DataFlow::Node pred, DataFlow::Node succ, string predProp, string succProp
3344
) {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ nodes
453453
| tst.js:414:19:414:31 | target.taint8 |
454454
| tst.js:415:18:415:30 | target.taint8 |
455455
| tst.js:415:18:415:30 | target.taint8 |
456+
| tst.js:422:7:422:46 | payload |
457+
| tst.js:422:17:422:31 | window.location |
458+
| tst.js:422:17:422:31 | window.location |
459+
| tst.js:422:17:422:46 | window. ... bstr(1) |
460+
| tst.js:423:18:423:24 | payload |
461+
| tst.js:423:18:423:24 | payload |
456462
| typeahead.js:20:13:20:45 | target |
457463
| typeahead.js:20:22:20:38 | document.location |
458464
| typeahead.js:20:22:20:38 | document.location |
@@ -882,6 +888,11 @@ edges
882888
| tst.js:414:19:414:31 | target.taint8 | tst.js:414:19:414:31 | target.taint8 |
883889
| tst.js:414:19:414:31 | target.taint8 | tst.js:415:18:415:30 | target.taint8 |
884890
| tst.js:414:19:414:31 | target.taint8 | tst.js:415:18:415:30 | target.taint8 |
891+
| tst.js:422:7:422:46 | payload | tst.js:423:18:423:24 | payload |
892+
| tst.js:422:7:422:46 | payload | tst.js:423:18:423:24 | payload |
893+
| tst.js:422:17:422:31 | window.location | tst.js:422:17:422:46 | window. ... bstr(1) |
894+
| tst.js:422:17:422:31 | window.location | tst.js:422:17:422:46 | window. ... bstr(1) |
895+
| tst.js:422:17:422:46 | window. ... bstr(1) | tst.js:422:7:422:46 | payload |
885896
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target |
886897
| typeahead.js:20:22:20:38 | document.location | typeahead.js:20:22:20:45 | documen ... .search |
887898
| typeahead.js:20:22:20:38 | document.location | typeahead.js:20:22:20:45 | documen ... .search |
@@ -1009,6 +1020,7 @@ edges
10091020
| tst.js:403:18:403:30 | target.taint5 | tst.js:387:16:387:32 | document.location | tst.js:403:18:403:30 | target.taint5 | Cross-site scripting vulnerability due to $@. | tst.js:387:16:387:32 | document.location | user-provided value |
10101021
| tst.js:412:18:412:30 | target.taint7 | tst.js:387:16:387:32 | document.location | tst.js:412:18:412:30 | target.taint7 | Cross-site scripting vulnerability due to $@. | tst.js:387:16:387:32 | document.location | user-provided value |
10111022
| tst.js:415:18:415:30 | target.taint8 | tst.js:387:16:387:32 | document.location | tst.js:415:18:415:30 | target.taint8 | Cross-site scripting vulnerability due to $@. | tst.js:387:16:387:32 | document.location | user-provided value |
1023+
| tst.js:423:18:423:24 | payload | tst.js:422:17:422:31 | window.location | tst.js:423:18:423:24 | payload | Cross-site scripting vulnerability due to $@. | tst.js:422:17:422:31 | window.location | user-provided value |
10121024
| typeahead.js:25:18:25:20 | val | typeahead.js:20:22:20:38 | document.location | typeahead.js:25:18:25:20 | val | Cross-site scripting vulnerability due to $@. | typeahead.js:20:22:20:38 | document.location | user-provided value |
10131025
| 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 |
10141026
| winjs.js:3:43:3:49 | tainted | winjs.js:2:17:2:33 | document.location | winjs.js:3:43:3:49 | tainted | Cross-site scripting vulnerability due to $@. | winjs.js:2:17:2:33 | document.location | user-provided value |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,7 @@ function test() {
418418
$('myId').html(target.taint9); // OK
419419
}
420420

421+
function hash2() {
422+
var payload = window.location.hash.substr(1);
423+
document.write(payload); // NOT OK
424+
}

0 commit comments

Comments
 (0)