ECSEXCELON CYBER SOLUTIONS

Vibe-Coded Apps and Supabase: The Open Database Hiding Behind a Public Key

Why AI-generated apps often ship exposed databases, how to check a Supabase project for missing row level security in minutes, and how to fix it.

By Excelon Cyber Solutions Security Team5 min read

"Vibe coding", describing an app to an AI tool and shipping what comes back, has put working products in front of users in a weekend. It has also put a recurring class of bugs into production: the app works perfectly for the developer and quietly exposes everything to anyone who knows where to look. This post examines the most common one, a database left readable because row level security was never switched on.

Key takeaways

  • AI-generated apps work for the developer while quietly exposing data to everyone else.
  • The Supabase anon key is public by design; row level security is what protects your tables.
  • With RLS off, the anon key can read, and sometimes write, every row.
  • Treat generated code as an untrusted draft and review authorization, secrets and input handling before launch.

Why AI-generated code repeats the same mistakes

Code assistants optimise for "it runs". Security controls are invisible when everything works, so they are the first thing skipped. The assessments we run on fast-built apps keep finding the same short list:

  1. Authorization enforced only in the browser (hidden buttons instead of server checks)
  2. Database tables without row level security
  3. Secrets in the front-end bundle or committed to the repository
  4. No rate limiting on login, OTP or password reset
  5. SQL built from strings or unvalidated file uploads
  6. Admin routes protected by a front-end role flag
  7. Verbose errors and debug endpoints left on

Item 2 is the one that turns a small project into a data breach.

How Supabase is meant to work

A Supabase project exposes the database through an auto-generated REST API. Browser code uses a public anon key. That key is not a secret; it is designed to be visible in the page. Safety comes from row level security (RLS): policies on each table that decide which rows each user may read or write. With RLS disabled, the anon key can read and often write every row.

Step 1: Find the public key

Open the application's JavaScript in the browser developer tools or view the page source. The project URL and anon key are usually in the bundle (for example in a config object or environment variable prefixed for the browser). This is expected and not the vulnerability.

Step 2: Ask the API for a table

In the lab project, a profiles table stores names, phone numbers and e-mail addresses.

bash
curl -s "https://abcdlabproject.supabase.co/rest/v1/profiles?select=*&limit=3" \
  -H "apikey: <ANON_KEY>" \
  -H "Authorization: Bearer <ANON_KEY>"

With RLS disabled the response is a JSON array of real rows, returned to a caller who is not even logged in:

json
[ { "id": "9f2c...", "full_name": "Demo User", "phone": "+91-98xxxxxx01", "email": "demo1@example.test" } ]

Row counts are available through the Prefer: count=exact header and the Content-Range response header, which tells a tester how many records are exposed without downloading them:

bash
curl -s -I "https://abcdlabproject.supabase.co/rest/v1/profiles?select=id" \
  -H "apikey: <ANON_KEY>" -H "Authorization: Bearer <ANON_KEY>" \
  -H "Prefer: count=exact" | grep -i content-range

Illustrative lab outcome:

CheckResult
Tables reachable with the anon key6 of 9
Rows readable in profiles12,380
Tables that also accepted writes2
Time to find the issueabout 5 minutes

A professional test stops at proving the count and a couple of redacted fields.

Step 3: Fix it with policies

sql
-- Turn protection on
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;

-- Users may read and update only their own row
CREATE POLICY "own profile read"
  ON public.profiles FOR SELECT
  USING (auth.uid() = id);

CREATE POLICY "own profile update"
  ON public.profiles FOR UPDATE
  USING (auth.uid() = id)
  WITH CHECK (auth.uid() = id);

With RLS enabled and no policy, access is denied by default, which is the safe starting point. Then:

  • Keep the service_role key on the server only, never in the browser.
  • Write policies per table and per operation, and test them as two different users.
  • Treat file storage buckets the same way: private by default, signed URLs for downloads.
  • Add RLS tests to your CI so a new table cannot ship unprotected.

Review checklist for any AI-built application

  • Search the front-end bundle and the git history for keys, tokens and connection strings.
  • Confirm every sensitive action is checked on the server, not only hidden in the interface.
  • Attempt each API call without logging in, and again as a different user.
  • Rate limit authentication flows and add lockout or CAPTCHA where appropriate.
  • Run a dependency audit and remove unused packages.
  • Have a human review the generated authorization logic before launch.

AI tools are an excellent accelerator. The mistake is treating generated code as reviewed code. Our secure build and review service exists for exactly this gap.

Frequently asked questions

Is the Supabase anon key a secret?

No. It is designed to be visible in your front end. The service_role key is the secret and must stay on the server only. Safety for the anon key comes from row level security policies.

Can AI-written code be trusted in production?

Treat it as an unreviewed draft. Have a human review access control, secrets handling, input validation and dependencies, and run a penetration test before launch.

How can I check my own project quickly?

In a private window, call each table through the REST API with only the anon key and see whether rows come back. The Supabase dashboard also has an advisor that flags tables without row level security.

Further reading

Need this tested?

Have our senior analysts test your application

Excelon Cyber Solutions runs web application, API and network penetration tests across India, with every finding reproduced and documented before it reaches your report.

WHATSAPP