Please check the vulnerability on cross side scripting - "The untrusted data reaches a sink that may allow an attacker to control part of the response."
The property "req.body" is a source of untrusted data.
let {
userName,
…
util.errorLoging({
"message": userName + ' ' + helper.statusMessage.NO_SCHEDULE.DATA + initialDate,
"bqJobId": bqJobId,
"userName": userName
});
4. Passing "{"message" : userName + " " + helper.statusMessage.NO_SCHEDULE.DATA}" to "res.status(helper.statusCode.OK).send".
5. Calling "res.status(helper.statusCode.OK).send" with the tainted value in property "*" of "{"message" : userName + " " + helper.statusMessage.NO_SCHEDULE.DATA}". The untrusted data reaches a sink that may allow an attacker to control part of the response.
6. Escape non-constant data appropriately before concatenating it into HTML. The specific sequence of escapers necessary to make data safe depends on its syntactic position in the HTML. Allowing only safe characters (whitelisting) sometimes suffices to avoid XSS vulnerabilities, but only the strictest whitelists prevent all attacks.
return res.status(helper.statusCode.OK).send({
2. Creating a tainted string using "userName".
3. Assigning a tainted string to "<storage from new>["message"]".
message: userName + ' ' + helper.statusMessage.NO_SCHEDULE.DATA,
});
code
return res.status(helper.statusCode.OK).send({
message: userName + ' ' + helper.statusMessage.NO_SCHEDULE_DATA,
});
Please let me know how this vulnerability can be corrected?
EDIT req.body contents
let { userName, initialDate, lastDate, bqJobId } = req.body