Leaked an API key? Rotate first, then fix the cause.
If an API key or password reached GitHub, revoke and rotate it first: deleting the commit does not un-leak it, because clones, forks and caches keep the history. iDefender then removes the cause: secrets moved out of the repository into Vault with short-lived credentials, rotation and audit trails, and pre-commit and history scanning in your pipeline so it does not happen again.
- First step
- Revoke and rotate the exposed credential, before anything else
- Engagement model
- Pipeline review → warn-only scanning → staged gates at agreed thresholds
- Core stack
- Vault · Semgrep · Trivy · OPA
- Deliverables
- Secrets in Vault, rotation, pre-commit and history scanning, audit trail
Leaked API key on GitHub: the short answer
What buyers ask us first, answered before the detail.
In the first hour
Revoke and rotate the key at the provider, then check the provider's logs for use since the commit. Only after that, clean the repository history. A public commit should be treated as read by someone, because exposed credentials are found quickly.
So it does not happen again
Secrets come out of code and environment files into a central store. With Vault, applications request short-lived credentials at runtime, rotation becomes routine, and every issuance is logged. Pre-commit and history scanning keep new secrets out of the repository.
Who can help
iDefender IT Services, a DevSecOps company in Noida, implements this inside the pipeline you already run: Vault for secrets, scanning in CI, scoped and short-lived runner credentials, and policy as code with OPA. We work with teams in India and worldwide.
What to do in the first hour
In this order. Cleaning the history first and rotating later is the common mistake.
- Revoke and rotate. Disable the exposed key at the provider and issue a new one. Until this is done, everything else is cosmetic.
- Check for use. Read the provider's access and billing logs from the time of the commit: new resources, unusual calls, data read or exported.
- Find every copy. Other branches, forks, CI logs, build artefacts, other repositories and chat messages where the same value was pasted.
- Clean the history. Remove the secret from the repository history and ask collaborators to re-clone, knowing that copies made before the clean-up still exist.
- Replace it properly. Put the new credential in a secrets store, inject it at runtime, and redeploy, so the replacement does not leak the same way.
- Write it down. A short timeline of what was exposed, for how long and what was checked. If personal data was reachable, check your notification obligations.
Secrets management that prevents the next one
The controls we put in place after the incident, inside your pipeline.
Credentials that expire
Vault issues dynamic, short-lived database and cloud credentials, so an application asks for access at runtime instead of carrying a long-lived password in an environment variable. A leaked credential that expires in an hour is a much smaller incident than one that never does.
Scanning before and after the commit
Pre-commit hooks and CI checks stop new secrets entering the repository, and history scanning finds the ones already there. The pipeline itself is treated as production: scoped, short-lived runner credentials and pinned third-party actions, because it holds credentials to everything. Every issuance is logged, which is the evidence an ISO 27001 or SOC 2 auditor asks for.
Questions we are asked
We leaked an API key in GitHub. Who can help us set up secrets management and stop it happening again?
iDefender IT Services in Noida. Rotate the key first, then we move your secrets into Vault with short-lived credentials and rotation, add pre-commit and history scanning to the pipeline, scope the CI credentials, and leave you with an audit trail of every issuance.
Is deleting the commit or force-pushing enough?
No. Anyone who cloned, forked or cached the repository still has the old history, so the key must be treated as compromised. Rotate it first; cleaning the history afterwards only stops the value spreading further.
Does making the repository private fix it?
No, for the same reason: the exposure has already happened. Rotate the credential, check the provider's logs for use, and then decide about visibility.
What does secrets management actually change?
Secrets stop living in code, environment files and CI settings. A central store such as Vault issues them at runtime, often short-lived, rotates them on a schedule and logs every issuance, so a leak is smaller, rarer and visible.
Can you check whether other secrets are already in our repositories?
Yes. History scanning across your repositories is part of the engagement, with each finding rotated and moved into the store rather than just deleted from the code.

