Skip to content
RCE Write-up Intermediate

Easiest Way To Find Rce Package Dependency

The article describes a method for finding unclaimed npm package names referenced in a target's package.json files, then publishing a malicious package under that name so that the target's build or install process runs attacker code. The author claims this can lead to remote code execution when the victim installs the dependency.

JEETPAL Follow

Published on infosecwriteups.com

Free Article

JEETPAL, 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

Impact

If the target installs the dependency from the public registry rather than a local copy, the attacker's code could run during install, giving remote code execution.

What the attacker needed

Target lists an unregistered npm package; attacker has an npm account; target installs from public registry

How it was found

  1. Enumerate subdomains of the target and probe them for exposed package.json files.
  2. Read the package names listed in the discovered package.json.
  3. Check whether each package name is registered on the npm registry.
  4. Create an npm account and initialise a package with the same name.
  5. Add a preinstall script that calls back to a collaborator or webhook.
  6. Publish the package and watch for the callback to confirm code execution.

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 software is built, it downloads other small pieces of code called packages from a public registry. If a company lists a package name that nobody has registered yet, an attacker can register it first and put harmful code inside. When the company next builds its software, that harmful code runs on their machines.

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 JEETPAL

View all

12 more disclosed reports, 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.