Skip to content

.npmrc security checker

Free, no sign-up Runs in your browser

Paste an .npmrc and find auth tokens written in the file, strict-ssl=false, plain HTTP registries and registries that no scope points to. Tokens are redacted.

Checked as you type. Nothing you paste leaves this page, and secrets are shown redacted.

The file is read in your browser. It is not uploaded.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the .npmrc security checker

  1. Paste the .npmrc from your project or home directory, drop it, or load the example.
  2. Revoke any token the checker found, then replace it with ${NPM_TOKEN}.
  3. Point each private scope at its registry with an @scope:registry line.
  4. Decide whether ignore-scripts=true fits your project.

About this tool

The .npmrc file tells npm which registry to use and how to log in to it. A project-level .npmrc is usually committed, copied into Docker builds and uploaded with CI caches, so a token written into it travels to all those places. With an npm publish token, someone else can release a new version of your package.

This checker reports tokens, Base64 credentials and passwords that are literal values and not ${VARIABLE} references, and shows them redacted. It reports strict-ssl=false, which makes npm accept any certificate, and registries reached over plain HTTP. It also reports credentials for a registry that no registry or @scope:registry line points to: private packages are then resolved from the public registry, which is the opening for dependency confusion.

Finally it notes whether ignore-scripts is set, since install scripts are how most malicious packages run their code. The file is checked in your browser. The rules cover what the file says, not how your registry or proxy is configured, and not the .npmrc in your home directory unless you paste that one too.

Sources

Questions

Is it safe to commit .npmrc?

Yes, if it holds only settings and variable references such as //registry.npmjs.org/:_authToken=${NPM_TOKEN}. npm replaces the reference with the environment variable at run time. A literal token in a committed file is a leaked token.

What is dependency confusion?

An attack where someone publishes a public package with the same name as your private one, with a higher version number. If your client looks in the public registry for that name, it installs theirs. Scoped packages with the scope mapped to your private registry prevent it.

What does ignore-scripts do?

It stops npm from running preinstall, install and postinstall scripts of dependencies, and also the scripts in your own package.json when run through npm install. That blocks the usual way malicious packages execute. Packages that compile native code then need an explicit npm rebuild.

How should CI publish to npm without a token in a file?

Use trusted publishing, where npm accepts a short-lived OIDC identity from GitHub Actions or GitLab CI and no long-lived token exists. Where that is not available, store a granular token as a CI secret and expose it as an environment variable for the publish step only.

Related tools