Skip to content

Commit 4568967

Browse files
committed
JS: Do not use legacy taint steps in TaintedUrlSuffix
Tainted URL suffix steps are added as configuration-specific additional steps, which means implicit reads may occur before any of these steps. These steps accidentally included the legacy taint steps which include a step from 'arguments' to all positional parameters. Combined with the implicit read, arguments could escape their array index and flow to any parameter while in the tainted-url flow state.
1 parent 65a36b0 commit 4568967

File tree

4 files changed

+3
-37
lines changed

4 files changed

+3
-37
lines changed

javascript/ql/lib/semmle/javascript/security/TaintedUrlSuffix.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module TaintedUrlSuffix {
5454
// Inherit all ordinary taint steps except `x -> x.p` steps
5555
srclbl = label() and
5656
dstlbl = label() and
57-
TaintTracking::sharedTaintStep(src, dst) and
57+
TaintTracking::AdditionalTaintStep::step(src, dst) and
5858
not isSafeLocationProp(dst)
5959
or
6060
// Transition from URL suffix to full taint when extracting the query/fragment part.

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,8 @@ nodes
330330
| string-manipulations.js:9:36:9:57 | documen ... on.href | semmle.label | documen ... on.href |
331331
| string-manipulations.js:10:16:10:45 | String( ... n.href) | semmle.label | String( ... n.href) |
332332
| string-manipulations.js:10:23:10:44 | documen ... on.href | semmle.label | documen ... on.href |
333-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | semmle.label | 'arguments' object of function foo [1] |
334-
| tainted-url-suffix-arguments.js:3:14:3:14 | x | semmle.label | x |
335333
| tainted-url-suffix-arguments.js:3:17:3:17 | y | semmle.label | y |
336-
| tainted-url-suffix-arguments.js:3:20:3:20 | z | semmle.label | z |
337-
| tainted-url-suffix-arguments.js:5:22:5:22 | x | semmle.label | x |
338334
| tainted-url-suffix-arguments.js:6:22:6:22 | y | semmle.label | y |
339-
| tainted-url-suffix-arguments.js:7:22:7:22 | z | semmle.label | z |
340335
| tainted-url-suffix-arguments.js:11:11:11:36 | url | semmle.label | url |
341336
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | semmle.label | window.location.href |
342337
| tainted-url-suffix-arguments.js:12:17:12:19 | url | semmle.label | url |
@@ -426,7 +421,6 @@ nodes
426421
| tst.js:64:25:64:48 | documen ... .search | semmle.label | documen ... .search |
427422
| tst.js:65:25:65:48 | documen ... .search | semmle.label | documen ... .search |
428423
| tst.js:68:16:68:20 | bar() | semmle.label | bar() |
429-
| tst.js:70:1:70:27 | [,docum ... search] | semmle.label | [,docum ... search] |
430424
| tst.js:70:1:70:27 | [,docum ... search] [1] | semmle.label | [,docum ... search] [1] |
431425
| tst.js:70:3:70:26 | documen ... .search | semmle.label | documen ... .search |
432426
| tst.js:70:46:70:46 | x | semmle.label | x |
@@ -959,15 +953,9 @@ edges
959953
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | provenance | Config |
960954
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | |
961955
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | Config |
962-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:14:3:14 | x | provenance | Config |
963-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:17:3:17 | y | provenance | Config |
964-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:20:3:20 | z | provenance | Config |
965-
| tainted-url-suffix-arguments.js:3:14:3:14 | x | tainted-url-suffix-arguments.js:5:22:5:22 | x | provenance | |
966956
| tainted-url-suffix-arguments.js:3:17:3:17 | y | tainted-url-suffix-arguments.js:6:22:6:22 | y | provenance | |
967-
| tainted-url-suffix-arguments.js:3:20:3:20 | z | tainted-url-suffix-arguments.js:7:22:7:22 | z | provenance | |
968957
| tainted-url-suffix-arguments.js:11:11:11:36 | url | tainted-url-suffix-arguments.js:12:17:12:19 | url | provenance | |
969958
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:11:11:11:36 | url | provenance | |
970-
| tainted-url-suffix-arguments.js:12:17:12:19 | url | tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | provenance | |
971959
| tainted-url-suffix-arguments.js:12:17:12:19 | url | tainted-url-suffix-arguments.js:3:17:3:17 | y | provenance | |
972960
| tooltip.jsx:6:11:6:30 | source | tooltip.jsx:10:25:10:30 | source | provenance | |
973961
| tooltip.jsx:6:11:6:30 | source | tooltip.jsx:11:25:11:30 | source | provenance | |
@@ -1053,11 +1041,7 @@ edges
10531041
| tst.js:60:34:60:34 | s | tst.js:62:18:62:18 | s | provenance | |
10541042
| tst.js:64:25:64:48 | documen ... .search | tst.js:60:34:60:34 | s | provenance | |
10551043
| tst.js:65:25:65:48 | documen ... .search | tst.js:60:34:60:34 | s | provenance | |
1056-
| tst.js:70:1:70:27 | [,docum ... search] | tst.js:70:46:70:46 | x | provenance | |
1057-
| tst.js:70:1:70:27 | [,docum ... search] | tst.js:70:46:70:46 | x | provenance | Config |
10581044
| tst.js:70:1:70:27 | [,docum ... search] [1] | tst.js:70:46:70:46 | x | provenance | |
1059-
| tst.js:70:1:70:27 | [,docum ... search] [1] | tst.js:70:46:70:46 | x | provenance | Config |
1060-
| tst.js:70:3:70:26 | documen ... .search | tst.js:70:1:70:27 | [,docum ... search] | provenance | Config |
10611045
| tst.js:70:3:70:26 | documen ... .search | tst.js:70:1:70:27 | [,docum ... search] [1] | provenance | |
10621046
| tst.js:70:46:70:46 | x | tst.js:73:20:73:20 | x | provenance | |
10631047
| tst.js:107:7:107:44 | v | tst.js:110:18:110:18 | v | provenance | |
@@ -1398,9 +1382,7 @@ subpaths
13981382
| string-manipulations.js:8:16:8:48 | documen ... mLeft() | string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() | Cross-site scripting vulnerability due to $@. | string-manipulations.js:8:16:8:37 | documen ... on.href | user-provided value |
13991383
| string-manipulations.js:9:16:9:58 | String. ... n.href) | string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:9:36:9:57 | documen ... on.href | user-provided value |
14001384
| string-manipulations.js:10:16:10:45 | String( ... n.href) | string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | Cross-site scripting vulnerability due to $@. | string-manipulations.js:10:23:10:44 | documen ... on.href | user-provided value |
1401-
| tainted-url-suffix-arguments.js:5:22:5:22 | x | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:5:22:5:22 | x | Cross-site scripting vulnerability due to $@. | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | user-provided value |
14021385
| tainted-url-suffix-arguments.js:6:22:6:22 | y | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:6:22:6:22 | y | Cross-site scripting vulnerability due to $@. | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | user-provided value |
1403-
| tainted-url-suffix-arguments.js:7:22:7:22 | z | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:7:22:7:22 | z | Cross-site scripting vulnerability due to $@. | tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | user-provided value |
14041386
| tooltip.jsx:10:25:10:30 | source | tooltip.jsx:6:20:6:30 | window.name | tooltip.jsx:10:25:10:30 | source | Cross-site scripting vulnerability due to $@. | tooltip.jsx:6:20:6:30 | window.name | user-provided value |
14051387
| tooltip.jsx:11:25:11:30 | source | tooltip.jsx:6:20:6:30 | window.name | tooltip.jsx:11:25:11:30 | source | Cross-site scripting vulnerability due to $@. | tooltip.jsx:6:20:6:30 | window.name | user-provided value |
14061388
| tooltip.jsx:18:51:18:59 | provide() | tooltip.jsx:22:20:22:30 | window.name | tooltip.jsx:18:51:18:59 | provide() | Cross-site scripting vulnerability due to $@. | tooltip.jsx:22:20:22:30 | window.name | user-provided value |

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,8 @@ nodes
335335
| string-manipulations.js:9:36:9:57 | documen ... on.href | semmle.label | documen ... on.href |
336336
| string-manipulations.js:10:16:10:45 | String( ... n.href) | semmle.label | String( ... n.href) |
337337
| string-manipulations.js:10:23:10:44 | documen ... on.href | semmle.label | documen ... on.href |
338-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | semmle.label | 'arguments' object of function foo [1] |
339-
| tainted-url-suffix-arguments.js:3:14:3:14 | x | semmle.label | x |
340338
| tainted-url-suffix-arguments.js:3:17:3:17 | y | semmle.label | y |
341-
| tainted-url-suffix-arguments.js:3:20:3:20 | z | semmle.label | z |
342-
| tainted-url-suffix-arguments.js:5:22:5:22 | x | semmle.label | x |
343339
| tainted-url-suffix-arguments.js:6:22:6:22 | y | semmle.label | y |
344-
| tainted-url-suffix-arguments.js:7:22:7:22 | z | semmle.label | z |
345340
| tainted-url-suffix-arguments.js:11:11:11:36 | url | semmle.label | url |
346341
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | semmle.label | window.location.href |
347342
| tainted-url-suffix-arguments.js:12:17:12:19 | url | semmle.label | url |
@@ -431,7 +426,6 @@ nodes
431426
| tst.js:64:25:64:48 | documen ... .search | semmle.label | documen ... .search |
432427
| tst.js:65:25:65:48 | documen ... .search | semmle.label | documen ... .search |
433428
| tst.js:68:16:68:20 | bar() | semmle.label | bar() |
434-
| tst.js:70:1:70:27 | [,docum ... search] | semmle.label | [,docum ... search] |
435429
| tst.js:70:1:70:27 | [,docum ... search] [1] | semmle.label | [,docum ... search] [1] |
436430
| tst.js:70:3:70:26 | documen ... .search | semmle.label | documen ... .search |
437431
| tst.js:70:46:70:46 | x | semmle.label | x |
@@ -984,15 +978,9 @@ edges
984978
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) | provenance | Config |
985979
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | |
986980
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) | provenance | Config |
987-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:14:3:14 | x | provenance | Config |
988-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:17:3:17 | y | provenance | Config |
989-
| tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | tainted-url-suffix-arguments.js:3:20:3:20 | z | provenance | Config |
990-
| tainted-url-suffix-arguments.js:3:14:3:14 | x | tainted-url-suffix-arguments.js:5:22:5:22 | x | provenance | |
991981
| tainted-url-suffix-arguments.js:3:17:3:17 | y | tainted-url-suffix-arguments.js:6:22:6:22 | y | provenance | |
992-
| tainted-url-suffix-arguments.js:3:20:3:20 | z | tainted-url-suffix-arguments.js:7:22:7:22 | z | provenance | |
993982
| tainted-url-suffix-arguments.js:11:11:11:36 | url | tainted-url-suffix-arguments.js:12:17:12:19 | url | provenance | |
994983
| tainted-url-suffix-arguments.js:11:17:11:36 | window.location.href | tainted-url-suffix-arguments.js:11:11:11:36 | url | provenance | |
995-
| tainted-url-suffix-arguments.js:12:17:12:19 | url | tainted-url-suffix-arguments.js:3:1:8:1 | 'arguments' object of function foo [1] | provenance | |
996984
| tainted-url-suffix-arguments.js:12:17:12:19 | url | tainted-url-suffix-arguments.js:3:17:3:17 | y | provenance | |
997985
| tooltip.jsx:6:11:6:30 | source | tooltip.jsx:10:25:10:30 | source | provenance | |
998986
| tooltip.jsx:6:11:6:30 | source | tooltip.jsx:11:25:11:30 | source | provenance | |
@@ -1078,11 +1066,7 @@ edges
10781066
| tst.js:60:34:60:34 | s | tst.js:62:18:62:18 | s | provenance | |
10791067
| tst.js:64:25:64:48 | documen ... .search | tst.js:60:34:60:34 | s | provenance | |
10801068
| tst.js:65:25:65:48 | documen ... .search | tst.js:60:34:60:34 | s | provenance | |
1081-
| tst.js:70:1:70:27 | [,docum ... search] | tst.js:70:46:70:46 | x | provenance | |
1082-
| tst.js:70:1:70:27 | [,docum ... search] | tst.js:70:46:70:46 | x | provenance | Config |
10831069
| tst.js:70:1:70:27 | [,docum ... search] [1] | tst.js:70:46:70:46 | x | provenance | |
1084-
| tst.js:70:1:70:27 | [,docum ... search] [1] | tst.js:70:46:70:46 | x | provenance | Config |
1085-
| tst.js:70:3:70:26 | documen ... .search | tst.js:70:1:70:27 | [,docum ... search] | provenance | Config |
10861070
| tst.js:70:3:70:26 | documen ... .search | tst.js:70:1:70:27 | [,docum ... search] [1] | provenance | |
10871071
| tst.js:70:46:70:46 | x | tst.js:73:20:73:20 | x | provenance | |
10881072
| tst.js:107:7:107:44 | v | tst.js:110:18:110:18 | v | provenance | |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/tainted-url-suffix-arguments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import 'dummy';
22

33
function foo(x, y, z) {
44
arguments; // ensure 'arguments' are used
5-
document.writeln(x); // OK [INCONSISTENCY]
5+
document.writeln(x); // OK
66
document.writeln(y); // NOT OK
7-
document.writeln(z); // OK [INCONSISTENCY]
7+
document.writeln(z); // OK
88
}
99

1010
function bar() {

0 commit comments

Comments
 (0)