VibeSecurity

Data and privacy

What is Storage Bucket Policy?

A storage bucket policy is the set of rules that decides who can list, read, upload and delete files in a cloud storage bucket, such as Supabase Storage, Amazon S3 or Cloudflare R2.

Files that users upload, such as avatars, invoices, ID documents and exports, live in a bucket rather than in your database. Each bucket is either public or private, and private buckets rely on policies to decide who gets in. In Supabase Storage those policies are row level security rules on the storage.objects table, and the documentation states that by default no uploads are allowed until you add one.

The frequent mistake in AI-built apps is making a bucket public so that images display without extra code. Supabase's documentation is direct about what that means: a public bucket bypasses access controls for retrieving files, so anyone who has the URL can fetch the file. That is fine for a logo and wrong for a passport scan. A second mistake is a policy that lets any signed-in user read or overwrite every file, instead of only files in their own folder.

Keep one public bucket for assets that are truly public and a private one for everything else. Write policies that tie each file path to the user who owns it, serve private files through short-lived signed URLs, restrict upload size and file type, and on S3 leave Block Public Access switched on unless you have a specific reason.

Supabase policy: users read only their own folder
create policy "Users read own files"
on storage.objects for select
to authenticated
using (
  bucket_id = 'documents'
  and (storage.foldername(name))[1] = auth.uid()::text
);

Related terms

Sources

  1. 1.Supabase Docs: Storage Access Control
  2. 2.Supabase Docs: Storage Buckets
  3. 3.AWS Docs: Blocking public access to your Amazon S3 storage