Skip to content

Commit

Permalink
fix: sanitize log file names in the api
Browse files Browse the repository at this point in the history
Sanitize log file names to prevent directory traversal.
  • Loading branch information
tkurki committed Jun 25, 2024
1 parent d57209b commit e937e58
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/interfaces/logfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function mountApi(app) {
})
})
app.get(`${SERVERROUTESPREFIX}/logfiles/:filename`, function (req, res) {
const sanitizedFilename = req.params.filename.replaceAll(/\.\.(\\|\/)/g, '')
const sanitizedLogfile = path
.join(getFullLogDir(app), req.params.filename)
.join(getFullLogDir(app), sanitizedFilename)
.replace(/\.\./g, '')
res.sendFile(sanitizedLogfile)
})
Expand Down

0 comments on commit e937e58

Please sign in to comment.