An open API service indexing awesome lists of open source software.

npm-security-best-practices

Collection of npm package manager Security Best Practices
https://github.com/lirantal/npm-security-best-practices

Last synced: about 1 month ago
JSON representation

13. Consult the Snyk Security Database for package health

Follow-up resources

14. Do not trust the official npmjs.org registry

Follow-up resources

  • npmjs.org - based dependencies even when they are declared in a package's package.json file. This means a package may have non-registry dependencies that are invisible to users browsing the registry website.

1. Disable Post-Install Scripts

1.1. pnpm disable post-install scripts

1.2. Bun disable post-install scripts

2. Install with Cooldown

2.1. pnpm / Bun / Yarn minimumReleaseAge cooldown

2.2. Snyk automated dependency upgrades with cooldown

2.3. Bun minimumReleaseAge cooldown

2.3. Dependabot automated dependency upgrades with cooldown

2.4. Renovate bot automated dependency upgrades with cooldown

3. Harden package installs with security tools

3.2. Use Socket Firewall (sfw) for blocking malicious packages

  • Socket Firewall (`sfw`) - time firewall that intercepts supported package manager commands and blocks packages flagged for malicious behavior, using Socket's deep package analysis and threat intelligence.

3. Use npq for hardening package installs

2.2. Snyk automated dependency upgrades with cooldown

  • npq - risk packages.

4. Prevent npm lockfile injection

Advanced usage options

Bun lockfile linting

6. Avoid blind npm package upgrades

Lockfile management best practices

7. No plaintext secrets in .env files

Follow-up secure secrets resources

8. Work in Dev Containers

Follow-up resources

Follow-up secure secrets resources

Author

Additional mitigations

Follow-up resources