Add detection rules for Supabase secret API keys and personal access tokens
Is your feature request related to a problem? Please describe.
There are no Supabase rules in the default config. grep -i supabase config/gitleaks.toml returns nothing.
Supabase issues two credential types that are worth covering:
- Secret API key (
sb_secret_...) — the current-generation replacement for the legacyservice_roleJWT. It bypasses Row Level Security, so it is effectively full read/write access to a project's database, storage and auth. Docs: https://supabase.com/docs/guides/api/api-keys - Personal access token (
sbp_...) — used by the Management API and thesupabaseCLI viaSUPABASE_ACCESS_TOKEN. It is account-scoped rather than project-scoped, so a leak exposes every project the owner can reach.
The legacy anon / service_role keys are JWTs and are already picked up by the jwt rule, but the new-format keys and the PAT are not matched by anything.
Describe the solution you'd like
Two rules, supabase-secret-key and supabase-personal-access-token, following the existing GenerateUniqueTokenRegex pattern. Both prefixes are well over 3 characters so no identifier is needed.
On formats, Supabase documents the prefixes but not the exact suffix shape, so I sampled real occurrences rather than guessing:
sb_secret_is followed by 22 base64url characters (16 random bytes) plus an 8 character checksum segment, 31 characters total counting the inner_. Example structure from Supabase's own local-dev output in https://github.com/orgs/supabase/discussions/29260:sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMXXX. Realsb_publishable_keys found via code search have the identical 22 +_+ 8 shape.sbp_is followed by 40 lowercase hex characters, and there is also a versioned form. Code search turns up bothsbp_<40 hex>andsbp_v0_<40 hex>in the wild.
Worth flagging: TruffleHog's detector uses \b(sbp_[a-z0-9]{40})\b, which cannot match the sbp_v0_ form at all, since _ is outside its character class. So a rule that only copies that pattern would miss real tokens.
Describe alternatives you've considered
Also adding sb_publishable_. I do not think it belongs in the default config. That key is designed to ship in client-side code, so flagging it would be a false positive by definition, in the same way pk_live_ is not treated as a Stripe leak.
Additional context
Happy to open the PR, I have the rules written and tested locally. Related: #2065 proposed sbp_[a-f0-9]{40} bundled with two unrelated providers and was closed without review.
Source: gitleaks/gitleaks