# Backend-as-a-Service Data Exposure > In Supabase/Firebase-style BaaS, the client talks to the database directly using a publishable key embedded in the frontend. That key is meant to be public — the real control is row-level security (Supabase) or security rules (Firebase). Where those are missing, permissive, or only front-end-enforced, anyone with the key reads and writes the whole database. This is the dominant vuln class in vibe-coded apps. ## How it works - The publishable/anon key is in the client JS by design. It authenticates the request to PostgREST (Supabase) or the Firebase REST API; it does not authorize anything. The gap is the backend config the key points at. - Supabase request → three independent layers decide access: **exposed API schemas**, **Postgres grants** (per role, can't see the individual caller), and **RLS policies** (the only layer that sees the caller via `auth.uid()`). RLS is skipped entirely if disabled or if a service_role key is used. - Firebase: `/users` collection with rules lacking `request.auth.uid == userId` lets any authenticated low-priv account read every record. - "Authenticated" ≠ "authorized": once registration is open, the authenticated attack surface is far wider than the anonymous one. ## Techniques / payloads **Supabase (oneleet):** the classic check — read a `public`-schema table with the publishable key — is only ~33% of findings. Vary four axes: - **Schema:** enumerate tables in every exposed schema, not just `public`. A custom schema exposed with `grant all ... on all tables` (from following the custom-schema docs) makes the whole schema behave like `public`. 20 findings were in non-`public` schemas. - **Role:** test with an authenticated account, not just `anon`. 125 tables were inaccessible to the publishable key but readable once an account existed. Registration is often exposed even with no signup UI: call `/auth/v1/signup` directly; front-end-only domain restriction is bypassed the same way; a Before-User-Created hook can fail open on unknown domains, or Confirm-Email-disabled lets you register as another user's email. - **Granularity:** if the whole table is revoked, request individual columns (column-level grants). - **Action:** try both read (`GET`) and insert (`POST`); write access is frequently left open after read is fixed. A permissive policy that does nothing (`to authenticated using (true)`) silences the "RLS disabled" alert without actually restricting anything — a common false fix. **Firebase/Firestore:** register via the Auth REST API to get a low-priv token, then dump a collection: ``` curl -X POST 'https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=API_KEY' -d '{"email":...,"password":...,"returnSecureToken":true}' curl 'https://firestore.googleapis.com/v1/projects/PROJECT/databases/(default)/documents/users' -H "Authorization: Bearer $TOKEN" ``` Also probe the Realtime DB (`/.json`), storage bucket, and `sendOobCode` (unthrottled password-reset mail bombing). **Finding the target:** the Supabase project URL and anon key (a JWT), or the Firebase config, sit in the client JS bundle. Supabase removed anonymous access to the OpenAPI schema, so the old "pull schema from the key" trick is dead; querying nonexistent table names through PostgREST still leaks the real schema via error messages, and GraphQL introspection surfaces undocumented tables. ## Notable cases - **Moltbook (Wiz).** Supabase anon key in frontend JS with missing RLS gave unauthenticated read+write to all data: 1.5M API auth tokens, 35,000 emails, private agent messages, and plaintext OpenAI keys in conversations. GraphQL introspection found an undocumented `observers` table with ~30,000 early-access emails. Write access to public tables stayed open after the read fix. The DB also revealed only 17,000 humans behind 1.5M "agents" (88:1). - **Lovable (BOLA, 2026).** `/projects/{id}/*` verified the Firebase token but not ownership; any free account read source code, hardcoded Supabase creds (then used to query the live DB for real PII and Stripe IDs), and full AI chat histories. Fixed only for new projects; pre-Nov-2025 projects stayed open 48+ days; a regression re-exposed public-project chats for 76 days. Lovable first called it "intentional behavior." See [[BOLA in APIs]]. - **Wiz "1 in 5" vibe-coding research.** Four recurring flaws: client-side-only auth (hardcoded password strings / `localStorage` flags), API keys in client JS, wide-open DB tables (RLS off or permissive), and internal apps public without auth. Wiz worked with Lovable on a global system-prompt change to treat client-side secrets as a risk. - **Firestore PII dump.** A `/users` collection without `request.auth.uid == resource.id` returned the full user directory (PII, bios) to any registered account, plus reset mail bombing via unthrottled `sendOobCode`. ## Defenses - Enable RLS on every table and write real policies (`auth.uid() == user_id`); deny by default. Don't ship a permissive placeholder policy to silence alerts. - Enforce auth and all business rules server-side (Supabase Edge Functions / Firebase Functions); treat the client and its keys as fully public. Proxy third-party API calls through the backend and keep keys in Supabase Secrets. - Lock down registration: don't rely on front-end domain checks; configure Before-User-Created hooks to fail closed; require email confirmation. - Review every exposed schema, not just `public`; grant table/column access explicitly rather than schema-wide. - Rotate any key found in a client bundle only after fixing the backend authz it points at — the key was never the secret. ## Related - [[API Security]] - [[Excessive Data Exposure]] - [[BOLA in APIs]] - [[API Discovery]] - [[Broken Access Control]] - [[Leaked Cloud Credentials]] - [[Hardcoded Secrets]] ## Sources - [[raw/oneleet.com/supabase-security-findings-why-rls-is-only-25-of-the-issues-14135|Supabase Security findings why RLS is only 25% of the issues]] - [[raw/wiz.io/hacking-moltbook-the-ai-social-network-any-human-can-control-8967|Hacking Moltbook: The AI Social Network Any Human Can Control]] - [[raw/wiz.io/wiz-research-discovers-one-in-five-organizations-exposed-to-systemic-r-9203|Wiz Research Discovers One in Five Organizations Exposed to Systemic Risks in Vibe-Coded Applications]] - [[raw/infosecwriteups.com/insecure-firestore-security-rules-pii-exposure-11985|Insecure Firestore Security Rules & PII Exposure]] - [[raw/cyberkendra.com/lovable-left-thousands-of-projects-exposed-for-48-days-and-still-hasn-6558|Lovable Left Thousands of Projects Exposed for 48 Days And Still Hasn't Fixed It]] - [[raw/theregister.com/vibe-coding-upstart-lovable-denies-data-leak-cites-intentional-behavio-6555|Vibe coding upstart Lovable denies data leak cites 'intentional behavior']]