Short Answer: Is an AI-Generated App Secure by Default?
No. An app built with Lovable, Cursor, or Claude Code is not secure by default, even if it demos perfectly. AI tools routinely leave authorization checks incomplete, database rules too open, secrets in the wrong place, and dependencies unreviewed. The checklist below is the review to run before launch.
Before an AI-generated app handles real users, payments, or personal data, work through this AI-generated code security checklist — identity, database permissions, secrets, APIs, dependencies, input validation, and testing — then test it as an attacker would, not just as its owner.
This guide is that missing review. If you would rather have it done for you, see our security services.
Why AI-Generated Apps Have Specific Risks
- Plausible but incomplete code. The model handles the happy path; permission checks for a second user, an admin, or a logged-out visitor are omitted first.
- Fixes that widen access. When a query fails, the fastest AI fix is often to loosen the rule — a policy allowing everything, a disabled check, a public endpoint. The error disappears; so does the protection.
- Secrets handled casually. Keys end up in frontend code, committed
.envfiles, or prompts and logs. - Dependencies chosen without review, including outdated or similarly named packages — the supply-chain risk in the OWASP Top 10 for LLM Applications.
- AI-specific risks. If your app calls an LLM, you also inherit prompt injection (LLM01), sensitive information disclosure (LLM02), excessive agency (LLM06), and unbounded consumption (LLM10). OWASP notes there is no fool-proof prevention for prompt injection, so limit what the model can reach and do.
- No threat model. “What happens if a signed-in user changes an ID in the URL?” catches the most common serious flaw in AI-built apps.
Our breakdown of the Binance hack and its security lessons shows attackers going for keys and overlooked access paths — not the feature you polished most.
1. Authentication and Authorization
Authentication asks who are you? Authorization asks what may you do? AI-generated apps usually implement the first and improvise the second.
Authentication checklist
- [ ] Email confirmation on, if your app trusts an email address as identity
- [ ] Password reset and magic links expire and stop working after use
- [ ] Multi-factor authentication available — and required for admin accounts
- [ ] Sessions expire, refresh safely, and are revoked on logout and password change
- [ ] OAuth redirect URLs list only your production domains — no localhost or preview URLs left live
- [ ] Login endpoints rate-limited against automated guessing
Authorization checklist
Broken object-level authorization is API1:2023 in the OWASP API Security Top 10 for a reason: it is everywhere, and AI tools reproduce it faithfully.
- [ ] Every API route and server function checks the caller’s role on the server — never only by hiding a button in the UI
- [ ] Every lookup is scoped to the caller (
owner_id = current user), not justid = the ID in the request - [ ] Admin routes deny by default and allow named roles only
- [ ] Two-account test passed: Account A cannot read, edit, or delete Account B’s records by changing an ID
Remediation example. A Lovable-built booking app let any signed-in user view any invoice by incrementing the invoice number — invisible in normal use, because the UI never showed other invoices. Fix: scope the invoice query to the signed-in user on the server, and add a second-account test that must receive a 403. Under a day’s work removed a full billing-data exposure.
2. Exposed Secrets: Assume the Frontend Is Public
Everything shipped to the browser is public: bundled JavaScript, client-side environment variables, and anything in a public repository. Lovable’s security best practices make the same point: frontend code can be inspected and bypassed, so it must never hold secrets or make security decisions.
- [ ] No payment secret keys, database passwords, or service-role keys in frontend code or client variables
- [ ] Secrets live in the platform secret store or server-side environment; server code calls third-party APIs for the user
- [ ]
.envfiles are in.gitignore— and you checked repository history, because deleting a key from the latest commit does not remove it from history - [ ] Any key ever committed, shipped to a browser, or pasted into a public prompt is rotated, not just removed
- [ ] Each service gets its own scoped key, so one leak does not become every system
- [ ] Secret scanning is enabled on your repository
Remediation example. A Cursor-built dashboard shipped a payment secret key in a client-side variable because the AI placed all API calls in the frontend. Moving that call into a server function and rotating the key closed the hole — with no visible change to the app, which is why this flaw survives demos.
Guardrail your coding tools too: use ignore files (such as .cursorignore) and permissions so the agent cannot read credential files. Cursor documents this in its Agent Security documentation.
3. Database Permissions and Row-Level Security
This is the highest-impact section for Lovable apps and any app where the browser talks directly to the database — most commonly Supabase. There, the public (anon/publishable) key is meant to be visible. What protects your data is Row-Level Security (RLS): Postgres rules deciding which rows each user can read or write. Supabase’s Row Level Security documentation is explicit: enable RLS on every exposed table, and set grants and policies deliberately.
- [ ] RLS enabled on every exposed table — including logs, settings, and “internal” tables, which get RLS with no public policies at all
- [ ] Separate policies for select, insert, update, and delete; a read policy does not protect writes
- [ ] Policies compare the row owner to the authenticated user (in Supabase,
auth.uid()), and inserts useWITH CHECKso users cannot create rows for someone else - [ ] No policy uses
USING (true)for user data — that pattern usually appears as a quick fix for a permission error; treat finding one as a finding - [ ] Views and elevated functions do not bypass your rules, and storage buckets have their own policies
- [ ] The service-role/secret key, which bypasses RLS, appears only in server code you control — and that code checks permissions itself
- [ ] Your platform’s security advisor is clear of RLS warnings — Supabase’s production checklist lists RLS on all tables as a launch requirement
Two-minute test. In a private browser window, logged out, request one of your tables through the public API using only the public key (a developer can do this with one curl command). If real user rows come back, that table is effectively public. Fix it before anything else here.
The principle applies beyond Supabase: write down, table by table, who can read and write what, then test the negative cases. For apps that have outgrown a generated backend, a properly scoped backend is part of our custom web apps work.
4. Dependency and Supply-Chain Vulnerabilities
AI tools install packages quickly and explain them confidently. Neither is evidence a package is safe, current, or even the one you intended.
- [ ] Run your package audit (for example,
npm audit); resolve critical and high findings before launch, or document why each does not apply - [ ] Enable automated dependency updates and alerts. GitHub’s Dependabot documentation covers configuration, including private registries; pair it with secret scanning
- [ ] Commit the lockfile; review new packages in pull requests, confirm each is maintained and canonical (not a similarly named imitation), and remove unused packages the generator added
- [ ] Repeat the audit on a schedule. The NIST Secure Software Development Framework (SP 800-218) treats responding to vulnerabilities as a continuing practice, not a launch event
As our PHP2Shell write-up shows, once a serious flaw is public, exploitation begins quickly — the teams that fare best already know what they run.
5. API Security
Test generated Edge Functions, server routes, and backends against the authorization-first mindset of the OWASP API Top 10:
| Risk area | Check | Typical AI-generated flaw |
|---|---|---|
| Object-level authorization (API1) | Every object lookup scoped to the caller | Fetching any record by ID alone |
| Authentication (API2) | Tokens validated on every route | A route added later with no auth check |
| Property-level authorization (API3) | Responses expose only needed fields; clients cannot set protected fields | Returning the full user object; accepting is_admin from the client |
| Resource consumption (API4) | Rate, payload, and timeout limits | Unbounded AI or email endpoints anyone can call repeatedly |
| Function-level authorization (API5) | Admin functions require an admin role, server-side | Admin endpoint “protected” by an unlinked URL |
| SSRF (API7) | Server-side URL fetching uses an allowlist | A “fetch this URL” feature that can reach internal addresses |
| Misconfiguration (API8) | CORS restricted to your domains; errors leak no stack traces or SQL | Wildcard CORS on authenticated endpoints |
If your app calls third-party or LLM APIs, add two rules: validate and bound everything those APIs return before using it (API10, unsafe consumption), and put per-user quotas and spend caps on AI endpoints so one account cannot run up your bill — unbounded consumption in product form. Adding AI features to an existing product? Our AI integrations work starts from exactly these controls.
6. Input Validation and Output Handling
AI-generated code tends to trust input, because trusting input makes the demo shorter. Reverse that assumption:
- [ ] Validate type, length, range, and allowed values on the server for every field; client validation is user experience only
- [ ] Use parameterized queries or safe ORM methods; never build SQL or shell commands by concatenating user input
- [ ] Render user content as text by default; if rich text is required, sanitize it with a maintained library — improper output handling is how stored cross-site scripting enters AI-built apps
- [ ] Validate uploads by type and size, store them outside executable paths, and serve them with safe content types
- [ ] Treat AI-generated output as untrusted input: validate it before it reaches the browser, a query, an email, or another API
- [ ] Users see generic error messages; detailed errors go to your logs only
7. Security Testing: Test Like an Outsider
Minimum pre-launch set:
- Two-account test. With Account A signed in, replay Account B’s view, edit, delete, and export requests. Every one must fail.
- Logged-out test. Repeat key API calls with no session. No private data may appear.
- Role test. Call every admin endpoint as a regular user. Expect 403s throughout.
- Secrets scan. Scan the repository and the built frontend bundle for key patterns and your own key prefixes.
- Dependency audit. Fix or document every critical/high item.
- Abuse test. Oversized payloads, malformed JSON, script tags in every text field, rapid repeated login and AI calls. The app should reject, sanitize, or throttle — never error open.
- Restore test. Restore your latest backup into a separate environment. A backup never restored is a hope, not a backup.
8. Performance and Load Testing
An app that falls over under modest load is an availability incident waiting for a trigger. Performance is part of production readiness.
- [ ] Load-test top flows (sign-in, dashboard, search, checkout/booking) at several times expected peak, not at average
- [ ] Hunt the classic generated-code patterns: a query per row (N+1), list endpoints with no pagination, full-size images, AI calls made synchronously where a queue belongs
- [ ] Set API timeouts and limits so a slow dependency degrades one feature, not the whole app
- [ ] Confirm indexes and caching for your heaviest reads before buying a bigger server
Fix queries and payloads first — the focus of our performance optimization service — and only then scale infrastructure.
9. Backup and Recovery
- [ ] Automatic database backups, stored separately from the production account, with file storage and critical configuration (including encryption keys and secret values) covered too — a database alone does not rebuild the app
- [ ] At least one full restore performed and timed, with steps written down: that note is your recovery plan
- [ ] Backup access restricted (backup access is production access), and soft-delete or retention windows guard against accidents and compromised accounts
10. Production Readiness Checklist
Do not launch with real customer data until every box is checked, or consciously accepted in writing.
- [ ] Authentication hardened; MFA on admin/owner accounts across app, database, hosting, repository, and registrar
- [ ] Authorization passed the two-account and role tests
- [ ] RLS/database permissions enabled, reviewed, advisor warnings cleared
- [ ] No secrets in frontend, repository, or history; exposed keys rotated
- [ ] Dependency audit clean or documented; automated updates and secret scanning on
- [ ] API rate limits, CORS, error handling, and AI quotas configured
- [ ] Server-side input validation and safe output handling in place
- [ ] Security test set passed and saved for regression use
- [ ] Load test passed at several times expected peak
- [ ] Backup restored successfully in a test environment
- [ ] Logging on for auth events, permission failures, and errors — with alerts someone actually reviews
- [ ] Privacy basics in place, and a named person owns updates and incident response after launch
When to Hire a Professional
Hire a professional review when any of these are true (otherwise, work the checklist yourself):
- The app handles payments, health, financial, children’s, or other sensitive personal data
- Real customers already use it, or a business depends on it for revenue
- You found a
USING (true)policy, a secret in the frontend, or a failed two-account test — and fixing one issue raises the question of what else is there - An AI tool “fixed” a security error you did not fully understand
- A client, partner, or insurer asks how the app was reviewed, and you need an answer you can stand behind
A professional review is not a rewrite: it is a focused pass over the areas above, plus a written fix list ordered by risk. That is the work our security team does for Lovable, Cursor, and Claude Code builds.
Frequently Asked Questions About the AI-Generated Code Security Checklist
Is the Supabase anon key a secret?
No. It is designed to be public and identifies your project. Your protection is RLS plus correct grants. The service-role/secret key — which bypasses RLS — must never reach the browser.
My AI tool has a built-in security scan. Is that enough?
It is a good first pass — Lovable, for example, runs publish-time checks and surfaces Supabase Security Advisor findings — but its documentation still tells you to review RLS, secrets, and authentication yourself. A scanner catches known patterns; the two-account test catches your app’s logic. Use both.
Can I ask the AI to fix the issues it created?
Often, yes — with supervision. Give it one finding at a time, require the restrictive fix (“scope this policy to auth.uid()“, not “make the error go away”), and re-run your negative tests after each change. A first pass on a small app typically takes half a day to a day, including common fixes.
Sources
- OWASP GenAI Security Project — Top 10 for LLM Applications
- OWASP — API Security Top 10 2023
- NIST — Secure Software Development Framework (SP 800-218)
- Lovable Documentation — Security best practices for Lovable apps
- Cursor Documentation — Agent Security
- Supabase Documentation — Row Level Security
- Supabase Documentation — Production Checklist
- GitHub Documentation — Dependabot / dependency security
Frameworks checked November 2026 — confirm details on the linked official pages.
Get a Security Review Before You Scale
If your AI-built app is about to take on real users, a focused review now is far cheaper than an incident later. Tell us what you built and what data it holds — no obligation to hire us for the fixes.
