#2278·gitleaks

Rule request: detect Supabase `service_role` JWTs (distinct from safe `anon` keys)

Author: MohamedQiqaCreated Sep 19, 2026Updated Sep 19, 2026

Related issue

This overlaps with #2225 (opened July 2026, no replies yet). Our issue adds tested regexes and exact evidence that issue lacks.

Problem

Supabase issues two JWTs per project:

  • anon — public, safe to ship in a browser
  • service_role — full database access, must be secret

The stock jwt rule matches both. This means:

  • Users get a false alarm on the public anon key (noisy)
  • Or they disable the jwt rule entirely — and lose detection of the dangerous service_role key

We verified this by running the current regex against a real key of each type.

The fix

The JWT payload carries a role claim that separates them cleanly:

  • anon key payload: "role":"anon"
  • service_role key payload: "role":"service_role"

With --max-decode-depth already in Gitleaks, a rule matching "role":"service_role" works today without any new machinery.

Important caveat

Such a rule must not carry a keywords filter. The words service_role only exist after base64 decoding — a keyword pre-filter would stop the rule from ever running.

Evidence

  • Confirmed with real (revoked) keys of both types
  • anon key → should NOT match the new rule (false positive to avoid)
  • service_role key → should match (true positive)

We are preparing a PR with a Go rule file implementing this.