Supabase security · 6 minute read
Supabase Storage: a public bucket URL bypasses every RLS policy
You create a storage bucket, upload user avatars and invoices, and write RLS policies on storage.objects to keep them private. Then someone shares the bucket URL — and every object is public, regardless of your policies. A public bucket bypasses RLS entirely.
This is not a bug. It is the documented behavior of public buckets. The security boundary is the bucket's public flag, not the table policies below it.
What a public bucket means
When public = true on storage.buckets, the object URL (/storage/v1/object/public/<bucket>/<path>) serves the file to anyone who has it. No auth header, no JWT, no RLS evaluation, no row filter. The object is on the open web.
Private objects (including those in private buckets) require a valid user session and pass through storage.objects RLS policies. Public objects skip all of that.
The catalog check
Find every public bucket in your project:
select id, name, public, created_at
from storage.buckets
where public = true
order by name;Every row returned is a bucket whose objects are reachable by anyone with the URL — even if you wrote restrictive policies onstorage.objects.
For the full surface, list all buckets and note which are public:
select id, name, public
from storage.buckets
order by public desc, name;The safe pattern: private bucket + signed URLs
Keep data behind your app instead of on the open web:
- Create the bucket as
public = false. - Write
storage.objectsRLS policies scoped by owner (for example:auth.uid() = owner_id). - Generate signed URLs from server-side code (Edge Function or backend) with an expiration. The client never sees the object path directly; it receives a time-limited signed URL.
A signed URL is valid only for its lifetime and only for the specific object. After expiry, the URL returns 404 even if the object still exists.
Where the leak usually hides
- Default public bucket. Some boilerplates and starter kits create buckets as public by default for "ease of use." The bucket stays public long after the app goes to production.
- Object path guessability. Even in a private bucket, if the path is sequential (
avatars/1.jpg,avatars/2.jpg) and someone obtains one signed URL, they can guess adjacent paths — but they still need a valid session and matching RLS policy to read them. - Confusing the two layers. A team writes strict
storage.objectspolicies and assumes the bucket is private, but the bucket itself was created public. The policies never run for public-bucket requests.
What to audit before you ship
-- Public buckets (the gap)
select id, name, public from storage.buckets where public = true;
-- All buckets with their public flag (full surface)
select id, name, public from storage.buckets order by public desc, name;If any bucket returns public = true and it should not be publicly readable, flip it to private and review thestorage.objects policies for the objects inside.
Pair this with the table checks from the 13-point checklist and the Realtime channel checks from the Realtime security guide. Storage is the third boundary where RLS does not apply by default.
Honest limits
These are catalog reads against the Supabase Storage schema. They cannot test whether a specific signed URL leaks, whether your Edge Function signs URLs with the right expiration, or whether a public bucket URL has already been indexed by a scraper. Those require a live request test with and without auth headers.
A nightly read-only diff over the bucket catalog reports new public buckets before they become an incident. The free starter is here:
Get the free RLS Drift Monitor (13 checks, n8n + SQL) →
If you want a person to review your bucket configuration and storage policies, that is a fixed-scope review: Supabase RLS Spot Check. Work starts only after payment is secured.
Related: Supabase Edge Functions: service_role bypasses every RLS policy · the first 15 minutes of a Supabase security audit.