-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Description of the issue
The following DOM XSS vector is recognized nicely (CWE-079):
function test() {
let x = new URLSearchParams(location.search).get('x');
document.getElementById("sink").innerHTML = x;
}
But this one is not recognized:
function test() {
[document.getElementById("sink")][0].innerHTML = new URLSearchParams(location.search).get('x');
}
Is this a limitation of the JS data flow analysis library, generic limitation of the methodology or just an uncovered scenario (e.g. not propagating taint through array literals to their elements?)
My original test case was more complicated and a bit more realistic (like I could imagine similar code to be written IRL):
function f(e) {
e.innerHTML = new URLSearchParams(location.search).get('x');
}
[document.getElementById("sink")].map(f);
But this didn't work so I started to simplify. Same for a forEach + arrow function.