My code:
router.post('/loadDetails', async (req, res) => {
try {
var resultData = await myService.postRequest(req.body, 'myconfig/loadAllSDetails');
res.send(resultData);
}
catch(error) {
res.status(500).send(error.message);
}
})
Here I am getting vulnerability while passing input and output as
The application's router.post embeds untrusted data in the generated output with send, at line 626 of
routes\myConfigRouter.js
. This untrusted data is embedded straight into the output without proper sanitization or encoding, enabling an attacker to inject malicious code into the output.The attacker would be able to alter the returned web page by simply providing modified data in the user input body, which is read by the router.post method at line 625 of
routes\myConfigRouter.js
. This input then flows through the code straight to the output web page, without sanitization.This can enable a Reflected Cross-Site Scripting (XSS) attack.
I am passing req.body
with sanitize method like below but it's not working:
sanitize(req.body);