Security audit prompts for AI-built apps: 5 checks to run before launch
By Arif Khan, AIVolve LLC · Updated November 20, 2026
"Can I just ask my AI to do a security audit before I launch?"
Short answer: yes, and it's a good habit, but ask for specific checks rather than "is my app secure?" A vague prompt gets a vague "looks good." The five checks below catch the problems we see most in AI-built apps: one user seeing another user's data, secret keys in the browser, paid features that unlock without a real payment, database views that skip your security rules, and admin actions the server never checks. Each prompt asks the AI to report first and change nothing, so you can read the findings before anything is touched. Then confirm the important ones yourself, because an AI can't tell who is supposed to see what in your app unless you tell it.
Before you start (2 minutes)
- Save a restore point. Commit or export your project (in Lovable, connect GitHub or note the current version) so you can roll back if a fix goes wrong.
- Make two test accounts, User A and User B, with a little fake data in each. You'll need them for check 1.
- Run the built-in scan first if your builder has one. Lovable's Quick scan runs every time you publish, and you can run the Deep scan from the project's Security view. Lovable's docs say the scans "cannot guarantee complete security", so treat them as a start, not the finish.
- Use plan or chat mode for the prompts below (in Lovable, Chat mode; in Cursor or Claude Code, ask for a plan only), so the AI reads and reports without editing.
Check 1: Can User B see User A's data?
This is the most important check, and the one an AI can't do for you without help, because only you know which data is private.
Prompt (paste as-is):
Security review, read-only. Do not change any code or database settings. List every database table and view this app reads or writes. For each one, tell me: 1. Is Row Level Security enabled? 2. Which policies exist, for which operations (select, insert, update, delete), and for which roles (anon, authenticated)? 3. Does any policy use "true" or no condition, so every user or every visitor can see every row? 4. Which column ties a row to its owner (for example user_id or org_id), and does each policy compare it to auth.uid()? 5. Does any policy read the user's role or plan from user_metadata? Show the results as a table, then list the riskiest findings first. Don't fix anything yet.
Then test it yourself: log in as User B and try to open User A's pages, for example by changing an ID in the address bar (/orders/123 → /orders/124). If you see A's data, that table needs a policy fix before launch.
Why the last question matters: Supabase's docs warn that user_metadata "can be modified by authenticated end users", so it's not a safe place to keep roles like "admin" or "paid". Store those in app_metadata or your own table. Step-by-step: Supabase columns users should never edit.
Check 2: Are there secret keys in the browser?
Anything in your front-end code can be read by anyone who opens the page. Lovable's own guidance is that frontend code "should never make security decisions" and secrets in it "should be considered compromised."
Prompt:
Security review, read-only. Do not change anything. Search the frontend code, environment files and build config for secrets that would ship to the browser: - Supabase service_role or secret keys (sb_secret_...), Stripe secret keys (sk_live_, sk_test_), webhook secrets (whsec_), and any other API keys - any variable starting with VITE_, NEXT_PUBLIC_ or REACT_APP_ that holds a secret For each one, give the file and line, what the key is for, and whether it is safe to be public. The Supabase anon or publishable key is expected in the browser; flag it only if it is used together with tables that have RLS turned off.
Then check the live site: open it, then DevTools → Sources → search all files for service_role, sb_secret_ and sk_live. Both legacy Supabase keys start with eyJ, so if you find one, compare it with Settings > API Keys in your Supabase dashboard to see which one it is.
If a secret key is there: treat it as leaked. Supabase's rotation guide says to fix how it leaked first, or the new key will leak the same way. Then create a new secret key and move your server code to it. If the leaked key is the legacy service_role key, switch your browser code from anon to a publishable key before you deactivate the legacy keys, because they turn off together.
Check 3: Can someone unlock paid features without paying?
A common pattern in AI-built apps is a "Thank you" page that marks the user as paid. Stripe's docs explain why that isn't enough: you "can't rely on triggering fulfillment only from your checkout landing page, because it's not guaranteed customers visit that page." The same goes the other way. If the browser can set is_paid = true, so can anyone with DevTools.
Prompt:
Security review, read-only. Do not change anything. Trace how this app decides that a user has paid or has an active plan. 1. Where is the "paid" or "plan" value stored, and which code writes it? 2. Can the browser write that value directly (for example a Supabase update from the frontend), or only server code? 3. Is there a Stripe webhook handler? Does it verify the Stripe signature using the raw request body and the webhook signing secret before trusting the event? 4. Does any code mark a user as paid based only on the success page or a URL parameter? 5. What happens when a subscription is canceled or a payment fails? Does the app ever remove access? List the gaps, riskiest first.
Then test it yourself: with a test account, open the success page URL directly without paying. If the paid feature unlocks, the unlock belongs in the webhook instead. Our Stripe webhooks guide covers the test-vs-live setup.
Check 4: Do any database views skip your security rules?
This one surprises a lot of people. Supabase's docs say: "Views bypass RLS by default because they are usually created with the postgres user." A view over a protected table can hand every row to anyone who can query it, even when the table's own policies are perfect. AI tools often create views for dashboards and reports, so it's worth checking.
Prompt:
Security review, read-only. Do not change anything. List every view in the public schema (and any other schema the app's API exposes). For each view: which tables does it read, are those tables protected by RLS, and was the view created with security_invoker = true? Also list any database functions marked SECURITY DEFINER that the anon or authenticated roles can execute, and what each one reads or changes.
The fix (Postgres 15 and above): make the view follow the RLS policies of its tables:
alter view public.your_view_name set (security_invoker = true);
New views can be created with create view ... with (security_invoker = true) as .... On older Postgres versions, Supabase suggests revoking access to the view from anon and authenticated, or moving it to a schema the API doesn't expose. In the Supabase dashboard, Security Advisor flags these as "Security Definer View". Here's the full walkthrough, including revoking anon delete and truncate.
After the change, run check 1 again: a view that used to show everything may now show only the logged-in user's rows. That's the point, but make sure your dashboard still works for the right people.
Check 5: Does the server check who is asking?
Edge Functions, API routes and server functions often run with powerful keys. If one takes a user_id from the request and trusts it, anyone can call it with someone else's ID.
Prompt:
Security review, read-only. Do not change anything. List every Edge Function, API route or server function. For each one: 1. Does it require a logged-in user, and how does it verify the user (from the verified session or JWT, not from the request body)? 2. Does it use the Supabase service_role or secret key? If so, does it still check that the caller is allowed to touch this specific record? 3. Does it take a user_id, org_id or role from the request and trust it? 4. For admin-only actions, where is the admin check, on the server or only in the UI?
How to read the results
- Ask for proof, not reassurance. If the AI says "RLS is enabled on all tables," ask it to show the policy for your most private table, then run the two-account test anyway.
- Fix one finding at a time. Ask for the smallest change that fixes that issue, review it, and test again. A big "fix everything" pass can break login or payments.
- Re-run after big changes. Do this especially after changes to login, the database or payments, and when your AI tool adds new tables. Since Oct 30, 2026, new Supabase tables also need grants. See the permission denied fix.
- Know when to ask a person. If your app handles other people's money, health or personal records, or several companies' data, a developer review before launch is worth it. Lovable's docs suggest "an additional professional security review" for apps like these. A formal penetration test or compliance audit is a job for a specialist security firm.
FAQ
Can an AI do a security audit of my app?+
It can do a useful first pass if you ask specific questions, like which tables have RLS off, where secrets live and how payments are confirmed. It can't know which users should see which data unless you tell it, so confirm the important findings yourself with a two-account test.
What is the best prompt for a security review in Lovable?+
Ask for a read-only review of one area at a time: database policies, secrets in frontend code, payment checks, views and server functions. Ask it to list findings riskiest first and change nothing, then fix one finding at a time.
Do Supabase views bypass Row Level Security?+
By default, yes. Supabase's docs say views bypass RLS because they are usually created by the postgres user. On Postgres 15 and above, set security_invoker = true on the view so it follows the policies of its tables.
Is it safe to unlock paid features from the Stripe success page?+
No. Stripe's docs say you can't rely on the checkout landing page alone, because customers don't always reach it. Confirm the payment in a webhook that verifies Stripe's signature, and only let server code mark a user as paid.
Want a second pair of eyes?
Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day. Get a free X-ray →
Related: Is my Lovable app secure? The 15-minute check · Supabase RLS for AI-built apps: the 10-minute check · Supabase anon key vs service_role key · Stripe works in test mode but not live · Supabase view bypasses RLS · Claude Code "don't ask again" leaked your keys? · Supabase columns users should never edit · Make cron jobs and webhook endpoints fail closed · Is my Replit app ready for real users?
Written by Arif Khan, AIVolve LLC. VibeCoderSOS isn't affiliated with Lovable, Bolt, Cursor or Supabase. Settings names were checked against Lovable's, Supabase's and Stripe's documentation on October 30, 2026, and may change.
Need help?
Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day.
Get a free X-ray →