Secrets Bundled in Published Packages
Overview
When publishing packages without a proper .npmignore or explicit files field in package.json, sensitive files like .env, *.pem, and test credentials get included in the published artifact and become visible to anyone who installs the package.
Remediation
- Add
.npmignorewith patterns for.env,*.key,*.pem,test/,secrets/ - OR use the
filesfield inpackage.jsonto explicitly list only publishable files - Run
npm publish --dry-runto see what will be included