# Supabase storage bucket public by mistake? How to lock it down

Canonical: https://caelo.sh/guides/supabase-storage-bucket-public
Published: 2026-11-27 · Updated: 2026-11-27 · Arthi Arumugam, Caelo by Irth Labs

**Short answer:** A public Supabase bucket lets anyone with a file's URL download it with no access check. Uploads, deletes and moves still go through row level security policies on `storage.objects`. If the bucket holds private files, make it private, serve files with signed URLs or authenticated downloads, and add policies that limit each user to their own folder.

## What does public actually mean?

Supabase's docs say a public bucket "bypasses access controls for both retrieving and serving files within the bucket" and that "anyone with the asset URL can access the file." For uploading, deleting, moving and copying, "access control is still enforced", and by default Storage does not allow any uploads to buckets without RLS policies.

So public is right for avatars, product photos and blog images, and wrong for invoices, ID documents, contracts or anything a user uploads expecting privacy. File names that look random are not a protection: URLs end up in logs, emails and browser history.

## The vulnerable pattern and the fix

Vulnerable: a private kind of file in a public bucket, with an open upload policy

```sql
insert into storage.buckets (id, name, public) values ('invoices', 'invoices', true);

create policy "uploads" on storage.objects
for insert with check (true); -- anyone, signed in or not, can upload anywhere
```

Fixed: each user reads and writes only their own folder

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

create policy "Users read their own folder"
on storage.objects for select to authenticated
using (
  bucket_id = 'invoices'
  and (storage.foldername(name))[1] = (select auth.jwt()->>'sub')
);
```

Upload into the user's folder and share with a short-lived signed URL

```ts
const { data: { user } } = await supabase.auth.getUser();
await supabase.storage.from("invoices").upload(user.id + "/march.pdf", file);

const { data } = await supabase.storage
  .from("invoices")
  .createSignedUrl(user.id + "/march.pdf", 60); // valid for 60 seconds
```

The upload policy is the one from Supabase's access control docs. `storage.foldername(name)` splits the object path into folders, and the first folder must equal the signed-in user's ID.

## Fix it, step by step

1. List your buckets and which are public: `select id, public from storage.buckets;` in the SQL editor, or the Storage page of the dashboard.
2. For each public bucket, decide whether every file in it is meant for anyone on the internet. If not, it should be private.
3. Make it private in the dashboard, or from server code with the secret key: `await admin.storage.updateBucket("invoices", { public: false })`.
4. Replace `getPublicUrl` calls for that bucket with `createSignedUrl` or `download`. Public URLs stop working once the bucket is private, which is the point.
5. Store each user's files under a folder named after their user ID and add policies like the ones above. Add update and delete policies only if users need them.
6. Assume files were readable while the bucket was public. If they were sensitive, decide whether the people affected need to be told.

## Check it automatically

Caelo reads the SQL migrations in your `supabase` folder and flags policies whose condition is literally `true`, including policies on `storage.objects` (`supabase.permissive-policy` and `supabase.public-read-policy`). It does not check whether a bucket is set to public, either in an `insert into storage.buckets` line or in the dashboard, so look at the bucket list yourself.

Caelo output for the open upload policy above

```text
- RLS policy lets the role insert any row [needs review]
    supabase/migrations/001.sql:5  (supabase.permissive-policy)
    value: storage.objects: for insert to public, condition is (true)
```

- [Install Caelo: npx caelo . or the MCP server](/)
- [How Caelo compares with gitleaks, TruffleHog, Semgrep and others](/compare)

## Check your own app

1. Run the free local check: `npx caelo .` Caelo is a free, open source (MIT) command line tool and MCP server from Irth Labs that checks the files of an AI-built app for exposed API keys, Supabase and Firebase misconfigurations and `.env` files with real values. It runs on your machine, uploads nothing and uses no AI model. Each finding comes with a plain-English fix.
2. Follow the fix in the report and rerun Caelo. For an untracked, unignored file containing secrets, preview the US$19 quick fix. https://caelo.sh/fix
3. For an engineer's assessment, book the US$490 App Health Check. Irth Labs delivers a report and fixed repair quote, with credit toward the repair. https://www.irthlabs.com/start?service=app-health-check

## Questions

### Can RLS policies protect downloads from a public bucket?

No. Supabase says a public bucket bypasses access controls for retrieving and serving files. Policies on storage.objects still control uploads, deletes and moves, but not public downloads.

### Why can't I upload to my public bucket?

Because public only affects downloads. Uploads need an insert policy on storage.objects, and by default there is none.

### How long should a signed URL last?

As short as your use allows. The expiry is in seconds, so 60 is one minute. Create a fresh one each time a user opens the file rather than storing long-lived links.

## Sources

- [Supabase docs: Storage buckets fundamentals (public and private buckets).](https://supabase.com/docs/guides/storage/buckets/fundamentals)
- [Supabase docs: Storage access control.](https://supabase.com/docs/guides/storage/security/access-control)
- [Supabase reference: createSignedUrl.](https://supabase.com/docs/reference/javascript/storage-from-createsignedurl)
- [Supabase reference: updateBucket.](https://supabase.com/docs/reference/javascript/storage-updatebucket)
- [Supabase troubleshooting: Why can't I upload, list or delete in my public bucket.](https://supabase.com/docs/guides/troubleshooting/why-cant-i-uploadlistetc-my-public-bucket-Z6CmGt)
- [Caelo source: every rule in lib/rules.js.](https://github.com/arthi-arumugam-git/caelo/blob/master/lib/rules.js)

## Related guides

- [How to check your Supabase row level security is actually working](https://caelo.sh/guides/supabase-rls-check)
- [Is my Lovable app secure? A 15-minute self-check](https://caelo.sh/guides/is-my-lovable-app-secure)
- [Is it safe to expose the Supabase anon key in my frontend?](https://caelo.sh/guides/is-supabase-anon-key-safe-to-expose)
- [What does USING (true) mean in a Supabase RLS policy, and is it safe?](https://caelo.sh/guides/supabase-rls-using-true)
