External control of filename or path detected.


Passing unsanitized user input to the sendFile API is bad practice and can lead to path manipulation, by which attackers can gain access to resources and data outside of the intended scope.


✅ Set the root option to be an absolute path to a directory

app.post("/upload", (req, res) => {
var options = {
root: path.join(__dirname, "upload")
res.sendFile(req.params.filename, options)


Associated CWE

OWASP Top 10