npm registry прошёл 3M+ пакетов (Q1 2026). Typosquatting + dependency confusion остаются #1 attack surface. Знаковые инциденты 2024-2026: ua-parser-js (2021, replicated tried again 2024), event-stream (2018 precedent, новые cases в 2024), compromised-maintainer supply chain (shaii 2025). Контрмеры: Sigstore + cosign для signed packages, npm provenance (2023+), SBOM (SPDX/CycloneDX). Best practice: npm audit в CI + lock file commit + approved registry mirror.
Ниже: подробности, пример, связанные, FAQ.
# Verify package provenance
$ npm install lodash --auth-type=web
$ npm audit signatures
# Enable provenance для publish (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.jsonМинимум. Snyk / Socket.dev / GitGuardian деплят behavioral analysis + zero-day detection.
package.json reviews в PR, npm install --ignore-scripts (block post-install hooks), allowlists в registry-proxy.
Для US federal contracts — yes (EO 14028). Для SaaS с enterprise — часто требуют. Best practice в 2026.