Skip to content
RCE Disclosed report Beginner

[open] concatenation of unsanitized input into exec() command

The npm package 'open' concatenated user-supplied URLs into a shell command without escaping, allowing an attacker to inject arbitrary shell commands. An attacker who can control the URL passed to the module could execute commands on the victim's machine.

chalker Follow

Originally disclosed on HackerOne

High 8.4 View original
  • Triaged in 7 days
  • Fixed in 3 months
  • Disclosed after 22 months

I would like to report command injection in open. It allows to inject arbitrary shell commands by specifing crafted urls.

Module

module name: open version: 0.0.5 npm page: https://www.npmjs.com/package/open

Module Description

Open a file or url in the user's preferred application.

Module Stats

31 293 downloads in the last day 473 107 downloads in the last week 1 968 932 downloads in the last month

~23 627 184 estimated downloads per year

Vulnerability

Vulnerability Description

Urls are not properly escaped before concatenating them into the command that is opened using exec().

Steps To Reproduce:

JavaScript
require("open")("http://example.com/`touch /tmp/tada`");

Observe /tmp/tada/ file created.

Supporting Material/References:

  • Arch Linux Current
  • Node.js 9.5.0
  • npm 5.6.0
  • bash 4.4.012

Wrap up

  • I contacted the maintainer to let him know: N
  • I opened an issue in the related repository: N

Impact

User A who can pass urls for them being open-ed on machine B can execute arbitrary shell commands on machine B.

The original report as published on HackerOne, by chalker. 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

Impact

An attacker who can supply the URL to be opened on a victim's machine could execute arbitrary shell commands there.

What the attacker needed

Attacker can control the URL passed to open(); victim runs the open module on their machine

How it was found

  1. Call the open module with a URL containing a shell command substitution.
  2. Observe that the injected command runs and creates a file.

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.

The 'open' package runs a system command to open a file or web address. It put the address directly into that command without cleaning it, so special characters like backticks could make the computer run extra commands. This means someone who can choose the address could run their own commands on your 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 chalker

View all

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