← All Insights
App security · 7 min read · 14 November 2026

We built an insecure AI-built app on purpose: 7 flaws an outside check finds

Apps built with Lovable, Bolt, Replit or Cursor on top of Supabase or Firebase tend to ship with the same few security gaps. The tools are fast and the apps work, but the database rules, storage settings and keys are easy to get wrong, and nothing on screen tells you they are wrong. To show what that looks like, we built a small app with these gaps on purpose, hosted it like a real product, and checked it from the outside. The check found all 7 flaws we planted, raised no false alarms, and needed 60 requests and under 4 minutes.

By the HasafSec technical team · Reviewed by our technical lead

The lab: Harbourline Realty

Harbourline Realty is a fictional estate-agency CRM: agents sign in, see contacts, track deals and store lease documents. We ran it at lab.hasafsec.com on real hosted Supabase and Firebase projects, the same way a founder's app would, and bring it online for live demonstrations. Every name, phone number and file in it is fake, and the public cannot change anything in it.

We checked it the way we check a client's app:

  • Authorised first. The owner (us) signed a written authorisation naming the app, the hosts allowed and the testing window. The checker refuses to run without it.
  • From the outside. It sees only what any visitor's browser sees: the website's code and the services that code talks to.
  • Read-only. It looks and lists; it never writes, deletes or changes anything. The one sign-in uses a test account the owner set up for the check.
  • Minimal data. The evidence records counts and field names, not the records themselves.

The 7 flaws at a glance

Five were Critical and two High. Severity follows what an outsider could do and what kind of data was exposed.

#FlawSeverityWhere
1Anyone could read the contacts tableCriticalSupabase
2Any signed-in user could read every agent's dealsCriticalSupabase
3A secret Supabase key was in the website's codeCriticalFront end
4An AI provider key was in the website's codeCriticalFront end
5Anyone could read the whole Realtime DatabaseCriticalFirebase
6Anyone could read the orders collectionHighFirestore
7Anyone could list and download lease documentsHighSupabase Storage

1. Row-level security switched off

What we saw: the contacts table, with names, emails and phone numbers, answered anyone holding the public key. That key ships in every Supabase app's front end by design, so “anyone” really means anyone.

Why it happens: a table created by hand or by a quick migration starts without row-level security (RLS) unless someone turns it on. The app still works, so nobody notices.

Fix: turn RLS on for every table in the public schema with alter table public.contacts enable row level security;, then add only the policies you need, such as a select policy for signed-in users with using ((select auth.uid()) = owner_id).

2. RLS on, but the policy lets every user see everything

What we saw: signed in as one test agent, we could read every agent's deals, including client names.

Why it happens: a policy of using (true) for signed-in users makes the RLS warning go away, and a builder or AI assistant will happily write one. It answers “is this person signed in?” when the real question is “is this row theirs?”

Fix: tie each policy to the row's owner, as in using ((select auth.uid()) = owner_id). Test with two accounts: user A should never see user B's rows.

3. A secret Supabase key in the front end

What we saw: a service_role key inside the website's JavaScript. That key ignores every RLS rule, so whoever finds it can read and change the whole database. The lab's key is fake; a real one would hand over the database.

Why it happens: the service key gets pasted in to make something work, or an environment variable meant for the server gets a public prefix such as NEXT_PUBLIC_ or VITE_.

Fix: only the anon or publishable key belongs in the browser. Move anything that needs the service key into a server function or Edge Function. If a service key was ever shipped, rotate it now: removing it from the code does not remove it from copies people already downloaded.

4. An AI provider key in the front end

What we saw: an OpenAI-format API key (sk-proj-…) in the same bundle, fake in the lab.

Why it happens: calling the AI API straight from the browser is the quickest way to build a feature.

Fix: call the AI provider from your server or an Edge Function, keep the key there, and rotate any key that was ever public. Otherwise strangers run up your bill.

5. Firebase Realtime Database open to everyone

What we saw: rules of ".read": true at the root, so the whole database (customers, viewings) was readable without signing in.

Why it happens: test-mode rules from the first day of the project never get replaced.

Fix: deny by default and grant reads per path to the signed-in owner, for example ".read": "auth != null && auth.uid === $uid" under a users/$uid path.

6. A Firestore collection anyone can read

What we saw: allow read: if true on orders.

Fix: allow read: if request.auth != null && request.auth.uid == resource.data.owner_id;, and check the rules with the Firebase emulator before each release.

7. A public storage bucket

What we saw: the documents bucket was public and a policy let anyone list it, so every lease file could be found and downloaded.

Why it happens: “public” is the quickest way to make images show up, and later the same bucket gets private files.

Fix: keep private files in a private bucket, serve them with short-lived signed URLs, and do not give anonymous users a select policy on storage.objects.

What the check left alone

A check that cries wolf wastes your time, so the lab also has parts built correctly. The check examined them and raised nothing: the agent_notes table (RLS on, each agent reads only their own notes), the private agent-private bucket, and the Firestore staff_settings collection, readable only by its signed-in owner.

It also noted, as information only, that the site's code contains its Supabase and Firebase settings. That is normal: those public settings are meant to be there. The risk is in the rules behind them.

Check your own app in 15 minutes

You can run these from your own dashboards, on your own app:

  1. Supabase Table Editor: every table in `public` shows RLS enabled. The Security Advisor lists any that do not.
  2. Supabase policies: no policy reads `using (true)` on a table holding user or customer data.
  3. Two accounts: sign in as user A, then user B. Neither should see the other's records.
  4. Storage: private files sit in private buckets, and anonymous users have no `select` policy on `storage.objects`.
  5. Your live site's code: open the page source and scripts in the browser and search for `service_role`, `sk-`, `secret` and `private_key`. Nothing should match.
  6. Environment variables: nothing secret carries a `NEXT_PUBLIC_`, `VITE_` or `EXPO_PUBLIC_` prefix.
  7. Firebase rules: no `".read": true` or `allow read: if true` outside data that is genuinely public.
  8. Any key that was ever public: rotated, not just deleted from the code.

See the full report

The sample Launch Security Check report from this run shows what an app owner receives: each finding ranked and explained in plain language, with a recommended fix, a way to confirm it worked, and our manual review notes.

HasafSec's Launch Security Check is a fixed-price, outside-in, read-only review for apps built with AI tools on Supabase or Firebase. Nothing is tested until the app's owner has authorised it in writing. You get the report, a 30-minute call to walk through it, and one retest.

If you would like one before your launch or your next customer security questionnaire, [get in touch](/contact?service=launch-security-check).