DevOps Engineer interview question · Most asked

A production API credential was committed to Git. What do you do immediately, and how do you stop it happening again?

Scenario Asked in DevOps Engineer · Site Reliability Engineer (SRE) interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Treat it as compromised from the moment it was pushed: revoke or rotate the credential first, then check the provider's logs for misuse, and only then clean the repository. Removing the commit isn't enough, because clones, forks, CI logs and caches keep it.

Longer Answer

Now

  1. Rotate or revoke the credential (follow the zero-downtime rotation if production depends on it).
  2. Review access logs for the credential since the commit time; if misused, escalate as a security incident.
  3. Remove it from the repository (git filter-repo or BFG, force-push, ask collaborators to re-clone) and ask the hosting provider to purge cached views if the repo was public.

Prevent

  • Pre-commit hooks (gitleaks, detect-secrets) and server-side push protection (GitHub secret scanning push protection).
  • Secrets only in a secret manager; local development uses .env files that are git-ignored, or short-lived credentials.
  • Short-lived credentials (OIDC, IAM roles) so a leak expires on its own.
  • A blameless review: how did the secret reach the code, and what made that easy?

Key Points

  • Rotate first; history rewriting comes later.
  • Check logs for misuse.
  • Clones and caches keep old commits.
  • Push protection and pre-commit scanning.
  • Short-lived credentials limit future leaks.

Explanation

What interviewers look for

Correct priority order (revoke before cleanup) and layered prevention.

More DevOps Engineer questions

← All DevOps Engineer questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake