Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
Fix for path traversal (GHSA-948g-2vm7-mfv7)
  • Loading branch information
salahlalami authored Oct 4, 2024
2 parents 100525d + 5860bc5 commit 949bc6f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/src/routes/coreRoutes/corePublicRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const path = require('path');
router.route('/:subPath/:directory/:file').get(function (req, res) {
try {
const { subPath, directory, file } = req.params;

//subPath sanitization check
sanitizedPath = path.normalize(subPath).replace(/^(\.\.[\/\\])+/, '');
const options = {
root: path.join(__dirname, `../../public/${subPath}/${directory}`),
root: path.join(__dirname, `../../public/${sanitizedPath}/${directory}`),
};
const fileName = file;
return res.sendFile(fileName, options, function (error) {
Expand Down

0 comments on commit 949bc6f

Please sign in to comment.