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.
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)?
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
- Create a package.json with i and install keys in the scripts object.
- Set both keys to a command that prints a message.
- Run npm install on the project.
- Observe the command output in the deployment logs.
- Change the command to list files in the parent directory.
- 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.