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.

Sources