Investigation & Containment

Investigation

A leaked secret is a question of trust, not of files: who could have read it, and what could they do with it. Every minute the value stays valid, every copy of it works - so the investigation revokes it before it looks for copies.

  1. Record what leaked, and since when. Which value, where it is issued - the provider’s dashboard, the cloud console, the database - and what it can reach: a live payment key that may create charges is a different incident from a read-only test token. And the push time, not the merge time: 16:24. The pull request timeline shows the force-push and links to the old commit. A private repository narrows who could read it; a public one does not - assume everyone could.

  2. Revoke it at the source - now. Before the rest of the investigation and before anything in Git. Once the provider refuses the old value, every copy is worthless, wherever it is.

  3. Where else was it copied? The Git hosting (the old commit stays reachable by its SHA), every clone and fork made since the push, CI logs, chat messages and tickets that quoted the diff. The platform’s own checks print file and key names - NOT ENCRYPTED: <file>, PLAINTEXT VALUE: <file> - not encrypted: API_KEY - never the values, so the CI log of this run is not a copy.

  4. Was it used? The provider’s API log or audit trail, from the push time until the moment it was revoked in step 2. A call from an address you do not know is now a second incident.

The answer to “can we delete all the copies?” is no: you cannot reach the clones and forks of strangers. That is why step 2 came first.

Containment

  1. Issue a new value at its source - the old one is already revoked (step 2 above).
  2. Put the new value through the encrypted path. Boris did not need the platform key for that: encrypting needs only the public key in .sops.yaml, and the helper does it for him - scripts/sops-encrypt-secret.sh staging payments-api. Only reading or editing an encrypted file needs the private key.
  3. Verify the delivery. After the merge, the secrets-staging Kustomization reconciles READY True, the Secret exists, and the backend - restarted, because a changed Secret does not restart pods - talks to the provider with the new key.
  4. Clean up Git, second. Ask the Git hosting to drop cached views of the old commit if you want to, and record the incident: what leaked, from when to when, what was revoked, whether it was used. This step reduces noise; the revocation is what made the copies harmless.

Rotate first, clean up second. A secret that was ever pushed in plaintext is burned, whatever happens to the commit.

When the Key Itself Leaks

The incident above leaked one value. The worse case is the private age key: whoever has it can open every value ever encrypted for it - in every commit, of every branch, forever, because the encrypted files are public. That happened to this platform in September 2026, when the key was inside a saved Terraform plan that CI published as a build artifact (Chapter 02, Sensitive Is Not Secret).

The response is the same rule, at a larger scale: a new age key, every file re-encrypted for it - and every value the old key protected replaced at its source, because the old key still opens the old commits. Workflow shows the rotation; the lab runs it on your cluster.


Pause and Predict: Boris’s commit passed his editor, his git commit, his git push and CI. Which of these four steps could have stopped the key before anyone else could read it - and what would make that step hard to skip?