Skip to content
RCE Disclosed report Beginner CVE-2020-8137

[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.

mik317 Follow

Originally disclosed on HackerOne

High 7.5 View original
  • 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:

  1. Create the following PoC file:
JavaScript
// poc.js
var Blamer = require('blamer');
var blamer = new Blamer('git');
blamer.blameByFile('poc.js', 'test; touch HACKED;#');

  1. Check there aren't files called HACKED
  2. Execute the following commands in another terminal:
Bash
npm i blamer # Install affected module
node poc.js #  Run the PoC
  1. Recheck the files: now HACKED has been created :)
    Screenshot_from_2020-01-11_23-50-17.png
    Screenshot_from_2020-01-11_23-50-17.png From the original on HackerOne

Patch

Don't format commands using insecure user'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

The original report as published on HackerOne, by mik317. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Create a small script that loads the module and calls its blame function with a crafted file name.
  2. Confirm no file named HACKED exists yet.
  3. Install the affected module and run the script.
  4. 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.

More by mik317

View all

23 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.