Securing an application made with an AI app builder
You type instructions into a chat, and an AI app builder writes the web application and hosts it. A Lovable app has a frontend in the browser, server code such as Edge Functions, and a Postgres database whose row level security (RLS) policies control access to data.4 Bolt keeps its data in Supabase,1 v0 generates Next.js code that runs on Vercel,2 and Replit's Agent builds and publishes projects on Replit.8
The user of a browser can read and change everything sent to it, so frontend code cannot make security decisions.4 Where the database is Supabase, the anon key sits in the page by design, and the policies on each table decide what a request made with it returns.6 In generated code, authentication, database queries, secrets and data handling are the parts that still need a person to review them.8
Procedure
- Keep secret keys in the builder's secret store. Each builder separates values that may reach the browser from values that stay on its servers. In Bolt, a value in the
.envfile that the code reads in the browser is sent to every visitor of the published site, while a value saved under the database icon, Secrets, is given only to server functions and never written into the project files.1 In v0, only variables whose names start withNEXT_PUBLIC_reach the browser, so a payment or email key must not carry that prefix.2 Replit keeps the values for a published project under Publishing, Adjust settings, Production app secrets.3 A secret that turns up in frontend code is best treated as already compromised.4Prevents: Exposed credentials in source code repositories - Turn on row level security for every table. Lovable writes basic policies on its own and tells users to review them early; they are listed under More, Database, Manage, Policies.4 In Supabase, a table in an exposed schema without RLS can be read and written by any role holding a grant on it, and on existing projects a new table in
publicreceives every privilege foranonandauthenticated. Policies do not remove those grants, so revoke them and grant back only what the app uses.5
Prevents: Publicly exposed databasealter table public.reports enable row level security; revoke all on table public.reports from anon, authenticated; grant select, insert, update, delete on table public.reports to authenticated; - Tie each policy to the owner of the row. Write one policy per operation (select, insert, update, delete) and compare the caller with an owner column.
auth.uid()returns the signed-in user's ID and null for a request without a session. A policy foranonwithusing (true)lets every visitor read every row the grants allow.5
Prevents: Insecure direct object referencecreate policy "Owners read their reports" on public.reports for select to authenticated using ((select auth.uid()) = user_id); - Check views and server functions. Postgres creates views with the rights of their creator, usually the
postgresuser on Supabase, so a view over a protected table returns rows its policies would hide.5 Server code that uses the service role also skips RLS and has to check permissions itself, because any client can call a server function directly.4
Prevents: Authorizationconst { user } = await supabase.auth.getUser(); if (!user) return new Response("Unauthorized", { status: 401 }); - Test the rules from outside the app. Send the same requests the app sends with no session and with a second test account, and confirm that each returns only what that caller may see. Supabase keeps such checks as pgTAP files in
supabase/tests/and runs them withsupabase test db.5 In the Linkable case below, a request sent without the authorization header passed policies that held for signed-in requests.6Prevents: Insecure direct object reference - Run the builder's scan before each publish. Lovable's Quick scan, under More, Security, runs on every publish and covers database access rules and known vulnerable packages; the Deep scan, which reads the app's own logic, runs only when started.7 Replit has Block publishing of critical vulnerabilities under Publish, Advanced.8 v0 points to DeepSec for checking a chat's changes.2 A clean result does not mean the app is free of risk.7Prevents: Vulnerable dependencies
- Keep internal tools private. An app meant only for a team should have its Lovable project access set to workspace, should not be published to the public web, and should still ask users to sign in.4Prevents: Exposed administration interface
Prompt for a coding agent
List every table this app reads or writes, and for each one show whether row level security is on, which grants anon and authenticated hold, and every policy with its condition. Turn on row level security where it is off, revoke grants the app does not use, and replace any policy that allows everyone or every signed-in user with one per operation that compares auth.uid() with the owner column. Find every secret key in code that runs in the browser or in a variable starting with NEXT_PUBLIC_ or VITE_, and move each one into a server function that reads it from the secret store. Check that every server function verifies the caller before acting. List each change and any table whose owner you could not determine.
Notable incident
On 20 March 2025, a researcher found that changing a query sent by Linkable, a site built with Lovable, returned every row of its users table. A script run the next day against sites listed on Lovable Launched, a directory of Lovable projects, found 303 endpoints in 170 of 1,645 projects with inadequate RLS, from home pages alone. In a recheck of Linkable on 24 May, dropping the authorization header from a request removed all access control, and the researcher inserted a record marked "payment_status": "paid" without paying through Stripe.6 The flaw was published as CVE-2025-48757, classed as CWE-863 Incorrect Authorization with a CVSS 3.1 score of 9.3. Lovable disputes it, on the grounds that each customer is responsible for protecting the data of their own application.9
In SecFlash
A Supabase table that answers a read with no login shows on the Exposure page as SF-EXP-213, next to a secret key in public JavaScript (SF-EXP-301). The Cloud page lists a public table without row level security (SF-CLD-501), a policy that always allows access (SF-CLD-508) and a view that runs with its creator's rights (SF-CLD-506). In the code, the Security page flags a table without RLS as SF-SEC-721, a policy open to everyone as SF-SEC-723 and a service_role key in browser code as SF-SEC-724.
See also
- Row level security
- Privileged key in client-side code
- Publicly exposed database
- Insecure direct object reference
- Securing a Next.js and Supabase application
- Security checklist before launch
- Category: Guides
References
- a b Bolt (n.d.). "Secrets". Bolt support.
- a b c Vercel (updated 20 November 2026). "Security". v0 documentation.
- back Replit (n.d.). "Secrets". Replit documentation.
- a b c d e f Lovable (n.d.). "Security best practices for Lovable apps". Lovable documentation.
- a b c d "Row Level Security". Supabase Docs. Supabase.
- a b c Palmer, M. (2025). "Statement on CVE-2025-48757". mattpalmer.io.
- a b Lovable (n.d.). "Project security view". Lovable documentation.
- a b c Replit (n.d.). "Security". Replit documentation.
- back CVE Program (30 May 2025, updated 21 August 2025). "CVE-2025-48757". cve.org.
External links
- Row Level Security, Supabase documentation