#2225·gitleaks

Add detection rules for Supabase secret API keys and personal access tokens

Author: Yusuf-GadelrabCreated Jul 31, 2026Updated Sep 19, 2026

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:

  1. Secret API key (sb_secret_...) — the current-generation replacement for the legacy service_role JWT. 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
  2. Personal access token (sbp_...) — used by the Management API and the supabase CLI via SUPABASE_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. Real sb_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 both sbp_<40 hex> and sbp_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.