Git, CI/CD & GitOpsXCIV · Incident: Secret LeakIncidentResponse
Prevent recurrence — the controls that should have caught it
What you'll learn
- Identify the five layers of secret-leak prevention: pre-commit hook, server-side scanner, CI scan job, branch protection, and secret manager adoption
- Choose the right layer for each leak path: developer laptop, pull request, default branch, production consumer
- Run a post-incident review that produces concrete policy changes with owners and dates
- Distinguish the controls that prevent the next leak from the controls that detect the next leak
Prerequisites
Verified against Git 2.55.x teaching target; 2.40+ minimum · GitHub Actions continuous service; Aug 2026 documentation baseline · Argo CD v3.5.x teaching target; v3.0+ minimum · Flux v2.9.x · Sigstore Cosign v3.1.x · SLSA v1.2 · OCI Distribution Specification v1.1 · Git LFS v3.7.1 · Kubernetes (cross-course target) 1.36.x
The prevention controls are the changes that close the door the leak walked through. The controls are layered because no single control catches every leak path: a pre-commit hook catches the secret before it leaves the workstation, a server-side scanner catches it before it reaches the default branch, a CI scan job catches it before it merges, branch protection prevents direct pushes, and secret manager adoption removes the credential from the repository entirely.
The five layers of prevention
The five layers are stacked from the developer workstation outward to the production consumer. A leak that escapes one layer should be caught by the next:
flowchart LR
A["developer workstation"] --> B["pre-commit hook"]
B --> C["git push"]
C --> D["server-side scanner"]
D --> E["CI scan job"]
E --> F["branch protection"]
F --> G["secret manager adoption"]
G --> H["production consumer"]
A -. "secret committed" .-> X["leak"]
B -. "block" .-> X
D -. "block" .-> X
E -. "block" .-> X
F -. "block" .-> X
G -. "remove credential" .-> X
- Pre-commit hook. Runs on the workstation before
git commit. Runs a scanner against the staged changes and refuses the commit on a match. - Server-side scanner. Runs on the git host when a push is received. Inspects every commit and blocks the push or opens an alert.
- CI scan job. Runs in the pipeline on every pull request. Fails the build on a match.
- Branch protection. Requires a pull request, a successful CI, and a code review before merge.
- Secret manager adoption. Replaces the credential with a reference to a secret stored in Vault or AWS Secrets Manager.
Choosing the layer for each leak path
- Developer laptop. Pre-commit hook.
- Pull request. CI scan job.
- Default branch. Server-side scanner.
- Production consumer. Secret manager adoption.
The post-incident review
The review turns the response into a permanent change. Four outputs:
- The timeline finalised. Appended to the incident record.
- The leak path identified. The exact sequence is reconstructed.
- The control gaps listed. Each gap has an owner and a target date.
- The policy changes committed. Recorded as a new commit in the policy repository.
Production discipline
- The prevention controls run on the workstation, the detection controls run on the host. Both are required.
- Every control gap has an owner and a target date. A review without owners is a confession, not a change.
- The credential is removed, not redacted. The remediation is secret manager adoption, not a more aggressive scanner.
Cross-course references
- Linux for Production Sysadmins - Part XXXIV (KeyMgmt) covers secret manager adoption.
- Ansible for Production Sysadmins - Part XXXVIII (IncidentRunbooks) covers review patterns.
- Terraform for Production Sysadmins - Part XV (CredentialRotation) covers rotation patterns.
Quiz
Knowledge check · 4 questions
Q1. A team adds a server-side secret scanner to their git host after a confirmed leak. The team has no pre-commit hook, no CI scan job, and no branch protection. What is the failure mode of this configuration?
Q2. A post-incident review that lists the control gaps without naming owners and target dates is not sufficient to close the gaps.
Q3. Name the five layers of secret-leak prevention and the leak path each one addresses.
Q4. A confirmed leak has been resolved through disable, rotation, and history rewrite. Run the post-incident review and identify the control gaps that must be closed.
The leak was an AWS access key committed by a developer who copied the key from a CI log into a local `.env` file and then committed the file. The repository has no pre-commit hook, no CI scan job, no branch protection, and no secret manager. The git host's server-side scanner is enabled but did not catch the leak because the commit was pushed to a fork.
Passing score: 75%. Answers are checked in this browser.