CVE-2019-10791 (JavaScript, published 2020-02-18T17:15Z)
Description: value: promise-probe before 0.10.0 allows remote attackers to perform a command injection attack. The file, outputFile and options functions can be controlled by users without any sanitization.
Severity: HIGH (CVSS v3 base score: 9.8)
Weakness: CWE-78 \u2014 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
Repository: https://github.com/dottgonzo/node-promise-probe
Files changed:
index.js
index.js.map
index.ts
Commit message: resolve vulnerability


Vulnerable code:
                throw err;
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,iDAAoC;AACpC,2BAAyB;AAgHzB,iBAAwB,IAAY;IAClC,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAE9C,SAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxB,IAAI,GAAG;gBAAE,MAAM,GAAG,CAAA;YAElB,oBAAI,CAAC,iEAAiE,GAAG,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACvG,IAAI,KAAK;oBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;gBAC/B,IAAI,CAAC,MAAM;oBAAE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAA;gBAEjE,IAAI,QAAkB,CAAA;gBAEtB,IAAI;oBACF,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;iBAC9B;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;iBACnB;gBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,C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AE,MAAM,EAAE,EAAE;QAC3C,OAAO,CAAC,SAAS,CAAC;aACf,IAAI,CAAC,MAAM,CAAC,EAAE;YACb,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACxD,aAAa,CAAC,UAAU,EAAE;gBACxB,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;gBAC9C,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;aACrC,CAAC;iBACC,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE;gBACX,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC,CAAC,CAAA;QACN,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,0CAqBC"}
      if (err) throw err

Fixed code:
                return reject(new Error('wrong file provided'));
        if (!outputFile || !options || !options.seconds || !options.sampleRate || !options.numOfChannels)
            return reject(new Error('malformed props to createMuteOgg'));
        if (!Number.isInteger(options.seconds) ||
            !Number.isInteger(options.sampleRate) ||
            !Number.isInteger(options.numOfChannels))
            return reject(new Error('malformed numerico options prop for createMuteOgg'));
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,iDAAoC;AACpC,2BAAyB;AAiHzB,iBAAwB,IAAY;IAClC,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAE9C,SAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EA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AAQ,CAAC,CAAA;YACxD,aAAa,CAAC,UAAU,EAAE;gBACxB,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;gBAC9C,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;aACrC,CAAC;iBACC,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE;gBACX,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC,CAAC,CAAA;QACN,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,0CAqBC"}
import { reject } from 'bluebird'
      if (err) return reject(new Error('wrong file provided'))
    if (!outputFile || !options || !options.seconds || !options.sampleRate || !options.numOfChannels)
      return reject(new Error('malformed props to createMuteOgg'))

    if (
      !Number.isInteger(options.seconds) ||
      !Number.isInteger(options.sampleRate) ||
      !Number.isInteger(options.numOfChannels)
    )
      return reject(new Error('malformed numerico options prop for createMuteOgg'))