Skip to content
RCE Write-up Beginner

How I Found An Rce Vulnerability In A Hosting Platform

The hosting platform ran npm install on user-supplied package.json files, and the scripts object's install and i keys were executed, allowing arbitrary commands. An attacker could run commands on the shared server and list other users' project files.

Sancho Godinho Follow

Published on infosecwriteups.com

While creating a package.json, I thought about why not add “i” and “install” keys to the “scripts” object (as they are the values that are executed to install the dependencies)?

Sancho Godinho, on infosecwriteups.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

The platform executed npm install on user-controlled package.json files without restricting the scripts that npm runs.

Impact

An attacker could execute arbitrary commands on the shared hosting server and read files from other users' projects.

What the attacker needed

A hosting account on the platform; ability to upload a package.json

How it was found

  1. Create a package.json with i and install keys in the scripts object.
  2. Set both keys to a command that prints a message.
  3. Run npm install on the project.
  4. Observe the command output in the deployment logs.
  5. Change the command to list files in the parent directory.
  6. Run a command that lists files from another project on the same server.

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.

When you install a Node.js project, npm can run setup commands listed in a file called package.json. The platform let users upload that file and ran those commands without checking them, so a user could make the server run any command they wanted.

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 Sancho Godinho

View all

1 more disclosed report, best first.

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.