Cover image: Anyone can read this table. Supabase RLS checks for AI-built iOS apps, after the Lovable study

 

Short answer

Crissy Field scanned 159,041 Lovable projects and found thousands of Supabase-backed apps whose tables anyone could read, from chat messages to passport numbers, because row level security was off or too loose. Any iOS app that talks to Supabase can have the same hole. Make sure no secret key ships in your build, find tables without RLS and policies that are simply true, read your data as the anon role and as a signed-in stranger, fix the common patterns in a migration, and run Supabase's Security Advisor.

A German security firm, Crissy Field, looked at 159,041 apps built with Lovable and found that thousands of them let anyone read data that should have been private. In the worst cases that meant passport numbers, ticket codes, contracts and private chat messages, all reachable without logging in. The researchers did not break into Lovable. The apps were doing exactly what their databases allowed, and the databases allowed too much.

If you built an iOS app with Rork, Bolt, Lovable, Cursor, Claude Code or any other AI tool and it talks to Supabase, the same mistake can sit in your project. This post explains what the study found, why a native or Expo app is exposed in the same way as a web app, and how to check and fix your own tables in about an hour. Every check below is something you run against your own project.

What the Lovable study found

Crissy Field worked with the German business paper Handelsblatt, which reported the first results on November 2, 2026. The firm has since published an English report with updated figures. Here is what it says.

The team pulled Lovable projects out of Common Crawl, the public web archive, covering December 2025 to September 2026. That gave them 159,041 projects. Of those, 34,545 used Supabase as their database. Lovable's own database feature, added in late 2025, was left out of the study.

Of the Supabase projects, 24,664 websites sent database records to the browser as soon as the page loaded, with no login. That alone is not a problem, because a product catalogue or a blog list is meant to be public. The researchers then made more read-only requests with the same key the site already used, and found records containing email addresses in 10,560 tables across 7,403 of those 24,664 sites. That is the 30% figure you may have seen in headlines.

The report is careful about that number. An email column can be a public contact address or test data, and plenty of private records contain no email at all, so the 30% is not a confirmed leak rate. It covers only the 24,664 sites they examined closely, and a Common Crawl sample is not representative of every Lovable app.

The individual cases are the part worth reading. A German lifestyle forum exposed more than 80,000 profiles with names, emails, dates of birth and gender, plus more than 200,000 chat messages. Event organisers and restaurants exposed tens of thousands of ticket and food orders with phone numbers, postal addresses, payment information and ticket codes. A property manager exposed AI-generated summaries of internal emails about tenants. One service provider exposed more than 1,000 records with passport numbers, expiry dates and nationalities. The researchers say they could not tell whether any of it had been misused.

The report also makes a point that applies to every AI app builder. Because these tools wire up the database the same way every time, a trick that reads one app's data tends to work on the next one too. Mistakes in hand-written apps tend to be scattered, while mistakes in generated apps repeat.

Why your iOS app has the same exposure

A Supabase app talks to the database directly from the client. Your iOS app holds a project URL and a key, and it sends requests straight to Supabase's REST API. There is no server of yours in between unless you built one.

Supabase is designed for this. Its docs call the publishable key (it starts with sb_publishable_, and older projects use a legacy JWT called anon) safe to put in mobile and desktop apps, where it ends up "bundled inside the compiled packages or executables". Anyone can unzip your IPA and pull that key out. That is expected, and it is fine, on one condition: Row Level Security (RLS) must be switched on for every table the API exposes, with policies that say who may see which rows.

Requests made with the publishable key run as one of two Postgres roles. With no signed-in user they run as anon. With a signed-in Supabase Auth user they run as authenticated. If a table in the public schema has RLS off and those roles still hold their default grants, anyone with your key can read the whole table. It makes no difference that your app only ever shows a user their own rows. The app is one client. The API answers anyone who holds the key.

Supabase's own docs add a detail that catches people out. On existing projects, a new table created in public starts with every privilege granted to anon, authenticated and service_role. Adding a policy later does not remove those grants. So a table your coding agent created in a hurry, during a session you barely remember, can be wide open today.

The secret key is a different matter. It starts with sb_secret_ (the legacy version is the service_role JWT), it skips every RLS policy, and Supabase says plainly that it must never be in "a bundled mobile, desktop, or CLI package". AI tools sometimes reach for it when a query fails with a permission error, because it makes the error go away. If that key is in your app, RLS does not protect you at all.

Step 1: find out which keys your build ships

Start with the binary, because a secret key in the app makes every other check pointless. The script below reads an .ipa, an .app folder or a JavaScript bundle (Expo and React Native apps ship one) and lists every Supabase key it finds. For legacy JWT keys it decodes the payload and reads the role, so it can tell an anon key from a service_role key.

#!/usr/bin/env python3
"""List Supabase keys found inside an .ipa, .app folder or JS bundle.

Usage: python3 check_bundle_keys.py MyApp.ipa
       python3 check_bundle_keys.py build/MyApp.app
"""
import base64, json, os, re, sys, zipfile

JWT = re.compile(rb"eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}")
NEW = re.compile(rb"sb_(?:secret|publishable)_[A-Za-z0-9_-]{10,}")

def blobs(path):
    if os.path.isdir(path):
        for root, _, files in os.walk(path):
            for name in files:
                full = os.path.join(root, name)
                try:
                    with open(full, "rb") as f:
                        yield full, f.read()
                except OSError:
                    pass
    elif zipfile.is_zipfile(path):
        with zipfile.ZipFile(path) as z:
            for info in z.infolist():
                if not info.is_dir():
                    yield info.filename, z.read(info)
    else:
        with open(path, "rb") as f:
            yield path, f.read()

def jwt_role(token):
    part = token.split(b".")[1]
    part += b"=" * (-len(part) % 4)
    try:
        return json.loads(base64.urlsafe_b64decode(part)).get("role", "?")
    except Exception:
        return "unreadable"

def main(path):
    found_secret = False
    seen = set()
    for name, data in blobs(path):
        for m in NEW.findall(data):
            key = m.decode()
            if (name, key) in seen:
                continue
            seen.add((name, key))
            kind = "SECRET" if key.startswith("sb_secret_") else "publishable"
            found_secret |= kind == "SECRET"
            print(f"{kind:12} {key[:18]}...  in {name}")
        for m in JWT.findall(data):
            role = jwt_role(m)
            if role not in ("anon", "service_role"):
                continue
            if (name, m) in seen:
                continue
            seen.add((name, m))
            kind = "SECRET" if role == "service_role" else "publishable"
            found_secret |= kind == "SECRET"
            print(f"{kind:12} legacy {role} JWT  in {name}")
    if found_secret:
        print("\nA secret key ships in this build. Rotate it in the Supabase dashboard now.")
        return 1
    print("\nNo secret Supabase key found.")
    return 0

if __name__ == "__main__":
    if len(sys.argv) != 2:
        sys.exit(__doc__)
    sys.exit(main(sys.argv[1]))

Export an IPA from Xcode (Product, Archive, then Distribute App with a development or ad hoc method) or point the script at the .app inside your build products folder. Run it from Terminal with python3 check_bundle_keys.py MyApp.ipa. It exits with code 1 when it finds a secret key, so you can also drop it into a CI step.

The script was tested on Linux against a fake IPA holding a publishable key, a legacy anon JWT, a sb_secret_ key and a legacy service_role JWT inside a JS bundle. It flagged both secret keys and exited 1, and a clean bundle with only the anon key exited 0. It has not been run on a real App Store build, and a key that the app downloads at runtime will not show up because it is not in the bundle.

If it prints SECRET, stop here. Rotate that key in your project's API Keys settings, move whatever needed it into an Edge Function or your own server, and ship a new build. Old builds keep the old key forever, so rotation is the only real fix. Backdoored Claude Code Extension in Cursor: Check Your Mac, Then Rotate These iOS Keys has a wider list of keys worth rotating at the same time.

Running the key check on a real build

The script was run again on a Mac, this time against a real app: a sample iOS app built with Xcode 26.2 for the Simulator, in both the Debug and Release configurations, with made-up keys planted in the places they usually hide. None of the keys was real. This is where the script found them:

Where the key wasDebug buildRelease build
Publishable key in a Swift stringFoundFound
Secret key in one Swift stringFoundFound
Secret key built from two strings joined with +MissedFound
Legacy service_role JWT in a Swift stringFoundFound
Secret key in Info.plist, which Xcode writes as a binary plistFoundFound

With a secret key present it printed the rotation warning and exited 1. Zipped into an .ipa with the usual Payload folder, the Release build gave the same five findings. After the secret keys were removed and the app rebuilt with only publishable keys, it printed "No secret Supabase key found." and exited 0.

Three details from the run are worth knowing:

  • In a Debug build the keys were not in the app binary. They were in KeyApp.debug.dylib, the file Xcode puts most of a Debug build's code into. A check that only looks at the main executable would have reported a clean build. This script walks every file, which is why it found them.
  • Scan the Release or archived build. The split key was only caught there, because the optimizer joins constant strings in a Release build and leaves them apart in a Debug one. The build you scan should be the build you ship.
  • A clean scan proves less than it seems. A key decoded at runtime, from base64 or fetched from somewhere, never appears in the files. That is not a reason to hide a secret key better. A secret key does not belong in the app at all, which is why Step 1 says to rotate it and move the work to a server.

Step 2: audit your tables in the SQL Editor

Open your project in the Supabase dashboard, go to the SQL Editor and run these queries one at a time. They only read the Postgres catalog, so they change nothing.

The first lists tables in public that have RLS switched off. Every row it returns is a table the API can serve without any policy check.

select c.relname as table_without_rls
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p') and not c.relrowsecurity
order by 1;

The second finds policies whose rule is simply true. A policy like that turns RLS on in name only. AI tools write it often, because it is the quickest way to make a failing query pass.

select tablename, policyname, roles, cmd
from pg_policies
where schemaname = 'public' and (qual = 'true' or with_check = 'true')
order by 1;

Some of these are fine. A waitlist that anyone may insert into needs a with check (true) insert policy. A using (true) select policy on that same waitlist means anyone can download your whole list of sign-ups, which is exactly the kind of table the Lovable study kept finding.

The third lists tables with RLS on and no policy at all. These are safe from the API, since nothing gets through, but they usually mean a feature in your app is quietly returning empty results.

select c.relname as rls_on_no_policy
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p') and c.relrowsecurity
  and not exists (select 1 from pg_policies p
                  where p.schemaname = 'public' and p.tablename = c.relname)
order by 1;

The fourth finds views that ignore RLS. Supabase's docs warn that views bypass RLS by default, because they run with the rights of the user who created them. A summary view over a locked table can hand out what the table itself protects.

select c.relname as view_without_security_invoker
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'v'
  and coalesce(array_to_string(c.reloptions, ','), '') !~* 'security_invoker=(true|on|1)'
order by 1;

The fifth shows what the anon role is allowed to do on each table and view, before any policy runs.

select c.relname as table_name,
  has_table_privilege('anon', c.oid, 'select') as anon_select,
  has_table_privilege('anon', c.oid, 'insert') as anon_insert,
  has_table_privilege('anon', c.oid, 'update') as anon_update,
  has_table_privilege('anon', c.oid, 'delete') as anon_delete
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p', 'v')
order by 1;

Read the results together. A table that shows up in the first query and has anon_select set to true is the exact pattern behind the exposed apps in the study.

Step 3: read your data as a stranger would

Catalog queries tell you what is configured. This step shows what actually comes back. Run it in the SQL Editor. It switches to the anon role inside a transaction, counts what that role can see, and rolls back, so nothing is changed.

begin;
set local role anon;
select 'profiles' as t, count(*) from public.profiles
union all select 'orders', count(*) from public.orders
union all select 'order_summary', count(*) from public.order_summary;
rollback;

Replace the table names with your own. Any count above zero on a table that holds personal data is a leak. A "permission denied" error is good news: it means the anon role has no grant on that table, which Supabase reports as error 42501.

Then repeat the test as a signed-in user, which is the case that most AI-built apps get wrong. RLS is often switched on with a policy of "any logged-in user can read", so every user can read every other user's rows. Take a real test user's id from the Authentication page and run:

begin;
set local role authenticated;
select set_config('request.jwt.claims',
  '{"sub":"PUT-TEST-USER-UUID-HERE","role":"authenticated"}', true);
select count(*) as other_users_rows
from public.orders
where user_id <> 'PUT-TEST-USER-UUID-HERE';
rollback;

The answer should be zero. If it is not, user A can read user B's orders, and anyone who signs up for your app can do the same.

Step 4: fix the common patterns

These fixes follow the patterns in Supabase's RLS guide. Put them in a migration file in your repo, so the next coding agent session cannot quietly undo them, and review each one before you run it. A wrong policy can lock your own users out of their data.

For a table where each row belongs to one user, switch RLS on and add a policy that compares the row's owner with the signed-in user:

alter table public.profiles enable row level security;

create policy "Users read own profile" on public.profiles
  for select to authenticated
  using ((select auth.uid()) = id);

Supabase recommends writing (select auth.uid()) rather than a bare auth.uid(), so Postgres works it out once per statement instead of once per row, and always naming the role with to authenticated. Add separate insert, update and delete policies only for the actions your app really needs, with with check on insert and update so a user cannot write a row that claims to belong to someone else.

For a waitlist or contact form, let people write and stop them reading:

drop policy if exists "anyone" on public.waitlist;

create policy "Anyone can join the waitlist" on public.waitlist
  for insert to anon, authenticated
  with check (true);

revoke select on public.waitlist from anon, authenticated;

Your app's insert call must not ask for the new row back, because that requires read access. In supabase-js an insert returns nothing unless you chain .select() onto it; in Swift, check that no .select() follows the insert. If the table uses a serial id and the insert fails with a sequence error, the role also needs grant usage on sequence for that table's sequence.

For a view, make it respect the tables underneath. On Postgres 15 and later:

alter view public.order_summary set (security_invoker = true);

On older Postgres versions, Supabase's advice is to revoke the view from anon and authenticated or move it into a schema the API does not expose.

Policies that filter on a column need an index on that column, or every request scans the whole table:

create index if not exists orders_user_id_idx on public.orders (user_id);

Finally, tighten the grants. Supabase's guide says to revoke the defaults and grant back only what each role needs, for example revoke all on table public.reports from anon, authenticated; followed by a grant of the specific actions to authenticated. Do this table by table, after you know which screens use which tables.

Every query and fix in Steps 2 to 4 was run on a local PostgreSQL 16.15 server with stand-in anon and authenticated roles and a stand-in auth.uid() that reads the same request.jwt.claims setting. Before the fixes, the anon role could count every row in a profiles table with RLS off, read a waitlist through a using (true) policy, and see per-user order counts through a view, even though the orders table itself returned nothing. After the fixes all three returned zero rows or a permission error, the waitlist still accepted new sign-ups, and a signed-in test user saw only their own order. This was not run against a hosted Supabase project, so check the results on yours.

Step 5: let Supabase's Security Advisor check your work

Supabase ships a linter for these problems. In the dashboard it lives under Advisors, then Security Advisor. From the terminal, the Supabase CLI runs it with supabase db advisors. Several of its checks map directly onto the study's findings:

  • 0013, RLS disabled in public: a table anyone can read through the API.
  • 0024, permissive RLS policy: a policy with unrestricted access, like using (true).
  • 0010, security definer view: a view that bypasses RLS.
  • 0007, policy exists but RLS is disabled: someone wrote rules that are never enforced.
  • 0025, public bucket allows listing: anyone can list the files in a Storage bucket.
  • 0023, sensitive data publicly accessible.

Supabase notes that some findings can be intentional, so read each one against what your app is meant to share. Run it again after every schema change, because each new table starts open on many projects.

Storage needs the same attention as tables. If users upload ID photos, receipts or profile pictures, check that those buckets are private and that their policies scope each file to its owner. Public buckets that allow listing let anyone enumerate every file.

Step 6: test from outside, with your own key

The last check uses the same path the researchers used: an ordinary HTTP request carrying the key your app already ships. Do this only against your own project.

curl -s "https://YOUR-PROJECT-REF.supabase.co/rest/v1/profiles?select=*&limit=1" \
  -H "apikey: $SUPABASE_PUBLISHABLE_KEY"

An empty array, [], means the anon role can see no rows. A permission error means it has no grant. A row of real data means the table is open to the internet.

For the signed-in case, a test in your Xcode project can sign in as one test user and ask for rows belonging to anyone else. This sketch uses supabase-swift. It has not been compiled, so treat it as a starting point and adjust the table and column names.

import XCTest
import Supabase

final class RLSTests: XCTestCase {
  struct OrderRow: Decodable {
    let id: Int
    let user_id: UUID
  }

  let client = SupabaseClient(
    supabaseURL: URL(string: "https://YOUR-PROJECT-REF.supabase.co")!,
    supabaseKey: "YOUR-PUBLISHABLE-KEY"
  )

  func testSignedInUserSeesOnlyOwnOrders() async throws {
    let password = ProcessInfo.processInfo.environment["TEST_USER_A_PASSWORD"] ?? ""
    try await client.auth.signIn(email: "test-a@example.com", password: password)
    let me = try await client.auth.session.user.id

    let others: [OrderRow] = try await client
      .from("orders")
      .select("id, user_id")
      .neq("user_id", value: me)
      .execute()
      .value

    XCTAssertTrue(others.isEmpty, "User A can read \(others.count) rows owned by other users")
  }
}

Keep the test user's password in an environment variable in your scheme or CI, never in the repo. Point the test at a staging project if you have one, so it does not create noise in production data.

Does App Review check any of this?

Not directly. App Review tests the app on a device. It does not audit your Supabase policies, and a build with an open database can be approved. That does not make it compliant. Guideline 1.6 says apps "should implement appropriate security measures" to protect user information and "prevent its unauthorized use, disclosure, or access by third parties." An open profiles table fails that test, and your App Store privacy answers become wrong the moment strangers can read the data you collect.

The bigger cost is outside Apple's process. The study's examples included passport details and payment information. If your app holds data like that, a leak is a legal and trust problem for you, whichever tool wrote the code.

How to keep your coding agent from reopening the hole

Most of these tables were never opened on purpose. An agent hit a permission error and took the quickest route that made it pass. A few habits make that less likely. Cursor Can Now Deploy Your App From a Prompt. Test These 5 Bugs Before You Share the Link covers more shortcuts like this one.

Tell the agent, in your project instructions file, that every new table in public must ship with RLS enabled and owner-scoped policies in the same migration, that using (true) needs your approval, and that a secret or service_role key may never appear in client code. Ask it to run supabase db advisors after any schema change and paste the result.

When a query fails with error 42501 or returns nothing, treat that as RLS doing its job. Ask the agent which policy is missing for that specific user and action, and review the policy it proposes before it runs.

Keep the Step 1 script and the Step 6 test in CI. They are cheap, and they fail loudly when someone takes a shortcut.

A short checklist

  • No sb_secret_ or service_role key in any build you have shipped. If there is one, rotate it.
  • Every table in public has RLS on.
  • No select policy uses true on a table with personal data.
  • Waitlists and contact forms are insert only.
  • Views use security_invoker = true or are not exposed.
  • A signed-in test user sees zero rows owned by anyone else.
  • Policy columns are indexed.
  • Storage buckets with private files are private and cannot be listed.
  • Security Advisor shows no unexplained warnings.
  • Policies live in migrations in your repo.

FAQ

Is it a problem that my publishable key is visible in my app?

No. Supabase designed that key to be public and says it is safe in mobile apps. Your data is protected by RLS policies, and those are what you need to check.

Does this affect apps that don't use Lovable?

Yes. The study only looked at Lovable projects, but the cause is a missing or loose RLS policy, which any Supabase project can have, whether the code came from an AI tool or a person.

My app only shows users their own data. Am I safe?

Not necessarily. Your app is one client. The REST API answers any request that carries your key, so what matters is what the policies allow. Run Step 3 to see.

Will turning on RLS break my app?

It can, if you switch it on without policies, because every query will then return nothing. Add the policies in the same migration, test with a real signed-in user, and roll out to staging first.

Do I need to tell users if a table was open?

That depends on what data was exposed and where you and your users are. If personal data was readable, get advice on your obligations before deciding.

If you use Claude Code on your iOS project, Claude Code + Xcode: The Production iOS Workflow Kit ($18+) is a set of Claude Code rules, commands and agents for SwiftUI and UIKit work. It includes a privacy and security rule and human approval gates around auth, payments, PII and persistence. It covers the iOS side only, so it has no Supabase policies or backend scanner, and you still need the checks above for your database.

Sources