Skip to content

General issue - JavaScript data flow analysis #5177

@gdemarcsek

Description

@gdemarcsek

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.

Metadata

Metadata

Assignees

Labels

JSStalequestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions