Narrowed down conditions for CGI execution for security reasons

This commit is contained in:
Dorian Niemiec 2023-08-30 17:34:56 +02:00
parent b4de66359d
commit 9381b3dec0

View file

@ -56,14 +56,15 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
".sh": ["bash"], ".sh": ["bash"],
".ksh": ["ksh"], ".ksh": ["ksh"],
".csh": ["csh"], ".csh": ["csh"],
".bat": ["cmd", "/c"],
".cmd": ["cmd", "/c"],
".vbs": ["cscript"],
".jar": ["java"],
".pyw": ["python"],
".rb": ["ruby"], ".rb": ["ruby"],
".php": ["php-cgi"] ".php": ["php-cgi"]
}; };
if(os.platform() == "win32") {
exttointerpreter[".exe"] = [];
exttointerpreter[".bat"] = ["cmd", "/c"];
exttointerpreter[".cmd"] = ["cmd", "/c"];
exttointerpreter[".vbs"] = ["cscript"];
}
var exttointerpreteruser = {}; var exttointerpreteruser = {};
fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) { fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) {
if (!err) { if (!err) {
@ -115,7 +116,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
return arg.replace(/"/g, ""); return arg.replace(/"/g, "");
}); });
afterShebangCallback(args); afterShebangCallback(args);
} else if (line.substr(0, 2) == "MZ" || line.substr(0, 4) == "\x7fELF") { } else if (os.platform() != "win32" && line.substr(0, 4) == "\x7fELF") {
afterShebangCallback("binary"); afterShebangCallback("binary");
} else { } else {
afterShebangCallback(false); afterShebangCallback(false);
@ -146,7 +147,10 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
} }
} else { } else {
args = exttointerpreteruser[ext]; args = exttointerpreteruser[ext];
if (!args) { if (args === null) {
elseCallback();
return;
} else if (!args) {
args = exttointerpreter[ext]; args = exttointerpreter[ext];
if (!args) { if (!args) {
elseCallback(); elseCallback();