Block malicious looking requests to prevent path traversal attacks.

This commit is contained in:
Jafar Akhondali 2024-11-07 17:23:01 +01:00
parent 1a9ee8c34e
commit fe39c475a2

View File

@ -35,5 +35,10 @@ function write(res, file) {
http.createServer((req, res) => {
const route = req.url.split('/').slice(1);
if (route.includes('..')) {
res.writeHead(403);
res.end('');
return;
}
write(res, route);
}).listen(PORT, HOST);