Supabase API Key Vulnerability Demonstrated

A developer created a browser extension to demonstrate how easily Supabase API keys can be exposed on the client-side if not properly secured. The demo serves as a critical reminder for full-stack developers to implement robust backend security, particularly Row-Level Security, in their projects.

The demonstrated vulnerability hinges on Supabase's two primary API keys: `anon` and `service_role`. The `anon` key is intentionally public and designed for client-side use, but it is only safe when Row-Level Security (RLS) is enabled and correctly configured on all tables. The `service_role` key, however, is a secret that bypasses all RLS policies, granting full database access. Exposing this key on the client-side is a critical mistake, equivalent to sharing the master password to your database. Tools like the "SupaExplorer" browser extension are designed to scan websites and their network requests to find these exposed keys and insecure endpoints. Row-Level Security is a PostgreSQL feature that Supabase utilizes to control data access on a per-row basis. Developers must write SQL policies that define which users can read, write, or delete specific rows. For example, a policy can state that a user can only select rows where the `user_id` column matches their own authenticated ID. Without RLS, anyone with the public `anon` key can potentially read all data from any table. Forgetting to enable RLS on a new table is a common and critical oversight. Supabase provides a SQL editor and user impersonation tools to help developers thoroughly test their policies before going to production. The developer, Burak Eregar, created the extension not to exploit but to educate on a common misconfiguration. Security research has shown that thousands of Supabase instances have been misconfigured, leaving entire databases exposed. This is often due to developers moving from a prototype stage, where RLS might be skipped, to production without implementing these crucial security rules. Supabase's official documentation and numerous security guides emphasize that RLS is not optional for production applications. They even provide an option to automatically enable RLS on all new tables to create a "secure by default" posture. For sensitive operations, the recommended practice is to use server-side logic in "Edge Functions" with the `service_role` key, which is never exposed to the client.

Get your own daily briefing

Scout delivers personalized news, insights, and conversations tailored to your role and industry.

Download on the App Store

Shared from Scout - Be the smartest in the room.