Skip to content
RCE Write-up Intermediate

How I Discovered My First Critical Vulnerability in My Bug Bounty Career

A private dependency was not reserved on the public NPM registry, so an attacker could publish a package with the same name containing a reverse shell. When the application installed or updated that dependency, NPM resolved to the public malicious package instead of the intended private one, giving the attacker code execution.

snip3rgg Follow

Published on snip3rgg.medium.com

My journey into bug bounty hunting took an unexpected turn when I stumbled upon what would become my first critical discovery – Remote Code Execution via dependency confusion. But how did I find it?

Sahil Bugade (snip3rgg), on snip3rgg.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 private dependency name was not registered or scoped on the public NPM registry, so the package manager could resolve it to a public package controlled by an attacker.

Impact

The attacker could achieve remote code execution on systems that installed the malicious package, as the text claims the exploit succeeded.

What the attacker needed

Private dependency name unclaimed publicly; ability to publish to public NPM registry; target installs or updates the dependency

How it was found

  1. Identify a private dependency name used by the target that is not claimed on the public NPM registry.
  2. Publish a package with that same name to the public registry, containing a reverse shell.
  3. Wait for the target to install or update the dependency so NPM resolves to the malicious public package.

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.

Software often relies on other pieces of code called dependencies, which are downloaded from public registries. If a company uses a private dependency name that is not claimed on the public registry, anyone can publish a package with that same name. The package manager may then download the attacker's package instead of the private one, letting the attacker run their own code.

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.