inetLatency() fixed possible DOS intrusion
This commit is contained in:
+14
-6
@@ -35,12 +35,9 @@ function inetChecksite(url, callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let urlSanitized = '';
|
||||
const s = util.sanitizeShellString(url);
|
||||
const s = util.sanitizeShellString(url, true);
|
||||
for (let i = 0; i <= 2000; i++) {
|
||||
if (!(s[i] === undefined ||
|
||||
s[i] === ' ' ||
|
||||
s[i] === '{' ||
|
||||
s[i] === '}')) {
|
||||
if (!(s[i] === undefined)) {
|
||||
s[i].__proto__.toLowerCase = util.stringToLower;
|
||||
const sl = s[i].toLowerCase();
|
||||
if (sl && sl[0] && !sl[1]) {
|
||||
@@ -126,7 +123,18 @@ function inetLatency(host, callback) {
|
||||
}
|
||||
|
||||
host = host || '8.8.8.8';
|
||||
const hostSanitized = (util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host)).trim();
|
||||
let hostSanitized = '';
|
||||
const s = (util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host, true)).trim();
|
||||
for (let i = 0; i <= 2000; i++) {
|
||||
if (!(s[i] === undefined)) {
|
||||
|
||||
s[i].__proto__.toLowerCase = util.stringToLower;
|
||||
const sl = s[i].toLowerCase();
|
||||
if (sl && sl[0] && !sl[1]) {
|
||||
hostSanitized = hostSanitized + sl[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
+5
-2
@@ -502,7 +502,7 @@ function countLines(lines, startingWith) {
|
||||
return uniqueLines.length;
|
||||
}
|
||||
|
||||
function sanitizeShellString(str) {
|
||||
function sanitizeShellString(str, strict = false) {
|
||||
const s = str || '';
|
||||
let result = '';
|
||||
for (let i = 0; i <= 2000; i++) {
|
||||
@@ -527,7 +527,10 @@ function sanitizeShellString(str) {
|
||||
s[i] === '\n' ||
|
||||
s[i] === '\'' ||
|
||||
s[i] === '`' ||
|
||||
s[i] === '"')) {
|
||||
s[i] === '"' ||
|
||||
strict && s[i] === ' ' ||
|
||||
strict && s[i] == '{' ||
|
||||
strict && s[i] == ')')) {
|
||||
result = result + s[i];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user