Skip to content
RCE Disclosed report Beginner

[windows-edge] RCE via insecure command formatting

The windows-edge npm module builds a shell command by inserting a caller-supplied URI without validation, so shell metacharacters in the URI are interpreted by the shell. An attacker who can influence that value could run arbitrary commands on the victim's machine.

mik317 Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in under an hour
  • Fixed in 2 months
  • Disclosed after 3 months

I would like to report a RCE issue in the windows-edge module. It allows to execute arbitrary commands remotely inside the victim's PC

Module

module name: windows-edge version: 1.0.1 npm page: https://www.npmjs.com/package/windows-edge

Module Description

Launch a new Microsoft Edge tab on Windows

Module Stats

[102] downloads in the last week

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/eugeneware/windows-edge/blob/master/index.js#L8

Steps To Reproduce:

  1. Create the following PoC file:
JavaScript
// poc.js
const edge = require('windows-edge');
edge({ uri: 'https://github.com/; touch HACKED; #' }, (err, ps) => {})

  1. Check there aren't files called HACKED
  2. Execute the following commands in another terminal:
Bash
npm i windows-edge # Install affected module
node poc.js #  Run the PoC
  1. Recheck the files: now HACKED has been created :)
    Screenshot_from_2020-05-20_00-27-21.png
    Screenshot_from_2020-05-20_00-27-21.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 windows-edge

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 module concatenates the user-supplied URI into a shell command string instead of passing it as a separate, escaped argument.

Impact

An attacker able to control the URI passed to the module could execute arbitrary commands on the victim's PC.

What the attacker needed

Attacker controls the URI passed to the module; victim runs code using the module

How it was found

  1. Create a small script that calls the module with a crafted URI containing shell syntax.
  2. Confirm no file named HACKED exists yet.
  3. Install the affected module and run the script.
  4. Check again and see that the file was created.

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 small library opens a browser tab by running a system command. It pastes whatever address you give it straight into that command, so extra shell instructions hidden in the address get run too. That means someone who controls the address can make the computer run their own commands.

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.