Skip to content
RCE Disclosed report Intermediate

Arbitrary Code Execution via npm misconfiguration – installing internal libraries from the public registry

A Node.js project was configured to resolve internal private modules from the public npm registry, so an attacker could publish a higher-version package with the same name and have it installed during builds. The malicious package's install script then ran on the build machine, giving arbitrary code execution.

alexbirsan Follow

Originally disclosed on HackerOne

Bounty$11,500incl. $1,500 bonus Critical 10.0 View original
  • Triaged in under an hour
  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 7 months

Summary by the program

Due to misconfiguration of the Private NPM registry, a nodejs-based project was able to install a malicious module generated by an attacker instead of a normal module. If an attacker registers a higher version with the same name as a private module with Global Registry, it will download and install malicious modules from the Global Registry rather than normal packages stored in private registry when building nodejs-based projects.

If the malicious package is installed, the malicious script in the package is executed on the machine where it was downloaded on.

As such, arbitrary code execution could have occurred on the affected hosts.

The original report as published on HackerOne, by alexbirsan. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the npm client or registry configuration allowed fallback to the public registry for scoped/private package names, so a higher public version shadowed the internal one.

Impact

Arbitrary code execution could have occurred on the affected hosts where the malicious package was installed.

What the attacker needed

Ability to publish to public npm; build resolves private names publicly

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 report has not been written yet. The Original tab links to the source.

Projects often use private packages kept in a company registry. If the build tool is set up to also look at the public npm registry, someone can upload a package with the same name but a higher version number. The build then downloads the attacker's package, and any script inside it runs on the build machine.

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 alexbirsan

View all

11 more disclosed reports, best first.

More from LY Corporation

View all

The newest disclosed reports for this program.

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.