Course contentsShow
← Security
Lesson 1291 of 3,05226. Application Security - Supply ChainFree lesson

Package Name Reservation and Defensive Registration

Proactively registering internal package names on public repositories to prevent dependency confusion.

Package Name Reservation and Defensive Registration

What you'll learn: How to proactively claim your internal package names on public repositories before attackers exploit dependency confusion vulnerabilities.

The Problem

You've learned about dependency confusion attacks where attackers upload malicious packages with your internal package names to public repositories. If your package manager checks the public repository first (or prioritizes higher version numbers from public sources), you could accidentally install the attacker's code instead of your legitimate internal package.

The Defensive Strategy

Package name reservation means proactively registering placeholder packages on public repositories (npm, PyPI, RubyGems, etc.) using the same names as your internal, private packages—before an attacker does. These defensive packages typically contain minimal or no code, just enough to "claim" the namespace.

Think of it like buying a domain name for your business: even if you're not using it yet, you register it to prevent someone else from squatting on it and confusing your customers.

How It Works

When you identify internal package names used in your organization:

  1. Register those exact names on relevant public repositories
  2. Publish empty or minimal placeholder packages with clear ownership metadata
  3. Mark them appropriately (some repositories offer "reserved" or "placeholder" flags)
  4. Document internally that these are defensive registrations, not actual packages

This prevents attackers from claiming those names and ensures that even if your package manager checks the public repository, it will only find your placeholder—not malicious code.

Important Considerations

Some package repositories have policies about placeholder packages or namespace squatting. Always follow the repository's terms of service. Some organizations publish lightweight "stub" packages that clearly identify themselves as internal package placeholders.

Key Takeaway: Defensive registration claims your internal package names on public repositories before attackers can, blocking dependency confusion attacks at the source by controlling the namespace.