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

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
- Install the bunyan package using npm.
- Run the bunyan binary with the -p option and a crafted argument containing shell metacharacters.
- 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.