001 — A Kubernetes JWT in a public repo
What happened
GitGuardian flagged one of my public repositories and told me it had found a leaked credential — a Kubernetes service account token, a JWT, committed alongside a manifest or script. Nothing dramatic to look at: just a long string in a file I had pushed to publish my homelab work. But that string is exactly the kind of thing automated scanners crawl GitHub for, and in the worst case it represents a valid identity inside my cluster.
Diagnosis
First step: figure out whether the token was actually valid, not just expired. I decoded the JWT, checked the issuer and the bound service account, and reviewed what RBAC rights that account had in the cluster. The uncomfortable part wasn't that the token existed — it was realizing how easy it is to accidentally ship it when manifests, kubeconfigs and shell scripts live side by side in the same repo.
Fix
- Revoked and rotated the affected credentials and service account tokens.
- Removed the secret from the repository history with
git-filter-repo— deleting the file alone leaves the token recoverable in old commits. - Added
.gitignorerules for kubeconfigs, tokens, CA certificates and other credential-bearing files. - Enabled secret scanning on my repos so the next slip gets caught at commit time instead of by an external bot.
- Moved collection jobs to a dedicated ServiceAccount with narrow RBAC in a monitoring namespace — future tokens, even if leaked, have minimal blast radius.
What I learned
The lesson wasn't "never publish your cluster configs" — sharing the homelab is the point of the portfolio. The lesson is that publishing requires a deliberate boundary: history rewriting as a routine skill, ignore rules as muscle memory, and least-privilege service accounts so that a mistake is cheap instead of catastrophic. The scan alert cost me an evening; a live token in the wild would have cost much more.