Ninja Builder Sign in Get started

Security Checklist for AI-Built Apps: What to Check Before Launch

Six checks that catch the usual leaks in AI-written apps, written so you can run them without reading code.

By Ninja Builder team5 min read
Title card reading Security checklist for an AI-built app

Key takeaways

  • Secrets belong in environment variables on your computer and host, never in Git or anything a browser loads.
  • A secret that was ever committed or published must be revoked and replaced, not just deleted.
  • Database access rules, such as Supabase row level security on every table, are the most common gap in AI-built apps.
  • Check sign-in on the server for every private page and API route, and test with two accounts.
  • Turn off debug mode, commit a lockfile and run a dependency audit before launch.

Before you put an AI-built app online, check six things: no secret keys in your code or Git history, your .env file kept out of Git and out of the published folder, access rules on every database table, sign-in that protects every private page and API route, no debug mode in production, and no packages with known security holes. Most leaks from AI-built apps come from one of these, and each takes minutes to check.

AI coding agents write working code quickly, but they optimise for "it runs". They will paste a key into a file to get a demo going, or leave a database open because that made the error go away. None of that shows when you click around. This checklist is written so you can run it even if you do not read code: each item says what to look for and what to ask your agent.

1. Secrets and API keys

A secret is anything that grants access: API keys, database passwords, payment provider keys, tokens for email or SMS services. The rule is simple: secrets live in environment variables on your computer and on your host, never in a file that ends up in Git or in the browser.

Three columns: in the browser only publishable keys protected by row level security; on the server or host, secret keys and database URLs; never in Git, page source, screenshots or chat messages
Every key belongs in exactly one of these places.
  • Search the project for words like key, secret, token, password and long random-looking strings.
  • Open your published site, view the page source and the loaded JavaScript, and search there too. Anything a browser downloads is public.
  • Some keys are designed to be public. Supabase's publishable key (formerly the anon key) is meant for browsers, but only reaches what your row level security rules allow. Its secret key (formerly service_role) bypasses those rules and must never reach a browser. Supabase's API keys guide lists which is which.
  • If a secret was ever committed to Git or published, deleting it from the file is not enough: it stays in the history. Revoke it in the provider's dashboard and create a new one.

2. The .env file and .gitignore

Most projects keep secrets in a .env file during development. That file must be listed in .gitignore so it is never committed, and it must not sit inside the folder your host publishes. Share a .env.example with the variable names and empty values instead.

# .gitignore
.env
.env.*
!.env.example
node_modules/
dist/

Check that it worked with git log --all -- .env. If that prints anything, the file was committed at some point; treat every key in it as leaked. GitHub's secret scanning and push protection can catch many known key formats when you push, but do not rely on it as your only check.

Git client showing the commit history of a project, used to review what was committed before publishing
Look through what is actually committed before you publish, not just what is in the folder.

3. Database access rules

This is the most common serious hole in AI-built apps. If your app talks to the database straight from the browser (common with Supabase and Firebase), the database's own rules are the only thing standing between a visitor and every row.

  • Supabase: row level security on every table, with policies that say who can read, insert, update and delete. Enabling it with no policies blocks access through the API until you add them, which is the safe default.
  • Firebase: security rules that do not allow open reads or writes outside early testing.
  • Your own server: every query checks who is asking, and queries use parameters rather than gluing user input into SQL.

Test it, do not just read it. Sign in as user A, copy a record's ID, sign in as user B and try to load that record. Then try while signed out.

4. Sign-in and permissions

  • Every private page and every API route checks the user on the server. Hiding a button in the interface is not protection.
  • Admin actions check for an admin role, not just "signed in".
  • Use a proven sign-in service (Supabase Auth, Firebase Auth, Clerk, Auth0 or your framework's library) rather than code the agent wrote from scratch.
  • Password reset and email change flows confirm by email.
  • Forms and sign-in have rate limits, so nobody can try ten thousand passwords.

5. Debug mode, errors and CORS

Agents often turn on debug mode or verbose errors while fixing a problem and forget to turn them off. In production, error pages should show a short message, not stack traces, file paths or environment values. Check your framework's production setting (for example DEBUG=False in Django or NODE_ENV=production in Node). Also look for CORS set to * on an API that uses cookies or keys: it lets any website call your API from a visitor's browser.

6. Dependencies

AI agents add packages freely, and occasionally suggest a package name that does not exist or is a lookalike. Before launch:

  1. Commit a lockfile (package-lock.json, pnpm-lock.yaml or similar) so installs are repeatable.
  2. Run npm audit (or pip-audit for Python) and fix high and critical findings.
  3. Check any package you do not recognise: is it the official one, maintained, and widely used?
  4. Remove packages the app no longer uses.
Built-in Git Client for AI Coding: Commit and Push From Ninja Builder

The quick checklist

CheckPass when
SecretsNone in code, Git history or anything the browser loads
.envIgnored by Git, not in the published folder, never committed
DatabaseAccess rules on every table, tested with two accounts and signed out
Sign-inEvery private page and route checked on the server, rate limits on
Debug and CORSDebug off, short error pages, no open CORS on private APIs
DependenciesLockfile committed, audit clean of high and critical issues

This list catches the common mistakes; it is not a full security audit. If your app handles payments, health data or anything regulated, have a professional review it.

Automating the check

If you build with Ninja Builder, its security check runs these checks on your computer before anything is published: keys and passwords in files, a database link with its password in it, a .env saved in Git or in the publish folder, databases or storage anyone can open, SQL built from visitor input, debug mode and packages with known holes. Findings are grouped as Critical, Warning and Info, each with the file, the line and the fix, and /deploy will not publish while a Critical finding is open unless you say so. It is part of a desktop app that runs your own AI account with a team of agents; see features and the playbooks docs, or download Ninja Builder and try it free for 14 days.

Frequently asked questions

Is it safe to put my Supabase key in front-end code?

Only the publishable key (formerly called anon), and only with row level security enabled on every table. The secret key (formerly service_role) bypasses those rules and must never be in front-end code or Git.

I committed my .env file to GitHub. What should I do?

Revoke every key in it from each provider dashboard and create new ones, then add .env to .gitignore. Deleting the file in a new commit does not remove it from the history.

Do AI coding tools write insecure code?

They can. Agents tend to aim for code that runs, and may hard-code keys, leave databases open or skip permission checks to make an error go away. Reviewing those areas before launch catches most problems.

Is this checklist enough for a production app?

It covers the most common mistakes in AI-built apps. Apps that handle payments, health data or other regulated information should also get a professional security review.

Keep reading