Part 1 recap · Code
Code: the short version
Finding a key starts the work. Confirming it’s dead finishes it.
Take the full lesson Part 2 recap: People
Where the copies are
Issued by Stripe, kept in the vault, then 12 copies:
- Clipboard
- Laptop file
- Terminal history
- Settings file
- Commit on the laptop
- Git history on the code server
- Teammate laptop 1
- Teammate laptop 2
- Teammate laptop 3
- Main branch
- Build log
- Preview image
Plus any copies from the side stories: a doc, a chat, an AI chat, a ticket, and an incident channel. Code scanners can’t see these unless they’re connected.
The day, step by step
- Mission · 8:45 AM A developer gets a mission.
- Secrets Secrets let software prove who it is.
- SDLC Every change goes around a loop.
- Laptop · 9:20 AM Copied to a laptop.
- Terminal · 9:35 AM Pasted in to test it quickly.
- Editor · 10:10 AM Hardcoded to save time.
- Commit and push · 10:50 AM Two checks, both switched off.
- Shared and approved · 11:30 AM Shared with the team, approved in review.
- Git history · 2:05 PM Deleted, but still working.
- Pipeline · 2:12 PM The build copies it again.
- Detect · 4:40 PM TruffleHog finds the copies.
- Verify · 4:45 PM Is it still live?
- Analyze · 4:55 PM What can it reach?
- Notify · 5:10 PM The right owner gets the alert.
- Rotate · 6:05 PM Swap in a new key.
- Confirm · 6:20 PM Confirmed: the old key is dead.
How it ended
Swap in a new key. Every step before this found the problem. This step removes it.
Confirmed: the old key is dead. The leftover copies are harmless now, because their key is off.
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.
-
Laptop. Can scan files and folders on the laptop when someone runs it.
trufflehog filesystem ./billing -
On the laptop: the pre-commit hook. Runs as a pre-commit hook through native Git hooks, the pre-commit framework, or Husky.
trufflehog git file://. --since-commit HEAD --results=verified,unknown --fail --trust-local-git-config -
On the code server: the push check. Runs as a pre-receive hook on self-hosted code servers that allow server hooks, such as GitHub Enterprise Server and GitLab Self-Managed.
trufflehog git file://. --bare --results=verified --fail -
On the pull request: the CI check. The official GitHub Action scans the commits in the push or the pull request range and fails the job when a key is found.
trufflehog git file://. --since-commit main --branch HEAD --results=verified,unknown --fail -
Git history. Scans every commit still reachable from a branch or tag, including commit messages, so a deleted line is still found.
trufflehog git file://. -
Pipeline. Two different jobs. In the pipeline, open source checks the change and can fail the build, with a ready-made GitHub Action, a documented GitLab CI job, or one command in any other CI tool.
trufflehog docker --image example/billing:preview -
Analyze. Shows detailed permissions for about 20 of the most commonly leaked key types.
trufflehog analyze
Keep going
- Try TruffleHog open source Scan a repository or a folder on your laptop.
- See TruffleHog Enterprise Continuous scanning, routing to owners, and re-checks.
- Talk to the team Ask how this would work in your environment.