From e5d66d1fbd4b392294512d4644ac22bdc888573c Mon Sep 17 00:00:00 2001 From: Rob Cresswell Date: Tue, 10 Dec 2019 10:30:28 +0000 Subject: [PATCH] fix: sanitise pid parameter This patch adds a simple check to the process ID passed in, ensuring it is a number, and throwing an error otherwise. The aim is to fix the issue explained here: - https://hackerone.com/reports/701183 - https://snyk.io/vuln/SNYK-JS-TREEKILL-536781 Fixes: #30 --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 125afdc..8348b4b 100755 --- a/index.js +++ b/index.js @@ -5,6 +5,10 @@ var spawn = childProcess.spawn; var exec = childProcess.exec; module.exports = function (pid, signal, callback) { + if (typeof pid !== "number") { + throw new Error("pid must be a number"); + } + var tree = {}; var pidsToProcess = {}; tree[pid] = [];