What to do when you receive a security alert
Practical steps for the most common required actions in a codelake Research alert — key rotation, removing secrets from packages and git history, auditing access logs, and preventing future leaks.
A live, production-level credential was found embedded in plain text inside a published package. Anyone who installed or inspected that package while it was in the registry could have copied the secret — no hacking or special tools required.
codelake detected, archived, and verified the finding before the package was removed. The alert you received documents the exposure window, the observed reach, and the exact file and line where the credentials appeared.
Check whether the affected package version is in your dependency tree — directly or transitively:
If the affected version appears, your environment installed the compromised package. Treat the exposed credentials as compromised regardless of whether you personally used them.
Key rotation is replacing a compromised credential with a newly generated one, then revoking the old one. It is the single most important immediate response to a credential leak.
The goal is to make the exposed credential useless to anyone who captured it. Until you rotate, anyone who found the key in the tarball can use it — regardless of whether the package was removed.
Follow this order: generate new → deploy new → revoke old. Never revoke first — it will break your service before the new key is in place.
The process is the same regardless of provider (Stripe, AWS, GitHub, etc.):
Use environment variables as the baseline — your app reads the key at runtime from the environment, not from source:
Set env vars in your host's secrets panel (Vercel, Railway, Heroku…), not in committed .env files. A local .env is fine — but it must be in .gitignore:
For teams and production, use a secrets manager — they add auditing, rotation automation, and access control that environment variables alone don't.
If you're the package author, removing it from the current source is only the first step — git history still contains every previous commit.
npm deprecate <pkg>@"<=<bad-version>" "Contains exposed credentials — upgrade"git log and git show.The recommended tool is git filter-repo (the modern replacement for git filter-branch and BFG). It rewrites every commit containing the secret.
After force-pushing, ask all collaborators to delete their clone and re-clone. Old clones still contain the full history.
Review your provider's API access logs for the exposure window — the period between when the package was published and when you rotated the credentials. The exact window is documented in your alert.
Filter logs by that date range and look for:
- Requests from unusual IP addresses or regions
- Unexpected charges, refunds, or payout modifications
- Customer-data reads (list/retrieve customers)
- Webhook endpoint modifications (someone adding their own endpoint)
If you find suspicious activity, preserve the logs and contact the provider's security team before anything else.