Supabase database

My Supabase storage bucket is public by mistake. Who can see the files?

Anyone who has or can guess a file’s URL can download it, with no sign-in, because Storage skips its access checks for public buckets. If the bucket also has a broad read policy on storage.objects, anyone with your public key can list every file name too, so make the bucket private, drop that policy, add a per-user read policy and serve files with signed URLs.

TL;DR

  • On the real Supabase Storage server, a logged-out visitor downloaded another user’s file from a public bucket by its URL. With no read policy, listing returned nothing.
  • With the common “Public Access” policy (for select using (bucket_id = 'docs')), the visitor listed every user’s folder and file name, then downloaded them.
  • After switching to private, the old public URL returned “Bucket not found”, the owner read his file through a per-user policy, and another user couldn’t read it or sign a URL for it.
  • Supabase’s docs warn that files already cached in browsers can stay reachable after the switch.

Who can see files in a public bucket

Supabase’s bucket guide says that when a bucket is public, anyone with a file’s public URL can download it, and Storage skips access controls when it serves the file. The URL looks like https://<project>.supabase.co/storage/v1/object/public/<bucket>/<path>. Uploads, listing, overwrites and deletes still go through your policies.

So the risk depends on two things: can someone get the URL, and can they list the bucket? URLs leak through shared links, emails, browser history, and your own app if it shows them. File paths built from a user id and a predictable name are easy to guess once one is known.

What we saw in the lab

We ran Supabase’s own Storage server with a public bucket docs holding two users’ files in folders named after their ids.

lab output, 5 Dec 2026 (supabase/storage-api 1.98.5, Postgres 17.11)
-- 1. public bucket, no storage policies
anon GET bob's file by its public URL: 200 Bob Example, passport 123456789 (fake test data)
anon lists the bucket root: 0 []
anon lists bob's folder:    0 []
-- 2. public bucket + "Public Access": for select using (bucket_id = 'docs')   (no role)
anon lists the bucket root: 2 ['11111111-…', '22222222-…']
anon lists bob's folder:    1 ['passport.txt']
anon then downloads it by public URL: 200 Bob Example, passport 123456789 (fake test data)

Without a read policy, a visitor needs the exact path. With the broad policy, which AI builders often add to make images load, the visitor gets a directory of everyone’s files. Supabase’s docs say a public bucket needs no SELECT policy for downloads by URL, and its Security Advisor flags this combination as “Public Bucket Allows Listing”.

Check your project (read-only)

storage-check.sql (read-only)
-- Which buckets are public?
select id, public from storage.buckets order by id;
-- Which policies let people read or list files?
select policyname, cmd, roles, qual
from pg_policies
where schemaname = 'storage' and tablename = 'objects'
order by policyname;

A public bucket holding ID scans, invoices, payslips or anything a user uploaded privately needs to change. A SELECT or ALL policy whose condition is only bucket_id = '…' (or true), for {public}, anon or authenticated, lets those roles list that bucket.

Make it private

Switch the bucket in Storage → bucket → Edit bucket, or in a migration:

supabase/migrations/…_docs_bucket_private.sql
update storage.buckets set public = false where id = 'docs';
drop policy if exists "Public Access" on storage.objects;
create policy "read own files" on storage.objects
  for select to authenticated
  using (bucket_id = 'docs' and (storage.foldername(name))[1] = (select auth.uid()::text));

Then change the app. getPublicUrl() links stop working, so show files with a short-lived signed URL, created as the signed-in user:

app code
const { data, error } = await supabase.storage
  .from('docs')
  .createSignedUrl(`${user.id}/passport.pdf`, 60)   // seconds
// use data.signedUrl in the <a> or <img>

Uploads need their own INSERT policy with the same folder check; overwriting with upsert also needs SELECT and UPDATE. The per-user policies are in storage bucket policies, and upload errors in storage errors and the quota.

How to check it worked

lab output after the switch
anon GET the old public URL:                 400 {"statusCode":"404","error":"Bucket not found"}
bob GET his own file (no policy yet):        400 {"statusCode":"404","error":"not_found","message":"Object not found"}
-- after the per-user read policy
bob GET his own file:                        200 Bob Example, passport 123456789 (fake test data)
alice GET bob's file:                        400 {"statusCode":"404","error":"not_found"}
alice lists bob's folder:                    0 []
alice asks for a signed URL to bob's file:   {"statusCode":"404","error":"not_found"}
anyone opens bob's 60 s signed URL (no key): 200 Bob Example, passport …
a 1 s signed URL, 3 s later:                 400 {"error":"InvalidJWT","message":"\"exp\" claim timestamp check failed"}

Open one of your old public URLs in a private window: it should fail. Then sign in as two users and check each sees only their own files. A signed URL works for anyone who has it until it expires, so keep the expiry short.

If sensitive files were public

Switching to private stops new downloads through Supabase. It can’t recall copies. Supabase’s troubleshooting page notes that a CDN purge doesn’t clear browser caches, so a file someone already loaded may stay in their browser. Work out what was exposed and for how long; the first hour after a leak has the order. In the UK, if the files were personal data, you may need to report it to the ICO within 72 hours of becoming aware.

Ask your AI builder to fix it

Prompt for your AI builder
My Supabase storage bucket "docs" is public but holds private user files. Make it private (update storage.buckets set public = false), drop any storage.objects policy that allows select on the whole bucket, and add per-user policies for the authenticated role where the first folder of the path is the user's id ((storage.foldername(name))[1] = (select auth.uid()::text)) for select, insert, update and delete. Replace every getPublicUrl call for this bucket with createSignedUrl with a 60-second expiry. Don't make any other bucket public. Show me the SQL and code changes before you apply them.

Questions people ask

Who can see files in a public Supabase storage bucket?

Anyone who has the file's URL, without signing in, because Storage skips access checks for public buckets. If a broad read policy also covers the bucket, anyone with your public key can list every file name.

Can people list all files in a public Supabase bucket?

Not by default. Listing needs a SELECT policy on storage.objects. In our lab a visitor listed nothing until we added a policy matching the whole bucket, then saw every user's folder and file.

What happens to public URLs when I make a bucket private?

They stop working. In our lab the old public URL returned "Bucket not found". Your app must switch to signed URLs or authenticated downloads. Files already cached in someone's browser can stay there.

Are signed URLs safe?

A signed URL works for anyone who has it until it expires, with no sign-in. Create it only for the signed-in owner, keep the expiry short, and don't store it. In our lab a one-second URL was refused three seconds later.

Sources and lab

The checks behind this guide, each with example code, a self-check and the fix.

Free check

Check your migrations for this, free.

Paste a public GitHub repo. The free RLS check reads its supabase/migrations and flags tables with RLS off or no policies, always-true policies, update policies with no WITH CHECK, SECURITY DEFINER functions anyone can call or with no fixed search_path, views that skip RLS and public buckets. It never connects to your database.

Free, no sign-upReads migration files onlyHow it works

Written by Manraj Singh Dhillon. Last checked 5 Dec 2026. Code samples are synthetic and run against your own project; nothing here names a real app. Spotted a mistake? Tell us.