npm Publish Security: Monitor and Audit Package Releases
Do you know who published your last package version? Supply chain attacks on npm packages are increasingly common. Monitoring publish activity helps you detect unauthorized releases quickly and maintain an audit trail for compliance.
In this guide:
Why monitor npm publishes?
npm package compromises have affected major projects like event-stream, ua-parser-js, and coa. In each case, attackers gained publish access and released malicious versions. Early detection is critical.
Detect unauthorized access
Know immediately when a version is published — especially if you didn't trigger it.
Verify automation
Confirm that CI/CD publishes are working correctly and using the expected method (OIDC).
Compliance requirements
Many security frameworks require audit logs of software releases.
Team visibility
Keep everyone informed about releases without checking npm manually.
OIDC vs token publishing
npm supports two authentication methods for publishing. Each appears differently in notification emails and has different security implications.
Trusted Publishing (OIDC)
GitHub Actions, GitLab CI, or other CI providers authenticate directly with npm using short-lived tokens. No secrets to store or rotate.
In notification emails:
Published via OIDC by github:actionsAccess Token
Traditional npm tokens stored as secrets. Can be used from CI or manually. Requires careful secret management.
In notification emails:
Published via tokenSecurity best practices
✓Use Trusted Publishing (OIDC) for CI/CD
Configure your GitHub Actions or GitLab CI to use npm's Trusted Publishing instead of storing tokens as secrets.
npm Provenance documentation →✓Enable 2FA for all maintainers
Require two-factor authentication for everyone with publish access. For organizations, enforce this at the org level.
✓Use granular access tokens
When tokens are necessary, create tokens scoped to specific packages rather than using tokens with full account access.
✓Regularly audit maintainers
Check who has publish access to your packages:
npm access ls-collaborators <package>
Remove anyone who no longer needs access.
✓Monitor publish notifications
Don't ignore npm emails. Every publish should be expected. If you see one you didn't trigger, investigate immediately.
Maintaining an audit trail
npm notification emails contain valuable audit information, but they get buried in your inbox — especially if you maintain many packages or publish frequently.
The problem: if you maintain 20 packages and do weekly releases, that's 80+ emails per month. Important security signals get lost in the noise.
Consolidate your audit trail
npmDigest aggregates all your publish notifications into a single digest email. See all releases at a glance, grouped by scope, with publishing metadata (OIDC, token, timestamps) preserved.
- ✓Daily, weekly, or monthly digest frequency
- ✓OIDC vs token clearly visible
- ✓Packages grouped by @scope
- ✓Export data as JSON for compliance
If you suspect a compromise
If you see a publish you didn't authorize, act fast:
- 1
Deprecate the suspicious version
npm deprecate <package>@<version> "Security issue - do not use"
- 2
Revoke all access tokens
Go to npmjs.com/settings/tokens and delete all tokens. Regenerate only what you need.
- 3
Audit maintainer access
Review who has publish access and remove anyone suspicious or unnecessary.
- 4
Publish a patched version
Release a new version that supersedes the compromised one.
- 5
Report to npm security
Email security@npmjs.com with details about the incident.