Skip to content

Commit 3c09df0

Browse files
committed
Add support for unescape in taint tracking.
1 parent 37bed83 commit 3c09df0

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

javascript/ql/lib/semmle/javascript/dataflow/TaintTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ module TaintTracking {
494494
succ = c and
495495
c =
496496
DataFlow::globalVarRef([
497-
"encodeURI", "decodeURI", "encodeURIComponent", "decodeURIComponent"
497+
"encodeURI", "decodeURI", "encodeURIComponent", "decodeURIComponent", "unescape"
498498
]).getACall() and
499499
pred = c.getArgument(0)
500500
)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
| tst.js:477:18:477:40 | locatio ... bstr(1) | tst.js:477:18:477:30 | location.hash | tst.js:477:18:477:40 | locatio ... bstr(1) | Cross-site scripting vulnerability due to $@. | tst.js:477:18:477:30 | location.hash | user-provided value |
224224
| tst.js:484:33:484:63 | decodeU ... n.hash) | tst.js:484:43:484:62 | window.location.hash | tst.js:484:33:484:63 | decodeU ... n.hash) | Cross-site scripting vulnerability due to $@. | tst.js:484:43:484:62 | window.location.hash | user-provided value |
225225
| tst.js:492:18:492:54 | target. ... "), '') | tst.js:491:16:491:39 | documen ... .search | tst.js:492:18:492:54 | target. ... "), '') | Cross-site scripting vulnerability due to $@. | tst.js:491:16:491:39 | documen ... .search | user-provided value |
226+
| tst.js:501:33:501:62 | unescap ... n.hash) | tst.js:501:42:501:61 | window.location.hash | tst.js:501:33:501:62 | unescap ... n.hash) | Cross-site scripting vulnerability due to $@. | tst.js:501:42:501:61 | window.location.hash | user-provided value |
226227
| 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 |
227228
| 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 |
228229
| 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 |
@@ -745,6 +746,7 @@ edges
745746
| tst.js:491:7:491:39 | target | tst.js:492:18:492:23 | target | provenance | |
746747
| tst.js:491:16:491:39 | documen ... .search | tst.js:491:7:491:39 | target | provenance | |
747748
| tst.js:492:18:492:23 | target | tst.js:492:18:492:54 | target. ... "), '') | provenance | |
749+
| tst.js:501:42:501:61 | window.location.hash | tst.js:501:33:501:62 | unescap ... n.hash) | provenance | |
748750
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target | provenance | |
749751
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target | provenance | |
750752
| typeahead.js:21:12:21:17 | target | typeahead.js:24:30:24:32 | val | provenance | |
@@ -1397,6 +1399,8 @@ nodes
13971399
| tst.js:491:16:491:39 | documen ... .search | semmle.label | documen ... .search |
13981400
| tst.js:492:18:492:23 | target | semmle.label | target |
13991401
| tst.js:492:18:492:54 | target. ... "), '') | semmle.label | target. ... "), '') |
1402+
| tst.js:501:33:501:62 | unescap ... n.hash) | semmle.label | unescap ... n.hash) |
1403+
| tst.js:501:42:501:61 | window.location.hash | semmle.label | window.location.hash |
14001404
| typeahead.js:20:13:20:45 | target | semmle.label | target |
14011405
| typeahead.js:20:22:20:45 | documen ... .search | semmle.label | documen ... .search |
14021406
| typeahead.js:21:12:21:17 | target | semmle.label | target |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ nodes
607607
| tst.js:491:16:491:39 | documen ... .search | semmle.label | documen ... .search |
608608
| tst.js:492:18:492:23 | target | semmle.label | target |
609609
| tst.js:492:18:492:54 | target. ... "), '') | semmle.label | target. ... "), '') |
610+
| tst.js:501:33:501:62 | unescap ... n.hash) | semmle.label | unescap ... n.hash) |
611+
| tst.js:501:42:501:61 | window.location.hash | semmle.label | window.location.hash |
610612
| typeahead.js:9:28:9:30 | loc | semmle.label | loc |
611613
| typeahead.js:10:16:10:18 | loc | semmle.label | loc |
612614
| typeahead.js:20:13:20:45 | target | semmle.label | target |
@@ -1186,6 +1188,7 @@ edges
11861188
| tst.js:491:7:491:39 | target | tst.js:492:18:492:23 | target | provenance | |
11871189
| tst.js:491:16:491:39 | documen ... .search | tst.js:491:7:491:39 | target | provenance | |
11881190
| tst.js:492:18:492:23 | target | tst.js:492:18:492:54 | target. ... "), '') | provenance | |
1191+
| tst.js:501:42:501:61 | window.location.hash | tst.js:501:33:501:62 | unescap ... n.hash) | provenance | |
11891192
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc | provenance | |
11901193
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target | provenance | |
11911194
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target | provenance | |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ function FooBar() {
498498
this.foo = document;
499499
var obj = {
500500
bar: function() {
501-
this.foo.body.innerHTML = unescape(window.location.hash); // $ MISSING: Alert
501+
this.foo.body.innerHTML = unescape(window.location.hash); // $ Alert
502502
}
503503
};
504504
Object.assign(this, obj);

0 commit comments

Comments
 (0)