# Leaked npm Access Token? Revoke It and Check Your Packages

> npm access token exposed on GitHub? Revoke it, check publish history for tampered versions and enable 2FA. Step-by-step guide.

Source: https://leakwatch.net/secrets/npm-access-token

---

[LeakWatch](/)

[Product](/product)[Live feed](/leaks)[Guides](/secrets)[Blog](/blog)[Free scan](/)

1.  [Home](/)
2.  [Secrets](/secrets)
3.  npm Access Token

Code & CI · Secret guide

# Leaked npm Access Token: what to do in the first hour

Critical severityChecked liveLast verified October 2, 2026 · 5 min read

An npm access token authenticates to the npm registry as your account. Depending on its permissions, it can read private packages and, more importantly, publish new versions of every package you maintain. That is the supply-chain risk: a malicious release of a package other projects depend on runs on their machines the next time they install. A leaked token with publish rights is therefore about the people downstream as much as about you. Revoke it, then check what your packages’ history says.

[Check your GitHub account for leaked secrets — free](/)

Provider

npm

Severity

Critical

Impact

Source code and build access

Checked live by LeakWatch

Yes

## What an npm access token looks like

npm tokens use a recognizable prefix followed by a fixed-length alphanumeric body:

```text
npm_…XXXX   npm access token (masked)
```

The prefix does not tell you what the token can do. npm has two generations of tokens: older classic tokens (read-only, automation or publish) and newer granular access tokens, which can be scoped to specific packages or organizations, to read or write access, and given an expiry date. Both authenticate the same way, and npm now issues only granular ones, so a `npm_` value found in a repository can be either. Open the token list in your account to see which one you have.

An **`.npmrc` auth line** (`//registry.npmjs.org/:_authToken=…`) is just a file that stores the token; the token inside it is the secret. A **GitHub token** with publish rights to GitHub Packages is a different credential, see the [GitHub personal access token](/secrets/github-personal-access-token) guide.

## How npm access tokens get leaked

-   **Committed `.npmrc` files.** A project-level `.npmrc` with `_authToken` set, pushed along with the source.
-   **CI workflow files and secrets output.** Release pipelines that publish on tag, with the token written in the workflow instead of in the platform’s secret store, or printed in a log by a debug step.
-   **Docker builds.** A token passed with `ARG` or copied into an image to install private packages, then readable in the image layers.
-   **Published packages.** A package tarball published with a `.npmrc` or an `.env` file inside it because the `files` list or `.npmignore` did not exclude it.
-   **Shared dotfiles and screenshots.** Home-directory configs pushed to a public dotfiles repository.

## What to do in the first hour

1.  **Revoke the token first.** On [npmjs.com](http://npmjs.com), sign in, open the account menu and go to *Access Tokens*. Delete the exposed token. Do this before you replace it: a new token is worth nothing if the old one is still live.
2.  **Create a replacement with the narrowest scope.** On the same page, generate a new granular token limited to the packages it needs, with the shortest expiry that works for you and read-only access if the job only installs.
3.  **Audit your packages for releases you did not make.** For each package you maintain, open its *Versions* tab on [npmjs.com](http://npmjs.com), or run `npm view <package> time` locally. Look for versions or dist-tags you do not recognize, published since the exposure.
4.  **Deal with any tampered release.** If you find one, deprecate the version with a clear message (`npm deprecate`), publish a clean new version from a trusted machine, and contact npm support to have the malicious release removed. Tell the people who depend on the package.
5.  **Check your account.** In your profile settings, review active sessions, other tokens and who has publish rights to your packages and organizations. Delete what you cannot explain.
6.  **Turn on two-factor authentication** for publishing, and consider publishing from CI with provenance and trusted publishing instead of long-lived tokens.
7.  **Then clean the repository**: remove the value and rewrite history if you want to. See [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github).

Not sure what else leaked? [Run a free scan](/).

[Not sure what else leaked? Run a free scan.](/)

## Revoke it at npm

Revocation is done on the npm website, and the exact page can change, so follow the menu path rather than a saved link. Sign in to [npmjs.com](http://npmjs.com), click your profile picture, open *Access Tokens*, find the token by its name or last characters, and delete it. For a token that belongs to an organization or a teammate, the owner of the token must do it, or an organization owner can remove the member’s publish access. Once deleted, the token fails on the next registry request. Using the command line is also possible with `npm token list` and `npm token revoke`, but the website shows more information.

## How LeakWatch detects it

The rule is called “npm Access Token”. It looks for `npm_` followed by 36 letters or digits, ignoring case, and expects the value to end at a quote, whitespace, a semicolon, a line end or similar, which cuts false positives on longer strings. **This type is checked live**: LeakWatch can check whether a detected token is still active with a read-only request to the npm registry’s `whoami` endpoint, which only returns the account the token belongs to. It never publishes, never reads your private packages and never spends anything.

LeakWatch can check whether a detected key is still active with a read-only request to npm. It never reads your data or spends your credits.

## FAQ

Is a read-only token still a problem?

It is less serious, because it cannot publish, but it can download private packages, which may include source code and other secrets. Revoke it all the same, and rotate any secret you find inside those packages.

I use two-factor authentication. Am I covered?

Not necessarily. Tokens are created with different 2FA settings, and automation-style tokens can bypass the second factor so that CI can publish. Check the token’s settings; a granular token that bypasses 2FA has the same reach as a leaked password.

How do I know if a malicious version was installed by my users?

You cannot see their installs, but the publish time tells you the window. Compare the timestamps of your versions with the exposure time, deprecate anything suspicious and tell your users to pin to a known-good version.

## Related

-   [GitHub Personal Access Token](/secrets/github-personal-access-token)
-   [Docker Hub Access Token](/secrets/docker-hub-access-token)
-   [GitLab Personal Access Token](/secrets/gitlab-personal-access-token)
-   [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github)
-   [Which vendors leak most this week](/leaks/trends)
-   [All secret guides](/secrets)

[Get alerted next time a secret leaks — create a free account](/)

LeakWatch is not affiliated with npm.

![Gabriel Diyan, founder of LeakWatch](/brand/Photo-Gabriel-Diyan.webp)

Gabriel Diyan (0xCr0c0)

Cybersecurity student, founder of LeakWatch. I built and run the scanner described here — the detection patterns, the false-positive classifier and the provider validators are mine. [More about who I am](/about).

[GitHub](https://github.com/Leakwatch-Scan) · [X](https://x.com/LeakwatchScan) · [LinkedIn](https://www.linkedin.com/in/gabriel-diyan-80a378375) · [GitHub (personal)](https://github.com/crocogab)

LeakWatch

Secrets leak into public commits every minute. This watches the forges for yours. Built and run by [Gabriel Diyan](/about), a cybersecurity student — [why LeakWatch exists](/about).

Scan

-   [Product](/product)
-   [Live feed](/leaks)
-   [Trends](/leaks/trends)
-   [API docs](/docs)
-   [CI/CD](/docs?tab=ci)

Read

-   [Blog](/blog)
-   [Secret guides](/secrets)
-   [Changelog](/changelog)
-   [About](/about)

Verify

-   [Security](/security)
-   [Privacy](/privacy)
-   [Terms](/terms)
-   [Legal](/legal)
-   [Contact](/contact)
-   [Status](https://status.leakwatch.net)

© 2026 LeakWatch

[GitHub](https://github.com/Leakwatch-Scan)[X](https://x.com/LeakwatchScan)
