Safeguard
Supply Chain•

A package registry token leaked: what should you check and revoke?

Revoke the token, list recent publishes, check who has access and look for new versions you did not release. A checklist for npm and PyPI tokens.

Safeguard Security Team
3 min read

If a package registry token leaked, revoke it, create a narrower replacement, list every release published since the leak, and look for versions you did not make. A token that can publish is a way to ship malware under your name, so treat the leak as a possible compromised release until shown otherwise.

Why registry tokens are special

A leaked cloud key exposes your cloud. A leaked publish token exposes everyone who installs your package. The right response checks both the token and what it may already have done.

Checklist

StepnpmPyPI
Revoke the tokenDelete it with npm token commands or the websiteRevoke it from your PyPI account
List recent releasesCompare version list and times with your recordsCompare release history with your records
Look for odd versionsAnything you did not publishAnything you did not upload
Check maintainersReview owners with npm owner lsReview project collaborators
ReplaceGranular token, narrow scope, short expiryNarrowest scope PyPI offers

The npm docs say only granular tokens are supported now, legacy tokens were removed in November 2025, you set an expiration when you create a token, and tokens lose access automatically if the owner loses access to the package or organization. Choose the narrowest scope and the shortest expiry that works.

Steps

  1. Revoke the leaked token first. Do not wait.
  2. Compare the registry's release list with your own release records, for the time since the token was created, not only since you noticed the leak.
  3. If you find a release you did not make, treat it as a compromised package: report malware to the registry, publish a clean higher version and warn users. See the maintainer first 24 hours guide.
  4. Find how it leaked: committed file, CI log, shared document. Remove it there and check history, see leaked secret in git history.
  5. Replace with a scoped token, and prefer trusted publishing where your registry supports it.
  6. Review other tokens in the same place the leak came from.

Check use

Registry audit views vary. Where a registry does not show token use, rely on the release history and your own CI logs, and say what you could not see.

Reduce the next leak

Keep tokens out of source files and shared documents, scope each token to one project, and give each a short expiry. Where the registry supports trusted publishing from CI, prefer it over stored tokens, since there is then no long lived secret to leak. Run secret scanning on repositories and CI logs, and treat any hit as a reason to check the release list, not only to rotate.

Quick check

The token was only exposed for an hour, do I still need to check releases?

Yes. A publish takes seconds. Check the release list for the whole life of the token.

Is a read only token a concern?

Less so, but it can expose private packages. Revoke and replace it too.

Safeguard's SBOM and dependency scanning can help show which of your projects depend on your own published packages. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.