Secrets and Incident Response: Revoke Before Cleanup
A secret is not just a file
Credentials grant access to external resources. If a real credential appears in Git, treat it as potentially exposed even in a private repository. Do not paste it into chat, logs or issue reports. Notify the authorized incident owner and revoke or rotate it through its issuer promptly; verify the old credential no longer works through approved procedures.
Why deleting the file is insufficient
Git commits retain old snapshots. Removing a file in a new commit changes the new tree, not the old tree. The lab uses only the literal NOT_A_CREDENTIAL_DEMO, which cannot authenticate anywhere. A second local clone retains the original snapshot even after the source removes the file.
git show HEAD^:demo-marker.txtgit ls-tree HEAD -- demo-marker.txtContain, investigate, remediate
After immediate credential containment, investigate scope with authorized logs, replace affected deployments and update secret storage. Document time, affected systems and responsible owners without recording secret values. Coordinate any history cleanup with repository owners; rewriting changes commit IDs and may break references or signatures. Clones, forks and caches can retain copies. Do not rewrite shared history as an automatic response.
Prevent recurrence
Use an approved secret manager, scoped short-lived access, ignored local configuration and pre-push protection where available. Ignore rules do not remove tracked files or older commits. Secret scanning detects supported patterns, not every possible credential. Rotate exposed credentials even if a scan stops showing the value.
Practice
Run the disposable marker fixture and inspect its recorded results; do not search for real credentials. Explain the difference between invalidating a credential and removing bytes from a repository. Write a short incident checklist with revocation first, then scope, replacement, coordinated cleanup and verification.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Secrets and Incident Response: Revoke Before Cleanup — knowledge check
Reason about repository trust, security controls and incident response.
First priority after a real credential exposure?
Does a deletion commit remove older snapshots?
Why coordinate history rewriting?
What should incident logs contain?
What does a clean scan establish?