Rules

Supabase RLS policy with USING (true) lets anyone write

SR-SUPA-002 · Medium

A Row Level Security policy only protects a table if its condition checks who is asking. A policy for insert, update, delete or all with using (true) or with check (true) passes for every request, so anyone holding the anon key can write or remove rows through the Data API. Read policies with true can be fine for public data, which is why ShipReady skips for select. The fix is to scope each write policy to the signed-in user, usually by comparing (select auth.uid()) to the row's owner column, and to limit it to the authenticated role.

The fix

Before · supabase/migrations/0002_posts.sql
create policy "Anyone can update posts"
on public.posts for update
using (true);
After · supabase/migrations/0002_posts.sql
create policy "Authors can update their own posts"
on public.posts for update
to authenticated
using ((select auth.uid()) = author_id)
with check ((select auth.uid()) = author_id);

How ShipReady finds it

ShipReady reads the create policy statements in your .sql files and reports each one that uses using (true) or with check (true) and is not limited to for select. Findings carry rule ID SR-SUPA-002.

Run the check

Terminal
npx @shipmate-agency/shipready check .
GitHub Action
# .github/workflows/shipready.yml
name: ShipReady
on: [push, pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  shipready:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: deeflect/shipready@v0.2.0

Want a person to check every area and send the fixes as pull requests? Launch Lockdown, $950 once.