Open storage buckets
A public bucket, or a storage policy of allow-all, lets anyone with the URL read files other users uploaded.
By ShipSecurely Editorial · Updated · How we make these guides
Shows up in: Supabase, Firebase, Vercel
What it is
Table RLS does not apply to files. Supabase Storage and Firebase Storage have their own policies. A bucket flagged public, or a policy of allow read: if true, means the object URL is the only secret. URLs leak through the network panel, emails, and referrers.
"Public" is appropriate for assets you meant to publish, such as marketing images. It is not appropriate for invoices, IDs, or user uploads you thought were private because the UI does not link to them.
Listing and reading are different. A bucket can hide the file list and still serve any object whose name is known. Generated names help. A private policy helps more.
The Supabase exposure checker can list bucket names and the public flag with the anon key. It does not read files. Open a file URL in a private window before you treat a bucket as safe.
How do I tell if a Supabase storage bucket is public?
Read the public column. Creating buckets inserts a bucket with id, name, and public, and the example sets public to true. The JavaScript example on that page sets public: true and comments the default as false. Run this select in the SQL editor on a project you own:
select id, name, public
from storage.buckets;
A row with public true is a public bucket. Storage buckets says a public bucket bypasses access controls for retrieving and serving files, so anyone with the asset URL can access the file. Uploading, deleting, moving, and copying still go through access control.
A row with public false is a private bucket. Buckets are private by default. On a private bucket, every operation, including downloads, is subject to row level security policies. Storage access control says Storage does not allow uploads without RLS policies, and you allow an operation by creating policies on storage.objects. A private bucket still needs those storage.objects policies.
The storage schema says you can query the storage tables, and that you should treat the schema as read-only. This check is a select.
How to check in 5 minutes
In Supabase, open Storage and look at each bucket's public flag and policies. In Firebase, open Storage rules.
Copy a file URL from one test user. Open it in a private window with no login. If the file loads and it was not meant to be public, the bucket is open.
As a second test user, request the first user's object path through the client SDK. If the SDK returns it, the policy is too wide even when the bucket is marked private.
Search the repo for
getPublicUrlandpublic: true. Those call sites are public by intent. Confirm each one should be.
How to fix
Supabase
Make the bucket private. Add policies so authenticated users can only read and write a prefix that includes their user id.
create policy "own folder read"
on storage.objects
for select
to authenticated
using (
bucket_id = 'uploads'
and (storage.foldername(name))[1] = auth.uid()::text
);
Write the matching insert and update policies with with check. Serve files to the owner with a short-lived signed URL created on the server after you check the session. Do not generate signed URLs for any path the caller passes. Check the prefix first.
Firebase
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /uploads/{userId}/{file} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
That sample is the shape, not a complete ruleset. Add size and content-type checks from unsafe file uploads. Do not deploy if true because a test upload failed.
Vercel
If files live on Vercel Blob or another store, start from private access and issue signed reads. Check that product's docs for the exact flag. A file in public/ on the Next.js app is always public. Do not put user uploads there.
Next.js
The route that mints a signed URL has to authenticate the caller and authorize the path. A route that signs whatever ?path= it receives is an IDOR. See IDOR.
Copy the fix prompt
Paste this into Cursor, Lovable, Bolt, or Claude Code. Read the diff before you merge it.
You are closing open file storage. Do not add features. 1. Find buckets, Blob stores, and public/ folders used for uploads. 2. Make user-file buckets private. Leave truly public marketing assets public and list them in your summary. 3. Add read and write rules so a user can only access their own path prefix. 4. Replace unlimited public URLs with short-lived signed URLs created only after a session check. 5. Do not sign a path just because the client sent it. Show the policy and the signing code. Tell me how to confirm a logged-out request no longer loads another user's file.
Questions
How do I tell if a Supabase storage bucket is public?
Read public from storage.buckets. Creating buckets inserts id, name, and public, and the example sets public to true. Run select id, name, public from storage.buckets; in the SQL editor on a project you own. A true value is a public bucket. Storage buckets says a public bucket bypasses access controls for retrieving and serving files, so anyone with the asset URL can access the file. Uploading, deleting, moving, and copying still go through access control. Buckets are private by default. On a private bucket, every operation, including downloads, is subject to row level security. Storage access control says you allow an operation by creating policies on storage.objects, and a private bucket still needs those policies.
The bucket is private but getPublicUrl still works. How?
getPublicUrl builds a URL. It does not check the policy. If the bucket is actually private, that URL should fail when you open it logged out. If it loads, the object or the bucket is still public.
Are signed URLs safe to put in an email?
They are a bearer token for that file until they expire. Use a short expiry. Do not use a year-long URL as a convenience.
Sources
Related
Guides
Need someone to fix it for you? See /help.
The weekly fix
The weekly fix: 3 real security mistakes in vibe-coded apps and how to fix them, every Tuesday.