Supabase Realtime channels are public by default: 6 checks before you ship live features
Supabase Realtime makes live chat, presence and notifications easy to build with an AI tool. It also makes it easy to ship a channel that any signed-in user, or any visitor, can listen to. If your app broadcasts private
Supabase Realtime makes live chat, presence and notifications easy to build with an AI tool. It also makes it easy to ship a channel that any signed-in user, or any visitor, can listen to. If your app broadcasts private data over a channel, check this before launch.
The problem
By default a Realtime channel is public. Anyone who has your project URL and anon key, both of which ship in your front-end code, can try to join a channel by name. If you broadcast "room-123" messages or presence for a private conversation, a guessed or leaked topic name is enough.
The fix, from the Supabase docs
Supabase documents Realtime Authorization for Broadcast and Presence. You control access with Row Level Security policies on the realtime.messages table, and the client opts in with private: true. To enforce private channels you also need to turn off the "Allow public access" setting in Realtime Settings. Sources are at the end.
The 6 checks
- Open Realtime Settings and check "Allow public access". If it is on, private channel rules are not enforced.
-
Create policies on
realtime.messages. Without a policy, a private channel has no one allowed in. Write one for receiving and one for sending. -
Tie the policy to the topic and the user. Use
realtime.topic()and the JWT claims so a user can only join their own rooms, not any room name. -
Join with
private: truein your client code. Check everysupabase.channel(...)call, not just the first one the AI wrote. - Do not put secrets or personal data in broadcast payloads for channels that are public. Treat topic names as guessable.
- Test with a second account. Sign in as a different user, try to join the first user's topic, and confirm you get nothing.
create policy "members can read their room"
on "realtime"."messages"
for select
to authenticated
using (
(select realtime.topic()) = 'room-' || (select auth.uid())::text
);
Adapt the rule to your own rooms table. Keep policies simple, because the docs warn that complex RLS can slow connection time.
Table changes are a separate path
Realtime also streams database changes, and those follow the table's own Row Level Security. A table with RLS off or an open policy leaks through the stream and through normal queries alike. Check that first.
What an outside scan can and cannot tell you
ProofForge looks at your live site from the outside, the way a stranger would. It can see what ships in your public code, exposed files and open endpoints. It cannot join your private channels as a signed-in user, so it will say inconclusive about channel rules. The two-account test above is yours to run.
Sources
- Supabase Realtime Authorization docs: https://supabase.com/docs/guides/realtime/authorization
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.