Unsanitized User input in HTTP Send file request
Last updated
Rule ID: javascript_express_external_file_upload
Applicable Languages: Javascript
Weakness ID: CWE-73
Using unsanitized user input in the sendFile API call exposes your application to path manipulation attacks. This vulnerability allows attackers to access files and resources they shouldn't by manipulating file paths in requests.
Set the root option to an absolute path when using sendFile. This restricts accessible files to a specific directory, preventing attackers from accessing files outside of this directory.
app.post("/upload", (req, res) => {
var options = {
root: path.join(__dirname, "upload")
};
res.sendFile(req.params.filename, options);
});To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our SAST TOOL
Last updated