Safeguard
Developer Tools•

Does npm audit work through an internal package mirror?

npm audit asks your configured registry for advisories. Whether it works through a mirror depends on what the mirror forwards. How to test it quickly.

Safeguard Security Team
4 min read

It can, but only if your mirror answers the advisory request. npm audit sends package names and versions to the registry you have configured. If your mirror forwards that request upstream or serves its own advisory data, you get results. If it does not, npm falls back to a slower endpoint, and the docs do not say what happens after that.

What npm actually sends

Since npm 7, npm audit posts a list of package names and versions to a bulk advisory path on the default configured registry. If that call returns an error or an invalid response, npm tries an older quick audit endpoint, which the docs describe as considerably slower in most cases. The quick endpoint receives the full package tree from the lockfile plus some environment details such as the npm and Node versions.

The practical point for a small team is simple. Your mirror is now in the path of the audit. A mirror that only caches tarballs and package metadata may not know what to do with the advisory request.

The audit setting is on by default, and the config docs say npm submits audit reports to the default registry and to scoped registries. So a scope pointed at a private feed will receive audit traffic too.

Three ways a mirror can behave

Mirror behaviorWhat you seeWhat to do
Forwards the advisory path upstreamAudit results as usualNothing, but confirm once
Serves its own advisory dataResults, possibly differing from upstreamLearn how fresh that data is
Rejects or ignores the pathErrors or an empty reportAdd a separate scan of the lockfile

The middle case deserves a note. If the mirror keeps its own copy of advisory data, the freshness of that copy decides how current your audit is. Ask whoever runs the mirror how often it refreshes.

Test it from a clean machine

Run this in a small project that has a lockfile and at least one dependency you know has an advisory.

npm config get registry
npm audit
echo "exit code: $?"

Check three things. First, the registry printed is your mirror and not the public default. Second, the report lists the advisory you expected. Third, the exit code is non-zero when vulnerabilities exist, so your CI step can fail on it.

An empty report is not proof of a clean tree. It may mean the audit call silently returned nothing. That is why you want one known-vulnerable package in the test project.

If audit does not work through the mirror

Do not turn audit off and move on. You have a few options:

  1. Ask the mirror owner to enable forwarding of the advisory path.
  2. Run the audit step with the registry pointed at the upstream default for that one command, if your network policy allows it.
  3. Scan the lockfile with a separate tool that does not depend on the registry, so advisory lookup and package download are decoupled.

Option 3 tends to age best, because it keeps working when you change mirrors. It also lets you feed the same inventory to your reviewers, not just to CI.

Where Safeguard fits

Safeguard's SBOM and dependency scanning reads your project's dependency inventory, so it does not depend on which registry served the tarballs. You can try a free scan at gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen.

Click into a finding and look at how severity and fix availability sit side by side, because that is the information a failed audit leaves you without.

Quick check

Does a mirror change which advisories npm knows about?

It can. The advisory data comes from whatever answers the audit request, so a mirror with its own data may be behind upstream. Ask how often it refreshes.

Can I just set audit to false in CI?

You can, but then nothing checks the tree. Replace it with a registry-independent scan first.

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.