Skip to content
RCE Write-up Beginner

My First Remote Code Execution (RCE)

The windows-edge Node.js module passed a user-supplied URI into a shell command, so a crafted URI containing shell metacharacters could run arbitrary commands. A later version switched to execFile and URL-encoding but kept shell: true, so a URI with a command separator still executed commands such as launching the calculator.

medium.com

Published on medium.com

I have been doing bug bounty for a while but, due to work pressure, were not able to spend sufficient time on this. Nevertheless, whenever I get some time for myself, I dive into the bug bounty reports to gain more knowledge and hone my skills.

BongHaxor, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code passed user-controlled input to a shell command without safe argument separation, and the later fix kept shell: true, so shell metacharacters still worked.

Impact

An attacker who can control the URI passed to the module could run arbitrary commands on the host, though the text only demonstrates this locally with the calculator.

What the attacker needed

Attacker controls the URI passed to the module; the module runs on Windows

The fix

The module should remove shell: true, strictly validate the URI, and use spawn or execFile without a shell; the text notes the maintainers did not reply to the report.

How it was found

  1. Review the module source and note that the URI is concatenated into a shell command.
  2. Check the command manually in the Windows command prompt.
  3. Write a small script that calls the module with a URI containing a command separator and a command.
  4. Run the script and observe the command execute, such as the calculator opening.

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 write-up has not been written yet. The Original tab links to the source.

This is about a small helper library that opens a web page in Microsoft Edge. It built a command for the operating system by gluing the user's web address onto a fixed command, so special characters in the address could start extra commands. The first fix blocked one style of input, but a setting that still runs commands through a shell let another style through.

What is RCE?

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

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.