Skip to content
RCE Disclosed report Beginner

bunyan - RCE via insecure command formatting

The bunyan CLI formats user input into a shell command without checks, letting a crafted -p argument run commands on the local machine.

ahihi Follow

Originally disclosed on HackerOne

  • Triaged in 23 hours
  • Fixed in 5 days
  • Disclosed after 8 days

I would like to report RCE in bunyan It allows arbitrary commands remotely inside the victim's PC

Module

module name: bunyan version: 1.8.12 npm page: https://www.npmjs.com/package/bunyan

Module Description

Bunyan is a simple and fast JSON logging library for node.js services:

Module Stats

[920,196] weekly downloads

Vulnerability

Vulnerability Description

The issue occurs because a user input is formatted inside a command that will be executed without any check. https://github.com/trentm/node-bunyan/blob/master/bin/bunyan#L1224

Steps To Reproduce:

Run the following command npm install bunyan ./node_modules/bunyan/bin/bunyan -p "S'11;touch hacked ;'" Recheck the files: now hacked has been created

Patch

Check input before command

Supporting Material/References:

State all technical information about the stack where the vulnerability was found

  • [OPERATING SYSTEM VERSION]: Ubuntu 18.04

Wrap up

Select Y or N for the following statements:

  • I contacted the maintainer to let them know: [Y/N] N
  • I opened an issue in the related repository: [Y/N] N

Impact

RCE on bunyan.

Attachments

Screen_Shot_2020-06-19_at_16.24.05.png
Screen_Shot_2020-06-19_at_16.24.05.png From the original on HackerOne

The original report as published on HackerOne, by ahihi. 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 bunyan CLI constructs a shell command using unsanitised user input, allowing shell metacharacters to break out and execute arbitrary commands.

Impact

An attacker could execute arbitrary commands on the machine running the bunyan CLI.

What the attacker needed

Victim runs bunyan CLI with attacker-controlled input

The fix

The input should be validated before being used in a command, or the command should be constructed safely without shell interpretation.

How it was found

  1. Install the bunyan package using npm.
  2. Run the bunyan binary with the -p option and a crafted argument containing shell metacharacters.
  3. Observe that the injected command executes, creating a file named 'hacked'.

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.

Bunyan is a logging tool for Node.js. Its command-line program takes an argument and builds a shell command from it without checking the input. Because the input is not sanitised, an attacker can include shell metacharacters to run their own commands on the victim's 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 ahihi

View all

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