Skip to content
RCE Write-up Intermediate

Dependency Confusion: A Namespace Takeover Story

The organisation's npm namespace was unclaimed, so anyone could register it and publish packages under the organisation's name. An attacker could then distribute malicious packages that developers might install, though the text does not show this actually happening.

sakshirathore3478 Follow

Published on medium.com

In the world of software development, we often focus on securing our code, but sometimes the risks lie in the dependencies we rely on. I recently stumbled upon a bug that perfectly illustrates this, which I like to call “Dependency Confusion: Namespace Takeover.” Here’s how it all went down.

Sakshi Rathore, on 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 organisation referenced an internal or private package namespace that was never registered on the public npm registry, leaving the name free for anyone to claim.

Impact

An attacker could publish packages under the organisation's name, which could lead to severe security issues if developers installed them, although the text does not demonstrate this occurring.

What the attacker needed

Organisation uses an unregistered public namespace; attacker can register that namespace

The fix

The organisation should register and control its namespace on the public registry, or otherwise ensure its package names cannot be claimed by outsiders.

How it was found

  1. Find a file on the target that lists package names associated with the organisation.
  2. Look up those package names on npmjs.com.
  3. Observe that the organisation's namespace returns a 404, meaning it is unclaimed.
  4. Register the namespace to confirm it can be taken over.

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 projects often use small building blocks called packages, downloaded from a public library such as npm. If a company's name is not already registered there, someone else can register it and upload packages that look official. Other developers might then download and run that attacker's code without realising it is not the real thing.

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.