Skip to content

Commit e02b67a

Browse files
erik-kroghatorralba
authored andcommitted
add failing test
1 parent 50cd40e commit e02b67a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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
@@ -218,6 +218,11 @@ nodes
218218
| typed.ts:28:24:28:34 | redirectUri |
219219
| typed.ts:29:33:29:43 | redirectUri |
220220
| typed.ts:29:33:29:43 | redirectUri |
221+
| typed.ts:47:25:47:34 | loc.search |
222+
| typed.ts:47:25:47:34 | loc.search |
223+
| typed.ts:51:24:51:34 | redirectUri |
224+
| typed.ts:52:33:52:43 | redirectUri |
225+
| typed.ts:52:33:52:43 | redirectUri |
221226
edges
222227
| electron.js:4:12:4:22 | window.name | electron.js:7:20:7:29 | getTaint() |
223228
| electron.js:4:12:4:22 | window.name | electron.js:7:20:7:29 | getTaint() |
@@ -412,6 +417,10 @@ edges
412417
| typed.ts:25:25:25:34 | loc.search | typed.ts:28:24:28:34 | redirectUri |
413418
| typed.ts:28:24:28:34 | redirectUri | typed.ts:29:33:29:43 | redirectUri |
414419
| typed.ts:28:24:28:34 | redirectUri | typed.ts:29:33:29:43 | redirectUri |
420+
| typed.ts:47:25:47:34 | loc.search | typed.ts:51:24:51:34 | redirectUri |
421+
| typed.ts:47:25:47:34 | loc.search | typed.ts:51:24:51:34 | redirectUri |
422+
| typed.ts:51:24:51:34 | redirectUri | typed.ts:52:33:52:43 | redirectUri |
423+
| typed.ts:51:24:51:34 | redirectUri | typed.ts:52:33:52:43 | redirectUri |
415424
#select
416425
| electron.js:7:20:7:29 | getTaint() | electron.js:4:12:4:22 | window.name | electron.js:7:20:7:29 | getTaint() | Untrusted URL redirection depends on a $@. | electron.js:4:12:4:22 | window.name | user-provided value |
417426
| react.js:10:60:10:81 | documen ... on.hash | react.js:10:60:10:81 | documen ... on.hash | react.js:10:60:10:81 | documen ... on.hash | Untrusted URL redirection depends on a $@. | react.js:10:60:10:81 | documen ... on.hash | user-provided value |
@@ -475,3 +484,4 @@ edges
475484
| 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 depends on a $@. | tst.js:26:62:26:78 | win.location.href | user-provided value |
476485
| 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 depends on a $@. | typed.ts:4:22:4:36 | location.search | user-provided value |
477486
| 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 depends on a $@. | typed.ts:25:25:25:34 | loc.search | user-provided value |
487+
| typed.ts:52:33:52:43 | redirectUri | typed.ts:47:25:47:34 | loc.search | typed.ts:52:33:52:43 | redirectUri | Untrusted URL redirection depends on a $@. | typed.ts:47:25:47:34 | loc.search | user-provided value |

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,31 @@ export class MyTrackingComponent {
2828
private doRedirect(redirectUri: string) {
2929
window.location.replace(redirectUri);
3030
}
31+
}
32+
33+
export class WeirdTracking {
34+
componentDidMount() {
35+
const { location }: { location: Location } = (this as any).props; // location source
36+
37+
var container = {
38+
loc: location
39+
};
40+
var secondLoc = container.loc; // type-tracking step 1 - not the source
41+
42+
this.myIndirectRedirect(secondLoc);
43+
}
44+
45+
private myIndirectRedirect(loc) { // type-tracking step 2 - also not the source
46+
const loc2 : Location = (loc as any).componentDidMount;
47+
this.doRedirect(loc.search);
48+
this.doRedirect2(loc2.search);
49+
}
50+
51+
private doRedirect(redirectUri: string) {
52+
window.location.replace(redirectUri); // NOT OK - and correctly flagged
53+
}
54+
55+
private doRedirect2(redirectUri: string) {
56+
window.location.replace(redirectUri); // NOT OK - but not flagged [INCONSISTENCY]
57+
}
3158
}

0 commit comments

Comments
 (0)