Sphere
Log in Join

Why I stopped trusting npm audit --force in CI on npm 10.8.2

I stopped running npm audit in CI last month. Not because security doesn't matter, but because after the fifth "fix available via npm audit fix --force" on a dependency we don't even ship to production, I stopped trusting the signal. Here's what replaced it.

## The report that broke it

This showed up on a routine npm audit against npm 10.8.2, Node 20.12.2, a dashboard with roughly 700 resolved packages:

# npm audit report

semver <7.5.2
Severity: moderate
semver vulnerable to Regular Expression Denial of Service
fix available via npm audit fix --force
Will install semver@7.6.3, which is a breaking change
semver@7.6.3 || >=8.0.1
Depends on vulnerable versions of semver
node_modules/lru-cache/node_modules/semver

1 moderate severity vulnerability

To address all issues (including breaking changes), run:
npm audit fix --force

The vulnerable semver was nested under a build-time tool that never goes near the browser. npm audit fix --force would have upgraded a transitive dependency across a major boundary in a package we don't control. I ran it once on a branch. The build broke in a way that took an hour to untangle.

## Why the advice is often wrong

npm audit treats all dependencies the same. It doesn't know that eslint runs only in CI, or that the vulnerable axios copy is in a dev-only code generator. --omit=dev helps, but the nested dependency graph still produces warnings where the actual exploit path doesn't exist in your app. And advisories lag, a moderate ReDoS in a semver parser gets the same severity label whether it's in your request path or in a linter.

That doesn't mean ignore it. It means don't let a bot auto-apply --force.

## What I do now

Three things, in order.

Run npm audit --omit=dev --json on a schedule, not on every commit, and read the output instead of counting advisories. Then check the same tree against OSV:

npx @google/osv-scanner@1.9.2 --lockfile=package-lock.json

OSV gives you the actual advisory IDs and affected ranges, which makes it much easier to say "not reachable" and move on.

For the ones that are real, use overrides instead of --force:

{
"overrides": {
"semver": "7.6.3"
}
}

That's explicit and reviewed. It lives in the repo and everyone gets the same version.

Finally, we track the handful of runtime dependencies we actually care about in a small file and check those versions in a weekly job. It's less comprehensive than npm audit and about ten times quieter.

## The honest tradeoff

We will miss something. A transitive runtime dependency could get a real advisory and our weekly scan might not catch it for a few days. I'm okay with that, because the alternative was a CI job that failed every other day and got ignored. A check nobody reads is worse than a narrower one somebody does.

If you've got a setup that catches real issues without the noise, I'm genuinely interested, this is the part of our pipeline I'm least happy with.