Skip to content

Commit d8a5947

Browse files
committed
simplify TaintedUrlSuffix::source() to only consider window.location based sources
1 parent b3de5d9 commit d8a5947

File tree

3 files changed

+85
-25
lines changed

3 files changed

+85
-25
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ module TaintedUrlSuffix {
2626
*/
2727
FlowLabel label() { result instanceof TaintedUrlSuffixLabel }
2828

29-
/**
30-
* Gets a remote flow source that is a tainted URL query or fragment part.
31-
*/
29+
/** Gets a remote flow source that is a tainted URL query or fragment part from `window.location`. */
3230
ClientSideRemoteFlowSource source() {
33-
result.getKind().isFragment()
31+
result = DOM::locationRef().getAPropertyRead(["search", "hash"])
3432
or
35-
result.getKind().isQuery()
33+
result = DOM::locationSource()
3634
or
3735
result.getKind().isUrl()
3836
}

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

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ nodes
2828
| angular2-client.ts:22:44:22:71 | \\u0275getDOM ... ().href |
2929
| angular2-client.ts:22:44:22:71 | \\u0275getDOM ... ().href |
3030
| angular2-client.ts:22:44:22:71 | \\u0275getDOM ... ().href |
31+
| angular2-client.ts:22:44:22:71 | \\u0275getDOM ... ().href |
3132
| angular2-client.ts:24:44:24:69 | this.ro ... .params |
3233
| angular2-client.ts:24:44:24:69 | this.ro ... .params |
3334
| angular2-client.ts:24:44:24:69 | this.ro ... .params |
@@ -36,8 +37,11 @@ nodes
3637
| angular2-client.ts:24:44:24:73 | this.ro ... ams.foo |
3738
| angular2-client.ts:25:44:25:74 | this.ro ... yParams |
3839
| angular2-client.ts:25:44:25:74 | this.ro ... yParams |
40+
| angular2-client.ts:25:44:25:74 | this.ro ... yParams |
3941
| angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
4042
| angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
43+
| angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
44+
| angular2-client.ts:26:44:26:71 | this.ro ... ragment |
4145
| angular2-client.ts:26:44:26:71 | this.ro ... ragment |
4246
| angular2-client.ts:26:44:26:71 | this.ro ... ragment |
4347
| angular2-client.ts:26:44:26:71 | this.ro ... ragment |
@@ -48,6 +52,7 @@ nodes
4852
| angular2-client.ts:28:44:28:87 | this.ro ... ('foo') |
4953
| angular2-client.ts:28:44:28:87 | this.ro ... ('foo') |
5054
| angular2-client.ts:28:44:28:87 | this.ro ... ('foo') |
55+
| angular2-client.ts:28:44:28:87 | this.ro ... ('foo') |
5156
| angular2-client.ts:30:46:30:59 | map.get('foo') |
5257
| angular2-client.ts:30:46:30:59 | map.get('foo') |
5358
| angular2-client.ts:30:46:30:59 | map.get('foo') |
@@ -75,6 +80,8 @@ nodes
7580
| angular2-client.ts:38:44:38:58 | this.router.url |
7681
| angular2-client.ts:38:44:38:58 | this.router.url |
7782
| angular2-client.ts:38:44:38:58 | this.router.url |
83+
| angular2-client.ts:38:44:38:58 | this.router.url |
84+
| angular2-client.ts:40:45:40:59 | this.router.url |
7885
| angular2-client.ts:40:45:40:59 | this.router.url |
7986
| angular2-client.ts:40:45:40:59 | this.router.url |
8087
| angular2-client.ts:40:45:40:59 | this.router.url |
@@ -293,7 +300,6 @@ nodes
293300
| dates.js:61:81:61:85 | taint |
294301
| event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
295302
| event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
296-
| event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
297303
| event-handler-receiver.js:2:49:2:61 | location.href |
298304
| event-handler-receiver.js:2:49:2:61 | location.href |
299305
| express.js:7:15:7:33 | req.param("wobble") |
@@ -519,28 +525,41 @@ nodes
519525
| string-manipulations.js:4:16:4:37 | documen ... on.href |
520526
| string-manipulations.js:4:16:4:37 | documen ... on.href |
521527
| string-manipulations.js:4:16:4:37 | documen ... on.href |
528+
| string-manipulations.js:4:16:4:37 | documen ... on.href |
529+
| string-manipulations.js:5:16:5:37 | documen ... on.href |
522530
| string-manipulations.js:5:16:5:37 | documen ... on.href |
523531
| string-manipulations.js:5:16:5:37 | documen ... on.href |
524532
| string-manipulations.js:5:16:5:47 | documen ... lueOf() |
525533
| string-manipulations.js:5:16:5:47 | documen ... lueOf() |
534+
| string-manipulations.js:5:16:5:47 | documen ... lueOf() |
535+
| string-manipulations.js:6:16:6:37 | documen ... on.href |
526536
| string-manipulations.js:6:16:6:37 | documen ... on.href |
527537
| string-manipulations.js:6:16:6:37 | documen ... on.href |
528538
| string-manipulations.js:6:16:6:43 | documen ... f.sup() |
529539
| string-manipulations.js:6:16:6:43 | documen ... f.sup() |
540+
| string-manipulations.js:6:16:6:43 | documen ... f.sup() |
530541
| string-manipulations.js:7:16:7:37 | documen ... on.href |
531542
| string-manipulations.js:7:16:7:37 | documen ... on.href |
543+
| string-manipulations.js:7:16:7:37 | documen ... on.href |
544+
| string-manipulations.js:7:16:7:51 | documen ... rCase() |
532545
| string-manipulations.js:7:16:7:51 | documen ... rCase() |
533546
| string-manipulations.js:7:16:7:51 | documen ... rCase() |
534547
| string-manipulations.js:8:16:8:37 | documen ... on.href |
535548
| string-manipulations.js:8:16:8:37 | documen ... on.href |
549+
| string-manipulations.js:8:16:8:37 | documen ... on.href |
550+
| string-manipulations.js:8:16:8:48 | documen ... mLeft() |
536551
| string-manipulations.js:8:16:8:48 | documen ... mLeft() |
537552
| string-manipulations.js:8:16:8:48 | documen ... mLeft() |
538553
| string-manipulations.js:9:16:9:58 | String. ... n.href) |
539554
| string-manipulations.js:9:16:9:58 | String. ... n.href) |
555+
| string-manipulations.js:9:16:9:58 | String. ... n.href) |
556+
| string-manipulations.js:9:36:9:57 | documen ... on.href |
540557
| string-manipulations.js:9:36:9:57 | documen ... on.href |
541558
| string-manipulations.js:9:36:9:57 | documen ... on.href |
542559
| string-manipulations.js:10:16:10:45 | String( ... n.href) |
543560
| string-manipulations.js:10:16:10:45 | String( ... n.href) |
561+
| string-manipulations.js:10:16:10:45 | String( ... n.href) |
562+
| string-manipulations.js:10:23:10:44 | documen ... on.href |
544563
| string-manipulations.js:10:23:10:44 | documen ... on.href |
545564
| string-manipulations.js:10:23:10:44 | documen ... on.href |
546565
| tooltip.jsx:6:11:6:30 | source |
@@ -603,11 +622,9 @@ nodes
603622
| tst.js:5:18:5:23 | target |
604623
| tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
605624
| tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
606-
| tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
607625
| tst.js:8:37:8:58 | documen ... on.href |
608626
| tst.js:8:37:8:58 | documen ... on.href |
609627
| tst.js:8:37:8:114 | documen ... t=")+8) |
610-
| tst.js:8:37:8:114 | documen ... t=")+8) |
611628
| tst.js:12:5:12:42 | '<div s ... 'px">' |
612629
| tst.js:12:5:12:42 | '<div s ... 'px">' |
613630
| tst.js:12:28:12:33 | target |
@@ -1065,6 +1082,9 @@ edges
10651082
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
10661083
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
10671084
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
1085+
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
1086+
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
1087+
| angular2-client.ts:25:44:25:74 | this.ro ... yParams | angular2-client.ts:25:44:25:78 | this.ro ... ams.foo |
10681088
| angular2-client.ts:26:44:26:71 | this.ro ... ragment | angular2-client.ts:26:44:26:71 | this.ro ... ragment |
10691089
| angular2-client.ts:27:44:27:82 | this.ro ... ('foo') | angular2-client.ts:27:44:27:82 | this.ro ... ('foo') |
10701090
| angular2-client.ts:28:44:28:87 | this.ro ... ('foo') | angular2-client.ts:28:44:28:87 | this.ro ... ('foo') |
@@ -1315,8 +1335,6 @@ edges
13151335
| event-handler-receiver.js:2:49:2:61 | location.href | event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
13161336
| event-handler-receiver.js:2:49:2:61 | location.href | event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
13171337
| event-handler-receiver.js:2:49:2:61 | location.href | event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
1318-
| event-handler-receiver.js:2:49:2:61 | location.href | event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
1319-
| event-handler-receiver.js:2:49:2:61 | location.href | event-handler-receiver.js:2:31:2:83 | '<h2><a ... ></h2>' |
13201338
| express.js:7:15:7:33 | req.param("wobble") | express.js:7:15:7:33 | req.param("wobble") |
13211339
| jquery.js:2:7:2:40 | tainted | jquery.js:7:20:7:26 | tainted |
13221340
| jquery.js:2:7:2:40 | tainted | jquery.js:8:28:8:34 | tainted |
@@ -1534,22 +1552,40 @@ edges
15341552
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
15351553
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
15361554
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
1555+
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
1556+
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
1557+
| string-manipulations.js:5:16:5:37 | documen ... on.href | string-manipulations.js:5:16:5:47 | documen ... lueOf() |
1558+
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
1559+
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
15371560
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
15381561
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
15391562
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
15401563
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
1564+
| string-manipulations.js:6:16:6:37 | documen ... on.href | string-manipulations.js:6:16:6:43 | documen ... f.sup() |
1565+
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
1566+
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
15411567
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
15421568
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
15431569
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
15441570
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
1571+
| string-manipulations.js:7:16:7:37 | documen ... on.href | string-manipulations.js:7:16:7:51 | documen ... rCase() |
1572+
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
1573+
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
15451574
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
15461575
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
15471576
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
15481577
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
1578+
| string-manipulations.js:8:16:8:37 | documen ... on.href | string-manipulations.js:8:16:8:48 | documen ... mLeft() |
1579+
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
1580+
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
15491581
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
15501582
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
15511583
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
15521584
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
1585+
| string-manipulations.js:9:36:9:57 | documen ... on.href | string-manipulations.js:9:16:9:58 | String. ... n.href) |
1586+
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
1587+
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
1588+
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
15531589
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
15541590
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
15551591
| string-manipulations.js:10:23:10:44 | documen ... on.href | string-manipulations.js:10:16:10:45 | String( ... n.href) |
@@ -1619,11 +1655,6 @@ edges
16191655
| tst.js:2:16:2:39 | documen ... .search | tst.js:2:7:2:39 | target |
16201656
| tst.js:8:37:8:58 | documen ... on.href | tst.js:8:37:8:114 | documen ... t=")+8) |
16211657
| tst.js:8:37:8:58 | documen ... on.href | tst.js:8:37:8:114 | documen ... t=")+8) |
1622-
| tst.js:8:37:8:58 | documen ... on.href | tst.js:8:37:8:114 | documen ... t=")+8) |
1623-
| tst.js:8:37:8:58 | documen ... on.href | tst.js:8:37:8:114 | documen ... t=")+8) |
1624-
| tst.js:8:37:8:114 | documen ... t=")+8) | tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
1625-
| tst.js:8:37:8:114 | documen ... t=")+8) | tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
1626-
| tst.js:8:37:8:114 | documen ... t=")+8) | tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
16271658
| tst.js:8:37:8:114 | documen ... t=")+8) | tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
16281659
| tst.js:8:37:8:114 | documen ... t=")+8) | tst.js:8:18:8:126 | "<OPTIO ... PTION>" |
16291660
| tst.js:12:28:12:33 | target | tst.js:12:5:12:42 | '<div s ... 'px">' |

0 commit comments

Comments
 (0)