[blamer] RCE via insecure command formatting
The blamer npm module builds a shell command by inserting a caller-supplied file name without validation, so a crafted value can append extra shell commands. An attacker who can influence that argument could run arbitrary commands on the machine running the module.
- Triaged in 14 hours
- Fixed in 58 days
- Disclosed after 58 days
I would like to report a RCE issue in the blamer module.
It allows to execute arbitrary commands remotely inside the victim's PC
Module
module name: blamer
version: 0.1.13
npm page: https://www.npmjs.com/package/blamer
Module Description
Blamer is a tool for get information about author of code from version control system. Supports git and subversion.
Module Stats
[~1800] downloads in the last day [12,910] downloads in the last week [~52k] 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/kucherenko/blamer/blob/master/src/vcs/git.js#L24
Steps To Reproduce:
- Create the following PoC file:
// poc.js
var Blamer = require('blamer');
var blamer = new Blamer('git');
blamer.blameByFile('poc.js', 'test; touch HACKED;#');
- Check there aren't files called
HACKED - Execute the following commands in another terminal:
npm i blamer # Install affected module
node poc.js # Run the PoC
- Recheck the files: now
HACKEDhas been created :)
Screenshot_from_2020-01-11_23-50-17.png From the original on HackerOne
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 blamer
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the file name is concatenated into a shell command string instead of being passed as a separate, escaped argument.
Impact
Arbitrary commands could be executed on the victim's machine, though only if the attacker can control the file name passed to the library.
What the attacker needed
Attacker controls the file name argument; victim runs code using the module
How it was found
- Create a small script that loads the module and calls its blame function with a crafted file name.
- Confirm no file named HACKED exists yet.
- Install the affected module and run the script.
- Check again: the HACKED file now exists.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This package runs a system command to ask git who wrote a file. It pastes the file name straight into that command line, so a name containing shell punctuation can end the command early and start a new one. Anyone who can pass such a name to the library gets their own commands run on that computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.