Skip to content

Commit

Permalink
fix: file access outside the public dir
Browse files Browse the repository at this point in the history
  • Loading branch information
drauggres committed Dec 15, 2021
1 parent 994d4c6 commit e83cf65
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server/services/HttpServer.ts
Expand Up @@ -45,6 +45,11 @@ export class HttpServer implements Service {
}
const parsedUrl = url.parse(req.url);
let pathname = path.join(publicDir, (parsedUrl.pathname || '.').replace(/^(\.)+/, '.'));
if (pathname.indexOf(publicDir) !== 0) {
res.statusCode = 403;
res.end();
return;
}
fs.stat(pathname, (statErr, stat) => {
if (statErr) {
if (statErr.code === 'ENOENT') {
Expand Down

0 comments on commit e83cf65

Please sign in to comment.