A lockfile is not integrity: dependency provenance as a control
A pinned lockfile stops unplanned upgrades but says nothing about whether the package inside your build is the one its author published. That is the difference between reproducibility and integrity.
Two things that get conflated
Reproducibility means the build always uses the same versions. Integrity means those versions match what the author actually published. A lockfile gives you the first, not the second. The common infection path in a package ecosystem is not a vulnerability in code — it is the moment of publication. An attacker takes over an account or registers a name two characters off a popular package, publishes a version with a postinstall script, and waits for the first npm install in CI.
What helps, in order of usefulness
- Pinned hashes, not just versions.
package-lock.jsonwithintegrity, or pnpm hashes;npm ciinstead ofnpm install. - No lifecycle scripts in CI.
--ignore-scriptsby default; allow scripts only where necessary and reviewed. - Provenance and signatures. Verify package provenance (e.g.
npm audit signatures, SLSA attestations) where the ecosystem offers it — as a requirement, not a formality. - An SBOM per build. Without a component list you cannot answer "are we affected" inside an hour, which is the only deadline that matters.
- A single registry or proxy for all dependencies, with manual promotion of new packages.
The practical bar
If your CI can install a package you first saw five minutes ago, you do not have supply-chain control — you have hope. Make new packages wait for human promotion; let existing ones update automatically.