Leaked secret emergency checklist
A do-it-now checklist for a leaked API key, token, or password: contain it, check for misuse, and prevent a repeat. Replace the key first. Optionally, clean it out of your git history.
Incident response.
Before anything else: replace the key. Invalidate the exposed key at the service it came from and create a new one. Nothing else on this list makes the exposed value safe. This does, no matter who already has a copy.
4. Optionally clean it out of your history#
Optional cleanup, not the fix. Rewriting history changes every commit, so everyone with a copy of the repository has to discard it and clone again. Only worth the disruption if the key must not stay in the history.
The one line that matters most is at the top: replace the key first. Everything else on this list limits the damage or prevents the next leak. Only a new key makes the exposed one safe.