AI builders love public storage buckets. They make image uploads "just work": no policies, no signed URLs, no errors. That's fine for logos and avatars. It's not fine when the same bucket holds ID photos, invoices, contracts or anything a user uploaded expecting it to stay private.
What "public" actually means
- Anyone with the file URL can download it. Public files are served from
/storage/v1/object/public/<bucket>/<path>with no login and no policy check. - Uploads, updates and deletes still need policies. "Public" only covers reading.
- Listing is the bigger risk. A broad
selectpolicy onstorage.objectsthat only checksbucket_id = 'uploads'lets anyone holding your publishable (anon) key, which is in your site's JavaScript, list every file in the bucket and download them all.
The 2-minute check
- In Supabase, open Storage. Buckets marked Public are readable by anyone with a link.
- For each public bucket ask: would a user be upset if a stranger saw these files? Avatars and product photos: fine. Passports, payslips, medical files, private chat attachments: not fine.
- Look at the
selectpolicies onstorage.objects. A policy foranon/publicthat only checks the bucket name lets anyone list the bucket. - Run the Security Advisor in the dashboard too.
The fix
Keep public buckets for public things only. Put private uploads in a bucket with Public off, stored under the user's id (<user-id>/invoice.pdf), with owner-only policies:
create policy "Users read own files" on storage.objects for select to authenticated using ( bucket_id = 'private-uploads' and (storage.foldername(name))[1] = (select auth.uid())::text ); create policy "Users upload to own folder" on storage.objects for insert to authenticated with check ( bucket_id = 'private-uploads' and (storage.foldername(name))[1] = (select auth.uid())::text ); Show files with short-lived signed URLs instead of permanent public links:
const { data } = await supabase.storage .from('private-uploads') .createSignedUrl(`${user.id}/invoice.pdf`, 60); // valid for 60 seconds Then remove broad select policies from public buckets (public files load without one; the policy mostly adds listing), and move existing sensitive files: copy to the private bucket, update paths in your database, delete the public copies.
A prompt for Lovable, Bolt or Cursor
Audit my Supabase Storage setup: 1. List every bucket, whether it is public, and what the app stores in it. 2. Anything user-uploaded and private (documents, IDs, invoices, attachments) must go in a private bucket, under the user's id folder. 3. Add select and insert policies on storage.objects so users can only access their own folder. No select policy for anon on any bucket. 4. Replace getPublicUrl for private files with createSignedUrl. 5. Give me a migration plan for files already in public buckets. The full guide, with FAQs, is on LeakPatrol. If you want an outside check of your live app (leaked keys, public files, tables that answer without a login), there's a free read-only scan there too.

