high · M3 · MASVS-AUTH-2 · PTKD-BACKEND-SUPABASE-RLS-BYPASS
Supabase view or function that bypasses Row Level Security
A view in the public schema runs with its owner's rights (no security_invoker), or a SECURITY DEFINER function is callable by anyone. Either one reads tables as the database owner, skipping every RLS policy you wrote.
How it is exploited
RLS protects public.orders, but a convenience view public.order_summary was created for the dashboard. Views run as their owner by default, so GET /rest/v1/order_summary returns every customer's orders to an anonymous caller.
Why it matters
RLS is silently skipped for everything reachable through the view or function.
How to fix it
- Recreate views with `with (security_invoker = true)` (Postgres 15+).
- For each SECURITY DEFINER function: `revoke execute on function public.f from public, anon;` and grant only to the roles that need it.
- Add `set search_path = ''` and fully qualify table names inside the function.
- Check Supabase's Security Advisor lints `security_definer_view` and `function_search_path_mutable`.
migration
create or replace view public.order_summary with (security_invoker = true) as
select id, total, user_id from public.orders;
revoke execute on function public.admin_stats() from public, anon;Does your app have this?
PTKD checks your build or your source project for PTKD-BACKEND-SUPABASE-RLS-BYPASS and every other check in this knowledge base.
Scan your appReferences
Related checks (M3)
- Permissive CORS with credentials
- State-changing request succeeded without authentication
- Weak JWT observed on the wire
- Biometric authentication not bound to a cryptographic key
- Premium access is stored on the phone and trusted (heuristic)
- Firebase rules trust an email address nobody verified
- Firebase security rules open to everyone
- Users can make themselves admin or premium in Firestore