UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

34 lines (33 loc) 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkContextForShellInjection = checkContextForShellInjection; const Source_1 = require("../../agent/Source"); const attackPath_1 = require("../../helpers/attackPath"); const extractStringsFromUserInputCached_1 = require("../../helpers/extractStringsFromUserInputCached"); const detectShellInjection_1 = require("./detectShellInjection"); /** * This function goes over all the different input types in the context and checks * if it's a possible shell Injection, if so the function returns an InterceptorResult */ function checkContextForShellInjection({ command, operation, context, }) { for (const source of Source_1.SOURCES) { const userInput = (0, extractStringsFromUserInputCached_1.extractStringsFromUserInputCached)(context, source); if (!userInput) { continue; } for (const str of userInput) { if ((0, detectShellInjection_1.detectShellInjection)(command, str)) { return { operation: operation, kind: "shell_injection", source: source, pathsToPayload: (0, attackPath_1.getPathsToPayload)(str, context[source]), metadata: { command: command, }, payload: str, }; } } } }