From 2eb858a19f246855c07e43f95a527871b6ae7809 Mon Sep 17 00:00:00 2001 From: Jafar Akhondali Date: Fri, 26 Jul 2024 05:33:40 +0200 Subject: [PATCH] Block malicious looking requests to prevent path traversal attacks. --- lib/ace/static.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ace/static.js b/lib/ace/static.js index e9f69e6..b1ed540 100755 --- a/lib/ace/static.js +++ b/lib/ace/static.js @@ -31,6 +31,11 @@ if (allowSave) http.createServer(function(req, res) { var uri = unescape(url.parse(req.url).pathname); + if (path.normalize(unescape(req.url)) !== unescape(req.url)) { + res.statusCode = 403; + res.end(); + return; + } var filename = path.join(process.cwd(), uri); if (req.method == "OPTIONS") {