A key’s day

Part 5 recap · Coverage

Coverage: the short version

Catch each copy where it lands. Then make every copy useless.

Take the full lesson Part 6 recap: Logs and public assets

Where the copies were caught

Issued by the payment service two years ago, then 6 copies:

  1. Sam’s laptop, stopped before the commit
  2. Priya’s pull request
  3. An old commit in Git history
  4. #checkout-dev in Slack
  5. A Jenkins build log
  6. A Confluence runbook

The day, step by step

  1. Meet the plan · 8:30 AM Meet the plan.
  2. Deploy the scanners · 9:00 AM Two scanners: one hosted, one in the data center.
  3. Pre-commit hook · 9:40 AM The pre-commit hook stops the key on the laptop.
  4. CI check · 10:30 AM The CI check fails Priya’s pull request.
  5. Git history · 11:30 AM A full scan finds a key deleted two years ago.
  6. Slack · 1:15 PM A pasted key in Slack is flagged.
  7. Builds, docs, and tickets · 2:00 PM Two more copies, outside the code.
  8. Detect · 2:30 PM Six catches, one alert.
  9. Verify · 2:32 PM Is it still live?
  10. Analyze and notify · 2:45 PM The right owner gets the alert.
  11. Rotate · 3:30 PM Swap in a new key.
  12. Confirm · 3:45 PM Confirmed: the old key is dead.

How it ended

Swap in a new key. The six caught copies, and any copy nobody caught, stop working at once.

Confirmed: the old key is dead. Each layer caught a copy. Rotation made all of them useless, including the ones no layer saw.

Try it with TruffleHog open source

Install TruffleHog first; its README lists the options. Run these only on folders, images and buckets you’re allowed to scan.

  1. Laptop. Runs on each commit through Git hooks, the pre-commit framework, or Husky.

    trufflehog git file://. --since-commit HEAD --fail
  2. Pull request. Runs in GitHub Actions, GitLab CI, Jenkins, CircleCI, and other pipelines, and fails the build.

    trufflehog git file://. --since-commit main --branch HEAD --results=verified,unknown --fail
  3. History. Scans a repository or an organization’s full history when someone runs it, including some deleted and hidden GitHub commits.

    trufflehog github --org=acme-example

Keep going