Skip to content

Are your uploaded files public? How to check the Supabase storage buckets in a Lovable or Supabase app (and fix them)

LaunchGuard (https://getlaunchguard.app) is a weekly health check for the app you shipped from Lovable, Cursor, Bolt, or v0. The first scan is free (no card; you prove you own the app) and shows your 1–2 most severe findings, with a fix prompt for each. Paid plans add the full report, a fix prompt for every finding, a weekly rescan and an emailed report. Everything below you can do yourself in your dashboards and a terminal, for free. Only test an app you own.

TL;DR

  1. A Supabase bucket is either private or public. Buckets are private by default. In a public bucket, "anyone with the asset URL can access the file", with no access check on download. (Supabase: Storage buckets) Lovable describes it the same way: public means "files are accessible by anyone with the URL". (Lovable: Storage)
  2. There are two separate problems to check: (a) private files (ID scans, invoices, contracts, user documents) sitting in a public bucket, and (b) a public bucket that also has a broad SELECT policy on storage.objects, which lets any client list every file in it. Supabase's Security Advisor has a dedicated warning for (b): 0025 public bucket allows listing. (Supabase: Database Advisors, lint 0025)
  3. Fix: keep truly public assets (logos, public profile pictures, blog images) in a public bucket without a listing policy. Move private files to a private bucket, add owner-only policies, and serve them with short-lived signed URLs. Then test again signed out.

Why this happens

Storage access in Supabase is controlled by Row Level Security policies on the storage.objects table. Those policies control "every file operation: upload, download, list, move, copy, update, delete, and creating signed URLs". Storage skips the policy check in two cases: "a download through the public URL of a public bucket, and a download or upload through a signed URL". (Supabase: Storage Access Control)

So the public flag on a bucket is a switch that turns off read access control for downloads by URL. Public file URLs follow a fixed pattern, https://[project_id].supabase.co/storage/v1/object/public/[bucket]/[asset-name]. (Supabase: Serving assets) If the file path is guessable, or the URL was shared, logged or pasted somewhere, the file is readable by anyone.

The second trap is listing. Supabase notes that a public bucket does not need any SELECT policy for its files to load by URL. When a public bucket also has a broad policy such as bucket_id = 'avatars' or true, clients can enumerate the files in it through the Storage API, "which often exposes more information than intended". (Supabase: Database Advisors, lint 0025) A prompt like "make uploads work" or "show all images" can produce exactly that kind of policy.

On Lovable's built-in backend, public buckets are blocked by default on all plans, and new buckets are forced to private unless a workspace owner or admin turns off Block public storage buckets. (Lovable: Storage; Lovable: Privacy and security settings) If your app was built before that setting, uses your own Supabase project, or someone turned the block off, check anyway.

Step 1 — List your buckets and see which are public

Lovable (built-in backend): go to More → Storage. Each bucket card shows Private or Public. (Lovable: Storage)

Supabase (your own project): open the SQL Editor and run:

-- Which buckets exist, and which are public?
select id, name, public, file_size_limit, allowed_mime_types
from storage.buckets
order by public desc, id;

-- How many files does each bucket hold?
select bucket_id, count(*) as files
from storage.objects
group by bucket_id
order by files desc;

The storage schema holds metadata about your buckets and objects, and you can query these tables directly. (Supabase: Storage schema)

For every bucket where public = true, ask one question: would I be fine if a stranger downloaded every file in here? Profile pictures, product images and blog images: usually yes. Receipts, ID photos, contracts, CVs, medical or school documents, chat attachments, exports: no. Supabase's own examples put "users' sensitive documents" in private buckets and "user profile pictures", "user public media" and "blog post content" in public ones. (Supabase: Storage buckets)

Step 2 — Look at the policies on storage.objects

Run in the SQL Editor:

select policyname, permissive, roles, cmd, qual, with_check
from pg_policies
where schemaname = 'storage' and tablename = 'objects'
order by cmd, policyname;

pg_policies is the standard Postgres view of every Row Level Security policy, with the roles, command and expressions it uses. (PostgreSQL: pg_policies)

Red flags:

  • A SELECT (or ALL) policy for public, anon or authenticated whose qual is only bucket_id = '<a public bucket>', or true, or 1 = 1. That makes the bucket listable. (Supabase: Database Advisors, lint 0025)
  • An INSERT policy with with_check equal to true and no role. Supabase uses that as a starting point and immediately narrows it to to authenticated and a specific bucket. (Supabase: Storage Access Control)
  • A SELECT policy on a private bucket that does not mention the user (no owner_id, no auth.uid() / auth.jwt()->>'sub', no folder check). Any signed-in user can then read everyone's files.

Also open Advisors → Security Advisor in the Supabase dashboard and look for 0025 public bucket allows listing. (Supabase: Database Advisors)

Step 3 — Test it the way a stranger would (signed out)

Do this only for your own project.

  1. In Step 1, pick one file path from each public bucket: select bucket_id, name from storage.objects where bucket_id = '<bucket>' limit 5;
  2. Open this URL in a private browser window, where you are not signed in: https://<project_id>.supabase.co/storage/v1/object/public/<bucket>/<path> If the file opens, anyone with that URL can open it. That is expected for a public bucket, so the question is only whether the file should be public. (Supabase: Serving assets)
  3. Check listing with the publishable (anon) key only, signed out, from a scratch folder on your machine:
npm init -y >/dev/null && npm install @supabase/supabase-js
cat > list-check.mjs <<'JS'
import { createClient } from '@supabase/supabase-js'
// Use your project URL and the PUBLISHABLE / anon key, never the secret or service_role key.
const supabase = createClient('https://<project_id>.supabase.co', '<publishable-or-anon-key>')
for (const bucket of ['<bucket-1>', '<bucket-2>']) {
  const { data, error } = await supabase.storage.from(bucket).list('', { limit: 100 })
  console.log(bucket, error ? `error: ${error.message}` : `${data.length} entries visible signed out`)
}
JS
node list-check.mjs

list() returns the files and folders in a bucket path. (Supabase JS: list) If a signed-out client gets entries back, anyone can enumerate that bucket. An empty array or an error is what you want for a bucket that should not be browsable. Note that list('') only shows the top level, so if your files live in per-user folders, also try one folder name you saw in Step 1.

  1. For a private bucket, sign in as a second test user in your app and try to open a file that belongs to the first user. If it loads, the SELECT policy is not owner-only.

Step 4 — Fix it

A. Public bucket that should stay public (logos, avatars, blog images): remove the listing policy. Files still load by URL after you drop it. (Supabase: Database Advisors, lint 0025)

drop policy if exists "<name of the broad select policy>" on storage.objects;

B. Bucket that holds private files: make it private. (Supabase: Database Advisors, lint 0025; Supabase JS: updateBucket)

update storage.buckets
set public = false
where id = '<bucket>';

On Lovable, the Storage page cannot edit an existing bucket; ask Lovable in the chat to make the bucket private. Lovable changes storage policies through database migrations, so reverting your code does not undo a policy change. (Lovable: Storage)

C. Add owner-only policies on the private bucket. These follow Supabase's own examples: uploads go into a folder named after the user's ID, and users can read only files they own. (Supabase: Storage Access Control; Supabase: Storage helper functions)

create policy "Users upload into their own folder"
on storage.objects for insert to authenticated
with check (
  bucket_id = '<bucket>' and
  (storage.foldername(name))[1] = (select auth.jwt()->>'sub')
);

create policy "Users read their own files"
on storage.objects for select to authenticated
using (
  bucket_id = '<bucket>' and
  (select auth.jwt()->>'sub') = owner_id
);

If users also need to overwrite files with upsert, Supabase says you also need SELECT and UPDATE permissions. (Supabase: Storage Access Control)

D. Change the app to use signed URLs for private files. A private file can be downloaded with the user's JWT, or through a signed URL created with createSignedUrl(path, expiresIn), where expiresIn is in seconds. (Supabase: Storage buckets; Supabase JS: createSignedUrl) Any getPublicUrl() calls for that bucket will stop working once it is private, so replace them. Keep expiry short: you cannot revoke one signed URL; you have to delete, move or rename the object, or rotate the project's URL signing key. (Supabase: Serving assets)

E. Limit what can be uploaded. Set an allowed MIME type list and a file size limit per bucket. (Supabase: Creating buckets) OWASP also recommends to "only allow authorized users to upload files" and to set a file size limit. (OWASP: File Upload Cheat Sheet)

F. Assume files that were public may already have been copied. Making a bucket private does not remove copies people already downloaded. Lovable's docs say the same and point to support if a file must stop being reachable. (Lovable: Storage) If the bucket held other people's personal data, consider whether you have a duty to tell them.

Then repeat Step 3 signed out and with a second test user.

Copy-paste fix prompt for Lovable or Cursor

Audit the Supabase Storage setup in this project.
1. List every storage bucket, whether it is public, its file size limit and
   allowed MIME types, and what kind of files the app puts in it.
2. List every RLS policy on storage.objects (name, command, roles, USING and
   WITH CHECK expressions) and flag:
   - SELECT or ALL policies on a public bucket that only check bucket_id or are true
     (these let anyone list the bucket),
   - SELECT policies on private buckets that do not restrict to the file owner,
   - INSERT policies that are not limited to authenticated users and one bucket.
3. Propose a plan: keep only truly public assets (logos, public avatars, blog images)
   in public buckets with no listing policy; move user documents and anything private
   to a private bucket; add owner-only INSERT and SELECT policies using a folder named
   after auth.jwt()->>'sub' and owner_id; replace getPublicUrl() for private files
   with createSignedUrl() and a short expiry; add file size and MIME type limits.
4. Write the changes as a database migration, and list every place in the frontend
   that must change.
Do not use the service_role or secret key in the browser. Show me the plan before
you apply it, and then tell me how to test signed out that the files are no longer listable.

FAQ

Is a public bucket always a problem? No. Supabase recommends public buckets for things like profile pictures and blog content, and they cache better. The problem is private files in a public bucket, or a public bucket that can be listed. (Supabase: Storage buckets; Supabase: Database Advisors, lint 0025)

My files have random names. Is that enough? Random names make URLs hard to guess, but a public URL still works for anyone who has it, and a listing policy hands out every name. Use a private bucket for anything private. (Supabase: Storage buckets; Supabase: Database Advisors, lint 0025)

I made the bucket private and now images are broken. Public URLs do not work for private buckets. Use the SDK download with the signed-in user, or a signed URL. (Supabase: Serving assets)

Does the Supabase anon key in my frontend let people read my private bucket? Only as far as your storage.objects policies allow. The service_role key bypasses those policies entirely and must never be in the browser. (Supabase: Storage Access Control)

Can I delete files with SQL? No. Supabase says to delete objects through the Storage API, because a SQL delete leaves the file orphaned in the bucket. (Supabase: Deleting objects)

Sources

Last checked against the sources above: 26 November 2026.

Newsletter

We send a confirmation link first. You are not subscribed until you open it, and every issue has a one-click unsubscribe.

Are your uploaded files public? How to check the Supabase storage buckets in a Lovable or Supabase app (and fix them)