high · M3 · MASVS-AUTH-2 · PTKD-BACKEND-SUPABASE-OPEN-POLICY

    Supabase policy that lets every row through

    A Row Level Security policy uses `true` as its condition, so RLS is on but does nothing: every caller the policy covers can reach every row.

    How it is exploited

    To make an error go away, an AI assistant writes `create policy "allow all" on public.orders for all using (true) with check (true);`. RLS is technically on, so dashboards look green, but any visitor with the anon key can rewrite another customer's order or mark it paid.

    Why it matters

    Same as no RLS for the covered operations: other users' data can be read, changed or deleted.

    How to fix it

    1. List policies with `select * from pg_policies where schemaname = 'public';`.
    2. Rewrite each `true` condition to check ownership, for example `(select auth.uid()) = user_id`.
    3. Split `for all` into separate select / insert / update / delete policies so each gets the right condition.
    4. If a table is genuinely public (a product catalogue), allow SELECT only, never write.

    Does your app have this?

    PTKD checks your build or your source project for PTKD-BACKEND-SUPABASE-OPEN-POLICY and every other check in this knowledge base.

    Scan your app

    References

    Related checks (M3)