How to fix: Supabase service_role JWT in source
The service_role JWT bypasses Row Level Security. Should NEVER be in client code.
Why it matters
The Supabase service_role key bypasses all Row Level Security (RLS) policies, giving anyone who has it unrestricted read and write access to every row in every table in your database, equivalent to handing over your database root password.
The service_role JWT bypasses Row Level Security. Should NEVER be in client code.
How to fix it
- 1Immediately remove the service_role key from any client-accessible code
- 2Use the anon key + RLS policies in client code
- 3If exposed, rotate the service_role key in Supabase Dashboard → Settings → API
Code examples
Correct: anon key in client, service_role server-only
// Client component: use the anon key with RLS
import { createClient } from '@supabase/supabase-js';
export const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY! // public, safe with RLS
);
// Server-only admin client (API routes, server actions only)
// import { createClient } from '@supabase/supabase-js';
// const adminClient = createClient(
// process.env.NEXT_PUBLIC_SUPABASE_URL!,
// process.env.SUPABASE_SERVICE_ROLE_KEY! // NEVER NEXT_PUBLIC_*
// );References
Detected automatically by VulnRadar. The check id is secret-supabase-service-role, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is Supabase service_role JWT in source?
- VulnRadar rates this critical severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id secret-supabase-service-role, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Supabase service_role JWT in source map to?
- It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.