supabase
Your Supabase Storage bucket is public: how vibe coders leak uploads
Why a public Supabase Storage bucket in Lovable, Bolt, or Cursor apps is world-readable, how to check in two minutes, and copy-paste private-bucket + signed URL fixes—then re-scan with the free grader.
Paste your production URL into the free Vibe Code Health grader for a Semrush-style score on secrets, headers, TLS, and common leaks—then come back to this guide for the fixes.
You asked Lovable, Bolt, or Cursor to “add profile photo uploads with Supabase.” The AI created a Storage bucket, checked Public, dropped three lines of client code into your React app, and the upload worked on the first try. You shipped.
Here is the part nobody highlighted in the chat: a public Supabase Storage bucket is world-readable. Anyone who knows (or guesses) the object path—or who can list the bucket with your public anon key—can download the files. That includes avatars, sure, but also resumes, ID scans, invoice PDFs, and chat attachments if you reused the same bucket later.
This guide is only about Supabase Storage buckets in vibe-coded apps (Lovable, Bolt, v0, Replit, Cursor + Supabase). It is not the anon-vs-service_role key explainer (Supabase keys) and not a full Postgres RLS tutorial (RLS for beginners)—though Storage has its own policies that work the same mental model.
Scan your live URL with Vibe Code Health. If the grader finds your project URL and anon key in the page, it now passively asks Supabase Storage whether buckets are public or listable—without logging in as you.
What “public bucket” actually means
Supabase Storage stores files in buckets. Each bucket has a flag: public or private.
Official docs are blunt: public buckets serve objects over a permanent public URL; private buckets require authorization or a short-lived signed URL (Storage access control, Serving assets from Storage).
| Bucket type | Typical URL pattern | Who can download? |
|---|---|---|
| Public | /storage/v1/object/public/{bucket}/{path} | Anyone with the path (often the whole internet) |
| Private | /storage/v1/object/authenticated/… or signed URL | Only roles your Storage policies allow, or holders of an unexpired signed URL |
The anon key in your frontend is supposed to be public (Understanding API keys). That is fine for Postgres only if RLS is tight. For Storage, the same anon key plus a public bucket (or a private bucket with USING (true) policies) is how uploads become a free file dump.
OWASP’s guidance on sensitive data exposure still applies here: do not put private user files where unauthenticated clients can fetch them (OWASP A02 Cryptographic Failures / sensitive data — treat stored personal files as sensitive data at rest and in transit).
Why vibe builders default to public
AI app builders optimize for a demo that “just shows the image”:
- You say “profile pictures.”
- The model creates bucket
avatarsand sets Public so<img src={publicUrl}>works with zero extra code. - A week later you add “upload your resume” or “attach a PDF” and the model reuses
avatarsor another public bucket. - Launch boards, scrapers, and curious users open DevTools, copy
NEXT_PUBLIC_SUPABASE_URL+ anon key (already in the bundle), and call the Storage API the same way your app does.
Minification does not help. The project URL and anon JWT are still string literals. That is expected for Supabase clients—the bucket configuration is what decides whether that is safe.
The anti-pattern (looks fine, is not)
// ❌ Dangerous pattern for private user files
const { data } = await supabase.storage
.from("uploads") // bucket marked Public in dashboard
.upload(`${userId}/${file.name}`, file);
const { data: pub } = supabase.storage
.from("uploads")
.getPublicUrl(`${userId}/${file.name}`);
// pub.publicUrl is a permanent, shareable link — no login required
If uploads is public, that URL works in an incognito window, a curl one-liner, and a scraper. Folder prefixes like ${userId}/ are not security; they are naming conventions.
Two-minute check (before you share the link)
- Open Supabase → Storage. Note which buckets say Public.
- In the SQL editor or API docs, confirm you did not add policies like “allow select for anon” with
trueon a private bucket (Policy examples). - Paste your production hostname into Vibe Code Health. Look for findings such as Supabase Storage bucket is public with listable files or Anon key can list private Supabase Storage objects.
- Optional manual probe (your own project only): from DevTools console on your site, you already have the anon key. Listing buckets or objects from someone else’s project without permission is not OK—only test apps you own.
If the scanner lists sample object names, treat those names as disclosed. Rotate nothing yet for Storage alone (the anon key is meant to be public), but move or delete sensitive objects and fix policies immediately.
The fix: private bucket + signed URLs
Step 1 — Create a private bucket for user content
In Supabase Dashboard → Storage → New bucket:
- Name:
user-uploads(or similar) - Public bucket: off
Keep a separate public bucket only for truly public marketing assets (logo, landing hero). Do not mix resumes into it.
Step 2 — Storage policies (default deny)
Storage uses Postgres policies on storage.objects (and related tables). Same idea as table RLS: no policy ⇒ no access for that role (Storage access control).
-- Users may only read/write objects under their own folder: {user_id}/...
create policy "users read own uploads"
on storage.objects for select
to authenticated
using (
bucket_id = 'user-uploads'
and (storage.foldername(name))[1] = auth.uid()::text
);
create policy "users upload to own folder"
on storage.objects for insert
to authenticated
with check (
bucket_id = 'user-uploads'
and (storage.foldername(name))[1] = auth.uid()::text
);
-- Avoid: create policy ... to anon using (true);
Never grant anon blanket SELECT on private buckets. Guest uploads, if you need them, deserve a dedicated design (signed upload URLs from a server route, strict MIME/size limits)—not USING (true).
Step 3 — Upload, then sign (client pattern)
import { createClient } from "@supabase/supabase-js";
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
export async function uploadUserFile(userId: string, file: File) {
const path = `${userId}/${crypto.randomUUID()}-${file.name}`;
const { error } = await supabase.storage
.from("user-uploads")
.upload(path, file, { upsert: false });
if (error) throw error;
const { data, error: signErr } = await supabase.storage
.from("user-uploads")
.createSignedUrl(path, 60 * 10); // 10 minutes
if (signErr) throw signErr;
return data.signedUrl;
}
Signed URLs expire (Creating signed URLs). That is what you want for private files. For Next.js server routes you can also create signed URLs with the user’s session or a carefully scoped server client—still never put service_role in the browser (API keys).
Step 4 — Lovable / Bolt / v0 / Replit prompts that help
Paste something like:
Make the Supabase Storage bucket for user uploads private. Remove getPublicUrl for those files. After upload, use createSignedUrl with a short expiry. Add Storage policies so authenticated users can only read/write objects whose first folder equals auth.uid(). Do not add anon SELECT policies with true.
Then redeploy and confirm Network tab shows signed URLs (with tokens) instead of /object/public/... for private files.
Step 5 — Clean up what already leaked
- List objects in every public bucket; delete or move anything personal.
- If a private bucket was listable to anon, assume object names (and likely contents) were visible—notify users if required by your threat model or local rules.
- Re-scan on Vibe Code Health until Storage findings clear.
- Skim /learn for how grades and glossary terms (RLS, JWT) fit the rest of the report.
Public images vs private uploads (decision table)
| Content | Bucket | URL helper |
|---|---|---|
| Logo, marketing OG image | Public OK | getPublicUrl |
| User avatar you are fine showing to the world | Public or private + signed | Prefer private if the app has minors, health, or dating context |
| Resumes, IDs, medical PDFs, chat attachments | Private only | createSignedUrl |
| Admin exports | Private + server/service_role only | Never anon |
“But Instagram avatars are public” is not a reason to put tax documents in the same bucket.
How this differs from table RLS
You can enable RLS on profiles and still leak every passport scan through Storage. Table policies do not protect storage.objects. Supabase documents Storage policies separately for that reason (Storage access control). Fix both.
Related reading on this site:
- Supabase anon vs service_role
- RLS explained for beginners
- Pre-launch safety walkthrough
- Platform notes under /for/lovable and glossary on /learn
What “fixed” looks like
| Signal | Still broken | Fixed |
|---|---|---|
| Dashboard bucket toggle | Public for user files | Private for user files |
| Client helper | getPublicUrl on uploads | createSignedUrl with short TTL |
| Anon Storage policy | USING (true) | No anon read; path scoped to auth.uid() |
| Vibe Code Health | Public/listable Storage finding | Finding gone after policy + bucket change |
Keep going
Rotate nothing for a normal anon key—but do treat every public object URL as permanent until you delete the object. Private bucket, tight Storage policies, signed URLs, then re-scan. Uploads that “just worked” in Lovable are one of the easiest ways vibe-coded apps leak personal files—and one of the fastest to fix once you know public means public.