Skip to content

Commit 6bc6d60

Browse files
authored
Merge pull request #1101 from odaysec/patch-1
fix(server): Uncontrolled data used in path expression
2 parents 166151c + e9afd60 commit 6bc6d60

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ http
2323
if (uri === '/test/') {
2424
uri = '/test/index.html';
2525
}
26-
filename = path.join(process.cwd(), uri);
26+
filename = fs.realpathSync(path.resolve(process.cwd(), uri));
27+
if (!filename.startsWith(process.cwd())) {
28+
res.writeHead(403, { 'Content-Type': 'text/plain' });
29+
res.end('403 Forbidden\n');
30+
return;
31+
}
2732

2833
domain.on('error', function () {
2934
res.writeHead(404, { 'Content-Type': 'text/plain' });

0 commit comments

Comments
 (0)