r/Supabase • • Oct 21 '26

tips Reminder: new tables will require explicit API grants from October 30

8 Upvotes

Starting October 30, newly created tables in the public schema on existing Supabase projects will need explicit GRANT statements to be accessible through the Data and GraphQL APIs, including via supabase-js.

Existing tables keep their current grants and will continue working. RLS behavior is unchanged, and direct Postgres connections aren’t affected.

If your migrations or AI tools create tables, make sure they include the appropriate grants alongside your RLS policies.

Full details and SQL examples


r/Supabase • • 4h ago

realtime Showcase: a live pixel canvas built only on Supabase (RLS, RPCs, Realtime, pg_cron batching)

Post image
1 Upvotes

Built a New Year pixel canvas where everyone paints together live. All logic lives in Supabase:

- Anonymous auth plus security-definer RPCs for every write, with RLS so clients can only read

- Per-IP rate limits from request headers, reserved usernames, chat slow mode

- To avoid pixels × viewers messages, a trigger records changed squares and a pg_cron job sends one realtime.send broadcast every 2 s (only when something changed)

- Presence for the online count, postgres_changes for chat and votes

check it out here: https://saharshbaiju.github.io/tandem/easteregg/


r/Supabase • • 11h ago

other Building my app in chat sent me back to Supabase 52 times before I finally moved the repo to Cursor 😂

Post image
0 Upvotes

r/Supabase • • 1d ago

database 3 Postgres migration patterns that silently lock production tables (and how to catch them in PRs)

1 Upvotes

We’ve all seen a migration pass staging in 50ms and then lock a production table for 20 seconds under real traffic. After reviewing dozens of incident post-mortems, almost all avoidable Postgres migration outages come down to three patterns: 1. Adding a NOT NULL column without a DEFAULT Running `ALTER TABLE users ADD COLUMN email text NOT NULL;` acquires an ACCESS EXCLUSIVE lock and rewrites/validates the table. On a busy table, every read and write queues up behind it. Fix: Add the column as nullable first, backfill in batches, then add a `NOT NULL` constraint using `NOT VALID` + `VALIDATE CONSTRAINT`. 2. Creating an index without CONCURRENTLY `CREATE INDEX idx_users_email ON users (email);` blocks all writes (`INSERT`, `UPDATE`, `DELETE`) on `users` until the index build finishes. Fix: Always use `CREATE INDEX CONCURRENTLY` (outside a transaction block). 3. Running ALTER TABLE without a lock_timeout Even a fast metadata-only `ALTER TABLE` needs an `ACCESS EXCLUSIVE` lock. If a long-running analytics query is holding a read lock on that table, your migration waits in the queue—and every subsequent query piles up behind your migration, causing a cascading outage. Fix: Always prepend `SET lock_timeout = '2s';` so the migration fails fast instead of taking down the app. To stop relying on human code review for this, I put together a lightweight static analyzer (`pgguard`) that parses SQL migrations in PRs and flags these exact lock risks before merge. Curious what other Postgres migration footguns you’ve hit in production that static checks should catch?


r/Supabase • • 1d ago

auth Supabase Sign in with Apple

Thumbnail reddit.com
1 Upvotes

r/Supabase • • 2d ago

other Wie viele User können auf meine App zugreifen, bevor ich für Supabase bezahlen muss?

0 Upvotes

r/Supabase • • 3d ago

tips Your Supabase backup has no uploaded files in it, only the list of them

Post image
0 Upvotes

You restore an old backup, the rows come back, and the photos and PDFs somebody deleted don't. The backup keeps only metadata about Storage files. On Free there are no automatic backups at all, and when you delete a project its backups go with it.

To get a bucket on your disk, after supabase login and supabase link:

supabase storage cp -r ss:///your-bucket ./files --experimental

Three slashes. One help page shows two, and on CLI 2.109.1 it then looks for an empty name and says Object not found.

Do it once and open a few files, then you know it works. Where do you keep your copy?


r/Supabase • • 4d ago

tips Quick way I audit Supabase RLS leaks using only HEAD + Prefer: count=exact

2 Upvotes

When I review Supabase projects built quickly with Lovable or Bolt, the most common leak is forgetting to enable RLS on a table or leaving a broad SELECT policy for anon.

Instead of pulling actual rows from someone's database during a quick check, you can send a HEAD request to /rest/v1/<table> with the public anon key and Prefer: count=exact. PostgREST returns the exposed row count inside the Content-Range header (for example */142) with an empty response body, so you immediately know whether unauthenticated reads are open without downloading user data.

I wrapped that check together with OpenAPI table discovery, rpc/ probing, and public storage bucket checks into a small open-source CLI (npx supabase-rls-check) and a browser checker. Attached is a sample audit output showing exposed tables and generated ALTER TABLE ... ENABLE ROW LEVEL SECURITY fixes.

Source is on GitHub if you want to run it locally in CI: https://github.com/Tthanh2k6/supabase-rls-check

Curious if anyone here also checks anything else automatically on anon before shipping, like auth.users views or SECURITY DEFINER RPCs?


r/Supabase • • 4d ago

auth Blocking disposable emails and Gmail alias farming in the Before-User-Created hook

1 Upvotes

Built a tiny API that blocks disposable emails and Gmail alias farming (j.o.h.n+7@gmail) right in Supabase's Before-User-Created hook. One call, 1,000 free checks a month, no card. Looking for 10 people running free tiers who'll try it and tell me what it misses. Snippet in comments.


r/Supabase • • 3d ago

tips My project is running out of Disk IO Budget

Post image
0 Upvotes

I created a Chrome extension that already has 289 users, 190 of them active weekly, with about 15k total requests per day (low numbers).

Apparently, the RAM is maxed out, and Supabase is asking me to upgrade to the next plan ($25 USD).

I don't want to, because the platform is small and I'm not monetizing it. I've tried many things, but nothing has worked.

Has anyone else had the same issue, or does anyone have any advice?

Platform is: Lexigo


r/Supabase • • 5d ago

database How to check whether anyone on the internet can read your Supabase tables

3 Upvotes

Edit: commenters caught several things. Check 1 shows grants, check 3 covers a second user and writes, there's a new check 4, and I removed a "most common" claim I couldn't support.

Edit 2: check 1 now shows each privilege separately, and there's a new check 5.

It's easy to ship a Supabase table that anyone can read. These are the checks I run. None of them needs an extra scanner.

1. Tables with row-level security off

select tablename,
       has_table_privilege('anon', t, 'select') as can_read,
       has_table_privilege('anon', t, 'insert') as can_insert,
       has_table_privilege('anon', t, 'update') as can_update,
       has_table_privilege('anon', t, 'delete') as can_delete
from (select tablename, format('%I.%I', schemaname, tablename) as t
      from pg_tables where schemaname = 'public' and not rowsecurity) x;

Any true is open to a signed-out visitor. On my local Supabase, new tables in public got these grants by default; the query shows what yours has. (The anon key is meant to be public. The missing protection is the problem.)

2. Policies that say true, and who they apply to

select tablename, policyname, roles, cmd, qual, with_check
from pg_policies where schemaname = 'public';

Postgres never reads a policy's name. A policy called "authenticated users can read" with no to authenticated shows {public}, which includes anon. A "service role" policy with no to is the same, and you can just delete it: the service role skips RLS. Adding and roles = '{public}' lists the policies that name no role, but look at ones written to anon too.

3. Test what actually happens

As a signed-out visitor:

begin;
set local role anon;
select count(*) from public.your_table;
rollback;

As a signed-in user (without the claims, auth.uid() is null and everything looks locked):

begin;
set local role authenticated;
select set_config('request.jwt.claims', '{"sub":"A-USER-UUID","role":"authenticated"}', true);
select count(*) from public.your_table;
rollback;

Writes have their own policies. Try an insert with otherwise valid values, and update and delete against someone else's rows, inside the same kind of transaction. A blocked update or delete just affects 0 rows. A count of 0 only means something if the table has rows.

4. Things that go around table RLS

Views run with their owner's rights unless you set security_invoker, and materialized views can't:

select c.relname, case c.relkind when 'm' then 'materialized view' else 'view' end
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('v', 'm')
  and coalesce(c.reloptions::text, '') not like '%security_invoker=true%';

security definer functions that anon can call through /rest/v1/rpc:

select p.oid::regprocedure
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef
  and has_function_privilege('anon', p.oid, 'execute');

To close one, revoke from public as well: revoke execute on function ... from public, anon, authenticated; then grant back only what should call it.

Storage: look at select * from pg_policies where schemaname = 'storage';, and note that public buckets serve files by URL whatever those policies say:

select id from storage.buckets where public;

5. Policies that trust what users can edit

Users can change their own user_metadata, so never decide roles from it. And an update policy that only checks row ownership lets a user change any column of their row, such as role. Limit the columns:

revoke update on public.profiles from authenticated;
grant update (name) on public.profiles to authenticated;

Not covered: your app code, backend routes that use the service role (they need their own checks), and anything changed in the dashboard but not in your migrations.

Disclosure: I'm building a free, open-source tool called Svetra that automates much of this (npx svetra check --migrations builds your migrations in a throwaway Docker database and lists what's open). It's early and I'm looking for people to try it. You don't need it for any of the above.


r/Supabase • • 5d ago

tips Supabase bugs that only show up when two users click at the same time (from testing a lot of AI-built apps)

1 Upvotes

I've spent the last few months testing AI-built Supabase apps for one kind of bug: the kind that passes every normal test and only breaks when two requests overlap. These are the ones I keep finding.

  1. The last seat gets sold twice. A booking demo checked "is there a seat left?" and then inserted the booking. With two guests at once, both passed the check. In 12 of 20 test orders, the last seat was booked twice. Fix: lock the row before the capacity check (select ... for update), or do the check and the write in one statement.
  2. A limit of 100 ends at 101. A workspace capped at 100 accounts counted the rows, then inserted. At 99, two creates both saw 99 and both got in. Fix: keep a counter column and take a slot with update ... set remaining = remaining - 1 where remaining > 0 returning ..., so only one request can win.
  3. Credits get spent twice. Read the balance in JS, subtract, write it back. Two requests read the same balance and both succeed. Fix: do it in one statement, update profiles set credits = credits - 1 where id = ... and credits > 0, and treat 0 updated rows as "not enough credits".
  4. Stripe webhooks arrive out of order. If your handler copies the subscription status from the event into a table, a late "active" event can overwrite a newer "canceled". In 6 of 7 public handlers I tried, the delivery order changed the final state. Fix: in a worker, re-fetch the subscription from Stripe and write that, one worker per subscription.
  5. Deduping by event ID isn't enough. A new event ID can still carry old state. Dedup protects you from retries, not from order.

How to test any of these: two connections, the same starting state, run the action at the same time, then check what was actually saved. Normal tests run one request at a time, so they stay green.

What would you add to the list?


r/Supabase • • 5d ago

database RLS is on for every table and it still leaks: 5 Supabase mistakes I keep seeing in AI-built apps

0 Upvotes

Been reading a lot of AI-generated Supabase schemas lately (Lovable, Bolt, Cursor projects) and "RLS is enabled on every table" keeps showing up as the security answer. It's a good start, but these are the holes I keep finding anyway.

1. Policies that are just true

The agent hits a 42501 error, "fixes" it with using (true), and now every signed-in user (or anon, depending on the role) can read every row. Quick audit:

select tablename, policyname, roles, cmd, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true');

Some of these are fine (public product lists). Anything with emails, orders or Stripe ids is not.

2. Tables added later with RLS off

RLS gets enabled in the first migration, then the agent adds three more tables a week later and forgets. This lists them:

select c.relname
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'r' and not c.relrowsecurity;

3. Views that skip RLS

Views run as their owner by default, so a view over a protected table can hand everything back. On Postgres 15+:

alter view public.my_view set (security_invoker = true);

4. Users can update their own row... including plan or is_admin

RLS is row level, not column level. "Users can update their own profile" also means they can set plan = 'pro' from the browser console. Either move those columns to a table users can't write, or limit the columns:

revoke update on public.profiles from authenticated;
grant update (display_name, avatar_url) on public.profiles to authenticated;

5. security definer functions callable by anon

They bypass RLS, and the agent often writes them that way to make an error go away. If it doesn't need to be public:

revoke execute on function public.my_fn(uuid) from public, anon;

How I test it: two real accounts, then in the SQL editor run as user B and try to read user A's data:

begin;
set local role authenticated;
select set_config('request.jwt.claims', '{"sub":"<user-b-uuid>","role":"authenticated"}', true);
select * from public.orders;
rollback;

If you see A's rows, the policy is wrong.

What else do you check before letting real users into a Supabase app? Curious what I'm missing.


r/Supabase • • 5d ago

database Title: I scanned 3,035 public repos from AI app builders. Here's what keeps showing up in their Supabase setup

0 Upvotes
Disclosure: I make and sell LeakWarden, the scanner I used. These checks are in the paid version.

I scanned 3,035 public GitHub repos made with Lovable, Bolt, v0, Replit, Base44 and Google AI Studio. In the projects that use Supabase:

- Where the SQL is in the repo, a table with RLS off or a write policy with using (true). A third of the Bolt projects had one, and half of the v0 and Base44 ones.
- The service role key in the repo or in browser code. From 3.5% of the Lovable Supabase projects to 15.6% of the Google AI Studio ones (Replit: 4 of 23, too few for a share).

Three checks you can do yourself in a few minutes:

1. Run the Security Advisor in the Supabase dashboard. It catches tables with RLS off.
2. Sign in as two different users and try to read and change each other's rows. If it works, the policy is open even though RLS is "on".
3. For views, run select has_table_privilege('anon', 'public.your_view', 'select'). Views run with their owner's rights by default, so a view over auth.users can hand out every email.

Full numbers and method: https://leakwarden.dev/research/app-builders-3035

r/Supabase • • 6d ago

tips Help

0 Upvotes

Can anyone refer me for supabase squad ??


r/Supabase • • 6d ago

Self-hosting Announcing Supermixer: Management plane for self-hosted Supabase

Thumbnail supermixer.app
0 Upvotes

What is Supermixer?

Supermixer is an open-source dashboard for running and managing multiple self-hosted Supabase projects on your own servers: https://supermixer.app

Self-hosting one Supabase instance is fine. Self-hosting five Supabase instances on your own servers starts to hurt. Each instance has its own Studio, its own `.env` file, and its own ports, and every backup and password change has to be done by hand. There's also no good way to give a teammate access to one project without handing them the keys to everything.

Supermixer, a management plane for self-hosted Supabase, is built to help with this. It runs on your own infrastructure, next to your stacks and gives you a single pane of glass to manage all of them.

What does Supermixer do?

- Run as many as Supabase projects as your hardware can hold. Since you self-host it, there are no plans or project limits.

- Connect Supabase stacks you already run, or create a new one in one click. Supermixer sets up Docker, ports, keys and TLS for you.

- A Studio-style dashboard for every project. SQL editor, table editor, schema visualizer, Auth users, Storage, Edge Functions, a Realtime inspector, logs and advisors. If you prefer, you can use the project's built-in Studio too.

- Supermixer is enterprise ready. Teams, Organizations, invitations, and roles are available. GitHub sign-in and two-factor are built in.

- Hosting on a public URL? TLS through Let's Encrypt for both the dashboard and each stack's API and Postgres ports.

- Audit logs and webhooks.

- Automating Supermixer is easy. Personal Access Tokens and a Supabase-style Management API is available, therefore existing scripts can keep working.

Why "management plane"?

Supermixer doesn't replace Supabase or fork it. Your stacks stay stock upstream Supabase, running on your own machines. Supermixer sits on top at the management layer, keeps track of your instances, and gives your team one login to manage all of them. Your Supabase stacks keep running, even if you stop using Supermixer.

Links

- GitHub: https://github.com/supermixerapp/supermixer

- Demo site: https://supermixer.app

Supermixer is Apache 2.0 licensed, with no telemetry and no paid tier. If you are a developer and use Supabase locally, I'd like to hear your thoughts if this is useful.


r/Supabase • • 6d ago

cli I built an open-source, zero-dependency Supabase security scanner + AI agent skill bundle (128 patterns, 76 static checks, SARIF CI)

2 Upvotes

Most Supabase security tools either charge a subscription or only scan your live URL after you've already deployed a leak.

I built Supalock — local-first, MIT-licensed, zero pip dependencies — to catch RLS, Storage, Auth, Edge Function, and secret leaks directly in your repo, CI, and coding agent before code ever ships:

https://github.com/hermes-lekkas/supalock

What's included:

  • 128 curated patterns across 10 surfaces (RLS, Postgres views/functions, Storage buckets, Auth/SSR, Edge Functions, Secrets, Realtime/RPC, Vibe-coded business logic, Next.js, and supabase/config.toml)
  • 76 static CLI checks that track RLS across multiple migration files, decode JWT payloads to tell anon apart from service_role, ignore TO service_role policies, and output Terminal / JSON / Markdown / SARIF 2.1.0
  • 8 Open Agent Skills (npx skills add Hermes-Lekkas/supalock) + ./install.sh for Claude Code, Cursor, Codex, Antigravity, Gemini CLI, Copilot, Cline, and Windsurf
  • Before/after demo apps (examples/vulnerable-vibe-saas -> 46 findings in 14 ms vs examples/hardened-vibe-saas -> 0 findings in 10 ms)

Try supalock explain SUPA-RLS-009 or run it on your own repo — would love feedback on any patterns I missed!


r/Supabase • • 7d ago

database supabase-rls-check v0.7.0: catching column-level UPDATE privilege escalation (role/credits/plan), non-invoker views, and leaked keys in build bundles

3 Upvotes

Disclosure: I am the author of supabase-rls-check (MIT licensed, free and open-source Python CLI / MCP server / GitHub Action).

just pushed supabase-rls-check v0.7.0 (159 unit & integration tests passing). it adds three checks aimed at bugs that keep showing up in AI-generated Supabase schemas (Lovable, Bolt, Cursor, v0):

repo: https://github.com/Tthanh2k6/supabase-rls-check pypi: https://pypi.org/project/supabase-rls-check/

  1. column_update_escalation (High): a lot of apps enable RLS on public.profiles or public.users with a standard ownership policy: FOR UPDATE TO authenticated USING ((select auth.uid()) = user_id) and also store role, is_admin, plan, tier, credits, balance, subscription_status, or org_id on that same table. because USING only filters which row you can update, and table-level UPDATE is granted to authenticated by default, any signed-in user can send PATCH /rest/v1/profiles with {"is_admin": true, "credits": 99999} and self-elevate. check.sql (for live catalog exports) and scan_sql (for local .sql migration files) now check whether anon or authenticated holds UPDATE on those columns without a WITH CHECK guard or a column-level REVOKE UPDATE + GRANT UPDATE (safe_col1, safe_col2).
  2. view_not_invoker on raw .sql migrations: views in Postgres default to security_invoker = false, running with the view owner's permissions and bypassing base-table RLS when exposed in public. check.sql already flagged these in pg_class.reloptions, and v0.7.0 adds static detection in scan_sql so you can catch CREATE VIEW public.x missing WITH (security_invoker = true) or ALTER VIEW ... SET (security_invoker = true) in local migration files before pushing.
  3. supabase-rls-check scan-bundle <path> (CLI + local MCP tool): scan-env intentionally skips dist/, build/, and web-build/ when scanning a source repo. the new scan-bundle command scans compiled frontend folders or single .js/.html bundles (offline, read-only, up to 5 MB per file) for base64-decoded service_role JWTs (ignoring anon tokens), sb_secret_ keys, and postgres://user:pass@ URLs, masking every secret as first6…last4.

you can inspect the remediation pattern locally with: uvx supabase-rls-check explain column_update_escalation

if there are other column names or RLS anti-patterns you see frequently in vibe-coded repos, let me know and i will add them to the heuristics.


r/Supabase • • 8d ago

tips How I self-host Supabase on a cheap VPS with HTTPS and scheduled backups

4 Upvotes

Disclosure up front: I built the tool this setup uses (ShipperKit, open source and MIT licensed). Mods, remove this if it doesn't fit here.

Getting Supabase running is the easy part. Keeping it running is where I kept losing evenings: the self-hosted Compose stack is a dozen containers, and you have to generate the JWT secret and API keys yourself. This is the setup I use now on a single VPS.

What you need

  • A server running Ubuntu 22.04/24.04 or Debian 12/13, x86-64 or ARM64
  • 4 GB of RAM to be comfortable
  • Ports 80, 443 and 8080 open
  • A domain with an A record pointing at the server, like supabase.yourdomain.com

1. Install ShipperKit

curl -fsSL https://shipperkit.dev/install.sh | sudo bash

Open the address it prints, paste the setup token and create your account.

2. Deploy Supabase

Open the Service Library, search for Supabase and select it. Enter supabase.yourdomain.com as the domain and deploy. The secrets and database passwords are generated for you, and HTTPS comes from Let's Encrypt automatically.

3. Set up backups before you put real data in

Add a backup schedule for the Postgres database and the storage volume. You can store backups on the server itself or in any S3-compatible bucket (Backblaze B2, Cloudflare R2, Wasabi). Restore one as a separate copy once, so you know the restore actually works before you need it.

Supabase-specific things to watch for

  • Plan for 4 GB of RAM.
  • Studio is exposed on your domain, so lock it down.

Repo: https://github.com/matyas-toth/shipperkit Site: https://shipperkit.dev

Happy to answer questions about running Supabase on it, or about self-hosting Supabase in general.


r/Supabase • • 7d ago

tips Added a tenant filter to a service key update. Uploads kept saying success and saved nothing

1 Upvotes

Everybody's talking about the service key skipping RLS this week, and i think the server side gets less attention than it should. Most posts stop at keeping it out of the browser.

On a project of mine an upload ran an update with the service key and no tenant filter, so it could write to another company's row. The fix was one more .eq on the company id. But nobody checked the result, and an update that matches 0 rows isn't an error in supabase-js. error is null, data is empty. So when the ids didn't line up, the user saw "upload succeeded" and the document still pointed at the old file.

What i do now - every service key update that gets a filter also gets .select() and fails when it comes back empty.

Do you check row counts on server side updates, or trust error == null?


r/Supabase • • 9d ago

auth What's the ideal foreign key to use for users in a multi tenant app

5 Upvotes

In a multi-tenant app, you need 4 tables in my opinion to handle all app features correctly:

  1. the default supabase users table
  2. a profiles table that holds extra information about each user like their profile picture, bio and anything about users that needs to be shared between organizations, supabase itself actually recommends using this table. this table should have a one-to-one relationship with the users table.
  3. an organizations table.
  4. a members table that will link the different user profiles with their respective organization. this serves as the pivot table between organizations and profiles.

Now for tables that hold rows that should belong to specific members of specific organizations, I always include a organization_id foreign key to make filtering by an organization easier. even though I could have a member_id foreign key with which I can do a nested join to filter by that member's organization, but having an organization_id directly on the table makes things easier and is a well known practice.

My question: Now that we've established that I should add an organization_id to (nearly) every table. which of the 3 user tables should I use to define who owns a particular table row? user_id, profile_id or member_id.

I could see the argument for either profile_id or member_id honestly, with member_id its makes more semantic sense because it tells us not only which user did the action but which user on which organization.

On the other hand we can figure out the relation pretty easily with the organization_id column we have on every table and using profile_id makes accessing things like user avatars cost one less join.


r/Supabase • • 9d ago

tips I built a deliberately insecure Supabase app and ran an outside check on it. Here's what showed up and how to fix each one

1 Upvotes

I run a small security consultancy, and I wanted a realistic demo, so I built a fake estate-agency CRM on hosted Supabase (plus a bit of Firebase) with common mistakes planted on purpose. All data is fake. Then I ran a read-only, outside-in check against it, the same view anyone with a browser gets.

The Supabase-side findings:

  1. RLS off on a table (contacts: names, emails, phones). Readable by anyone with the anon key, which is in every Supabase front end by design. Fix: alter table ... enable row level security; on every table in public, then add the policies you need.
  2. RLS on, but using (true) for authenticated. Signed in as one test user, I could read every user's deals. Fix: using ((select auth.uid()) = owner_id), and test with two accounts.
  3. service_role key in the JS bundle. That key bypasses RLS entirely. Fix: only the anon/publishable key in the browser; server-only code for the rest; rotate any key that was ever shipped.
  4. Public storage bucket with a list policy for anon. Every file listable and downloadable. Fix: private bucket + signed URLs; no anon select on storage.objects.

What it correctly left alone: a table with an owner-only policy and a private bucket.

Quick self-check for your own project:

  • Database → Advisors (Security Advisor) shows no "RLS disabled" warnings
  • No using (true) on tables with user data
  • Search your live site's JS for service_role and sk-
  • No secrets behind NEXT_PUBLIC_ / VITE_ / EXPO_PUBLIC_

Full write-up with the Firebase findings and a sample report: https://hasafsec.com/insights/insecure-ai-built-app-seven-flaws?utm_source=reddit&utm_medium=social&utm_campaign=p1

Happy to answer RLS or policy questions in the comments.


r/Supabase • • 9d ago

database If you "fixed" infinite recursion on team_members with using (true), your member list is public. Here's the fix the docs use

0 Upvotes

Disclosure: I build a security scanner for AI-built apps. No link, just SQL.

I keep seeing the same thing in team / workspace apps. A policy on team_members needs to check team_members ("can I see other members of my team?"), Postgres throws 42P17 infinite recursion detected in policy for relation "team_members", and the fix that makes the error go away is using (true). Now every signed-in user can list who's in every team, and so can anyone with the anon key if the policy didn't say to authenticated.

The pattern in the Supabase RLS docs is a security definer function that does the membership lookup as its owner, so the policy doesn't call itself:

create schema if not exists private;

create function private.my_team_ids()
returns setof uuid
language sql
security definer
set search_path = ''
stable
as $$
  select team_id from public.team_members
  where user_id = (select auth.uid())
$$;

create policy "see members of my teams"
on public.team_members for select
to authenticated
using (team_id in (select private.my_team_ids()));

Two things that matter:

  • Put it in a schema that isn't in your API's exposed schemas. A security definer function in public can be called by anyone at /rest/v1/rpc.
  • It only skips RLS because the owner is postgres. If you created it as some other role, it'll recurse again.

While you're in there, check the insert policy on team_members:

select policyname, cmd, with_check
from pg_policies
where tablename = 'team_members' and cmd in ('INSERT', 'ALL');

If with_check is just auth.uid() = user_id, it checks the row is you but not which team you're joining. Any signed-in user can insert themselves into another team's id and every "member of this team" policy lets them in. Safer is no client inserts at all (add members server-side after checking the invite) or only allowing inserts when the caller is already an owner of that team, using the same kind of function.

Quick test is two accounts. Make a team as A, sign up as B, try inserting B into A's team from the browser console. Delete the row after.

Curious how others handle invites here. Edge function, or a policy that checks an invites table?


r/Supabase • • 10d ago

database PostgreSQL persistent task queue: concurrency, idempotency and restart recovery

Thumbnail reddit.com
1 Upvotes

For those using Supabase, would you recommend Supabase Queues (pgmq) or a dedicated PostgreSQL queue table for this use case? I'm particularly interested in concurrency, stale worker protection and reliable restart recovery.