npm registry crossed 3M+ packages (Q1 2026). Typosquatting + dependency confusion remain the #1 attack surface. Notable 2024-2026 incidents: ua-parser-js (2021, replicated attempts in 2024), event-stream (2018 precedent, new cases in 2024), compromised-maintainer supply chain (shaii 2025). Countermeasures: Sigstore + cosign for signed packages, npm provenance (2023+), SBOM (SPDX/CycloneDX). Best practice: npm audit in CI + lock-file commit + approved registry mirror.
Below: details, example, related, FAQ.
# Verify package provenance
$ npm install lodash --auth-type=web
$ npm audit signatures
# Enable provenance when publishing (library authors)
$ npm publish --provenance
# Snyk in CI
$ npx snyk test
$ npx snyk monitor # ongoing watch
# SBOM generation
$ npx @cyclonedx/cyclonedx-npm --output-format json > sbom.jsonMinimum. Snyk / Socket.dev / GitGuardian add behavioral analysis + zero-day detection.
package.json reviews in PR, npm install --ignore-scripts (block post-install hooks), allowlists in a registry proxy.
US federal contracts — yes (EO 14028). Enterprise SaaS — often requested. 2026 best practice.