Skip to content

Commit bc2a772

Browse files
committed
JS: Add test case showing false negative
1 parent c68c83c commit bc2a772

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| query-tests/Security/CWE-079/DomBasedXss/jquery.js:37 | expected an alert, but found none | NOT OK | |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ nodes
431431
| jquery.js:34:5:34:25 | '<b>' + ... '</b>' |
432432
| jquery.js:34:5:34:25 | '<b>' + ... '</b>' |
433433
| jquery.js:34:13:34:16 | hash |
434+
| jquery.js:36:25:36:31 | tainted |
435+
| jquery.js:36:25:36:31 | tainted |
434436
| json-stringify.jsx:5:9:5:36 | locale |
435437
| json-stringify.jsx:5:9:5:36 | locale |
436438
| json-stringify.jsx:5:18:5:36 | req.param("locale") |
@@ -1512,6 +1514,8 @@ edges
15121514
| express.js:7:15:7:33 | req.param("wobble") | express.js:7:15:7:33 | req.param("wobble") |
15131515
| jquery.js:2:7:2:40 | tainted | jquery.js:7:20:7:26 | tainted |
15141516
| jquery.js:2:7:2:40 | tainted | jquery.js:8:28:8:34 | tainted |
1517+
| jquery.js:2:7:2:40 | tainted | jquery.js:36:25:36:31 | tainted |
1518+
| jquery.js:2:7:2:40 | tainted | jquery.js:36:25:36:31 | tainted |
15151519
| jquery.js:2:17:2:40 | documen ... .search | jquery.js:2:7:2:40 | tainted |
15161520
| jquery.js:2:17:2:40 | documen ... .search | jquery.js:2:7:2:40 | tainted |
15171521
| jquery.js:7:20:7:26 | tainted | jquery.js:7:5:7:34 | "<div i ... + "\\">" |
@@ -2355,6 +2359,7 @@ edges
23552359
| jquery.js:27:5:27:25 | hash.re ... #', '') | jquery.js:18:14:18:33 | window.location.hash | jquery.js:27:5:27:25 | hash.re ... #', '') | Cross-site scripting vulnerability due to $@. | jquery.js:18:14:18:33 | window.location.hash | user-provided value |
23562360
| jquery.js:28:5:28:43 | window. ... ?', '') | jquery.js:28:5:28:26 | window. ... .search | jquery.js:28:5:28:43 | window. ... ?', '') | Cross-site scripting vulnerability due to $@. | jquery.js:28:5:28:26 | window. ... .search | user-provided value |
23572361
| jquery.js:34:5:34:25 | '<b>' + ... '</b>' | jquery.js:18:14:18:33 | window.location.hash | jquery.js:34:5:34:25 | '<b>' + ... '</b>' | Cross-site scripting vulnerability due to $@. | jquery.js:18:14:18:33 | window.location.hash | user-provided value |
2362+
| jquery.js:36:25:36:31 | tainted | jquery.js:2:17:2:40 | documen ... .search | jquery.js:36:25:36:31 | tainted | Cross-site scripting vulnerability due to $@. | jquery.js:2:17:2:40 | documen ... .search | user-provided value |
23582363
| json-stringify.jsx:31:40:31:61 | JSON.st ... locale) | json-stringify.jsx:5:18:5:36 | req.param("locale") | json-stringify.jsx:31:40:31:61 | JSON.st ... locale) | Cross-site scripting vulnerability due to $@. | json-stringify.jsx:5:18:5:36 | req.param("locale") | user-provided value |
23592364
| json-stringify.jsx:35:40:35:61 | JSON.st ... jsonLD) | json-stringify.jsx:5:18:5:36 | req.param("locale") | json-stringify.jsx:35:40:35:61 | JSON.st ... jsonLD) | Cross-site scripting vulnerability due to $@. | json-stringify.jsx:5:18:5:36 | req.param("locale") | user-provided value |
23602365
| jwt-server.js:11:19:11:29 | decoded.foo | jwt-server.js:7:17:7:35 | req.param("wobble") | jwt-server.js:11:19:11:29 | decoded.foo | Cross-site scripting vulnerability due to $@. | jwt-server.js:7:17:7:35 | req.param("wobble") | user-provided value |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ nodes
431431
| jquery.js:34:5:34:25 | '<b>' + ... '</b>' |
432432
| jquery.js:34:5:34:25 | '<b>' + ... '</b>' |
433433
| jquery.js:34:13:34:16 | hash |
434+
| jquery.js:36:25:36:31 | tainted |
435+
| jquery.js:36:25:36:31 | tainted |
434436
| json-stringify.jsx:5:9:5:36 | locale |
435437
| json-stringify.jsx:5:9:5:36 | locale |
436438
| json-stringify.jsx:5:18:5:36 | req.param("locale") |
@@ -1562,6 +1564,8 @@ edges
15621564
| express.js:7:15:7:33 | req.param("wobble") | express.js:7:15:7:33 | req.param("wobble") |
15631565
| jquery.js:2:7:2:40 | tainted | jquery.js:7:20:7:26 | tainted |
15641566
| jquery.js:2:7:2:40 | tainted | jquery.js:8:28:8:34 | tainted |
1567+
| jquery.js:2:7:2:40 | tainted | jquery.js:36:25:36:31 | tainted |
1568+
| jquery.js:2:7:2:40 | tainted | jquery.js:36:25:36:31 | tainted |
15651569
| jquery.js:2:17:2:40 | documen ... .search | jquery.js:2:7:2:40 | tainted |
15661570
| jquery.js:2:17:2:40 | documen ... .search | jquery.js:2:7:2:40 | tainted |
15671571
| jquery.js:7:20:7:26 | tainted | jquery.js:7:5:7:34 | "<div i ... + "\\">" |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ function test() {
3232
$(hash + 'blah'); // OK
3333
$('blah' + hash); // OK - does not start with '<'
3434
$('<b>' + hash + '</b>'); // NOT OK
35+
36+
$('#foo').replaceWith(tainted); // NOT OK
37+
$('#foo').replaceWith(() => tainted); // NOT OK
3538
}

0 commit comments

Comments
 (0)