Skip to content

Commit 3240536

Browse files
authored
Merge pull request github#5798 from erik-krogh/trackLoc
Approved by esbena
2 parents 4d2db08 + dfd63e5 commit 3240536

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

javascript/ql/src/semmle/javascript/DOM.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ module DOM {
469469
t.start() and
470470
result = locationSource()
471471
or
472+
t.startInProp("location") and
473+
result = [DataFlow::globalObjectRef(), documentSource()]
474+
or
472475
exists(DataFlow::TypeTracker t2 | result = locationRef(t2).track(t2, t))
473476
}
474477

javascript/ql/test/query-tests/Security/CWE-601/ClientSideUrlRedirect/ClientSideUrlRedirect.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ nodes
171171
| tst.js:22:34:22:50 | document.location |
172172
| tst.js:22:34:22:55 | documen ... on.href |
173173
| tst.js:22:34:22:55 | documen ... on.href |
174+
| tst.js:26:22:26:79 | new Reg ... n.href) |
175+
| tst.js:26:22:26:82 | new Reg ... ref)[1] |
176+
| tst.js:26:22:26:82 | new Reg ... ref)[1] |
177+
| tst.js:26:62:26:78 | win.location.href |
178+
| tst.js:26:62:26:78 | win.location.href |
174179
| typed.ts:4:13:4:36 | params |
175180
| typed.ts:4:22:4:36 | location.search |
176181
| typed.ts:4:22:4:36 | location.search |
@@ -337,6 +342,10 @@ edges
337342
| tst.js:22:34:22:50 | document.location | tst.js:22:34:22:55 | documen ... on.href |
338343
| tst.js:22:34:22:55 | documen ... on.href | tst.js:22:20:22:56 | indirec ... n.href) |
339344
| tst.js:22:34:22:55 | documen ... on.href | tst.js:22:20:22:56 | indirec ... n.href) |
345+
| tst.js:26:22:26:79 | new Reg ... n.href) | tst.js:26:22:26:82 | new Reg ... ref)[1] |
346+
| tst.js:26:22:26:79 | new Reg ... n.href) | tst.js:26:22:26:82 | new Reg ... ref)[1] |
347+
| tst.js:26:62:26:78 | win.location.href | tst.js:26:22:26:79 | new Reg ... n.href) |
348+
| tst.js:26:62:26:78 | win.location.href | tst.js:26:22:26:79 | new Reg ... n.href) |
340349
| typed.ts:4:13:4:36 | params | typed.ts:5:25:5:30 | params |
341350
| typed.ts:4:22:4:36 | location.search | typed.ts:4:13:4:36 | params |
342351
| typed.ts:4:22:4:36 | location.search | typed.ts:4:13:4:36 | params |
@@ -400,5 +409,6 @@ edges
400409
| tst.js:18:19:18:84 | new Reg ... ref)[1] | tst.js:18:59:18:80 | documen ... on.href | tst.js:18:19:18:84 | new Reg ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:18:59:18:80 | documen ... on.href | user-provided value |
401410
| tst.js:22:20:22:59 | indirec ... ref)[1] | tst.js:22:34:22:50 | document.location | tst.js:22:20:22:59 | indirec ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:22:34:22:50 | document.location | user-provided value |
402411
| tst.js:22:20:22:59 | indirec ... ref)[1] | tst.js:22:34:22:55 | documen ... on.href | tst.js:22:20:22:59 | indirec ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:22:34:22:55 | documen ... on.href | user-provided value |
412+
| tst.js:26:22:26:82 | new Reg ... ref)[1] | tst.js:26:62:26:78 | win.location.href | tst.js:26:22:26:82 | new Reg ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:26:62:26:78 | win.location.href | user-provided value |
403413
| typed.ts:8:33:8:43 | redirectUri | typed.ts:4:22:4:36 | location.search | typed.ts:8:33:8:43 | redirectUri | Untrusted URL redirection due to $@. | typed.ts:4:22:4:36 | location.search | user-provided value |
404414
| typed.ts:29:33:29:43 | redirectUri | typed.ts:25:25:25:34 | loc.search | typed.ts:29:33:29:43 | redirectUri | Untrusted URL redirection due to $@. | typed.ts:25:25:25:34 | loc.search | user-provided value |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ window.location = new RegExp(/.*redirect=([^&]*).*/).exec(document.location.href
2121
var indirect = new RegExp(/.*redirect=([^&]*).*/)
2222
window.location = indirect.exec(document.location.href)[1];
2323
});
24+
25+
function foo(win) {
26+
win.location.assign(new RegExp(/.*redirect=([^&]*).*/).exec(win.location.href)[1]); // NOT OK
27+
}
28+
29+
foo(window);

0 commit comments

Comments
 (0)