Interview Security & DevSecOps

What do you do if a secret has already been committed and pushed? [Intermediate]

Answer

If a secret has been committed and pushed, treat it as compromised. Immediately revoke or rotate it, assess access logs for misuse, remove it from active code/config, purge history only as cleanup, and notify affected owners. Deleting the commit is not enough.

Technical explanation

Assume the secret may have been copied by clones, forks, CI logs, caches, or dependency mirrors.

Rotation should happen before or at least alongside history cleanup so the exposed value is no longer valid.

After remediation, add detection rules and preventive controls to avoid recurrence.

Hands-on example

Incident steps: 1) Identify secret type and scope. 2) Revoke/rotate in the source system. 3) Search logs for use after exposure. 4) Remove secret from repo and CI variables. 5) Use git-filter-repo/BFG if needed. 6) Add gitleaks and secret-manager integration.

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Security & DevSecOps interview questions

← All Security & DevSecOps questions