
LLima925770 (Community Member) asked a question.
res.status(500).json({ error: err });
"...In this case, the message being sent appears to be considered private. " really?
context code:
router.route('/deleteByDocumentType')
.post(verify.verifyOrdinaryUser, (req, res) => {
DocumentFormField.deleteMany({documentType:req.body.documentType}, (err, doc) => {
if (err) {
res.status(500).json({ error: err });
return
}
return res.status(200).json({ success: true, message: "campo removido da base"});
});
});
Veracode response: the application calls the express.Response.json() function, which will result in data being transferred out of the application (via the network or another medium). In this case, the message being sent appears to be considered private; this may include credentials such as usernames or passwords, data normally stored in cryptographically-protected vaults such as keychains, or other private information. Ensure that the transfer of the sensitive data is intended and that it does not violate application security policy. This flaw is categorized as low severity because it only impacts confidentiality, not integrity or availability. However, in the context of a mobile application, the significance of an information leak may be much greater, especially if misaligned with user expectations or data privacy policies. References: CWE (https://cwe.mitre.org/data/definitions/201.html) OWASP Security Misconfiguration
.png)
Hi @LLima925770 (Community Member) ,
Exposing errors externally, such as returning detailed error messages to clients in a production environment, can pose security risks and may not be the best practice for several reasons:
Instead of exposing detailed error messages externally, you should follow these best practices:
In summary, the practice of exposing detailed error messages externally is discouraged due to security risks and the potential negative impact on user experience. Instead, you should log errors on the server, return generic error messages to clients, and implement strong security measures to protect your application.
Thank you,
Boy Baukema