Skip to content
RCE Write-up Intermediate

The Easiest RCE? How One Node.js Variable Creates Chaos

A Node.js application passed user-controlled environment variables directly into child_process.fork(), allowing an attacker to set NODE_OPTIONS with a --require flag that loads a malicious file. This could lead to remote code execution on the server.

osintteam.blog

Published on osintteam.blog

Ever heard of an RCE so simple it feels like cheating? Well, buckle up.

Krishna Kumar, on osintteam.blog

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

The application trusted user-supplied environment variables and passed them directly to child_process.fork() without sanitising or blocking dangerous keys like NODE_OPTIONS.

Impact

An attacker could achieve remote code execution, gaining a shell on the server.

What the attacker needed

Node.js app uses child_process.fork(); User input controls env variables; Attacker can place a file on server

The fix

The application should not pass user-controlled objects directly to fork(); instead, create a clean environment object and only copy allowed keys, explicitly blocking dangerous variables like NODE_OPTIONS.

How it was found

  1. Upload a malicious JavaScript file to the server (e.g., via a file upload feature).
  2. Send a request to the vulnerable endpoint with a JSON body containing an env object with NODE_OPTIONS set to --require /path/to/malicious.js.
  3. The server passes the user-controlled env object to child_process.fork(), which starts a child process that loads the malicious file, executing the attacker's code.

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.

Environment variables are settings that programs read when they start. Node.js has a special one called NODE_OPTIONS that can include a flag to load extra code before the main program runs. If a website lets users set environment variables for a new Node.js process, an attacker can abuse this to run their own code on the server.

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.