Shipping secure
AI-generated code
For anyone shipping apps built with AI tools.
How an app works
Front end
Website or phone app. Anyone can read it.
Back end
Your server. Decides who can do what.
Database
Every user's data, stored together.
Services
Payments, AI, email. Each needs a key.
You log in on your phone → the server checks you → reads the database → calls services with its keys.
"It works" is not "it's safe"
Sam builds an expense tracker with AI in an afternoon.
It works ✓
Alice signs up, adds a £42 lunch and sees her dashboard. Every button works.
It leaks ✗
Bob changes one word in the web address and sees Alice's spending.
Safe asks: who else can do this?
When AI-built apps leak
- Mar 2025
Lovable apps: 170 apps with no database rules. Strangers could read user data. CVE
- Jul 2025
Base44: anyone could join private company apps using the ID in the address bar. Wiz
- Jul 2025
Tea: open storage leaked 72,000 photos, including 13,000 IDs. The Record
- Jan 2026
Moltbook: key in the browser, no rules. 1.5M API tokens exposed. Wiz
- Feb 2026
Lovable: public projects' code and AI chats readable for 11 weeks. Lovable
When agents and platforms go wrong
- Jul 2025
Replit: an AI agent deleted a live company database during a code freeze. Fortune
- Aug 2025
Nx: a poisoned package made victims' own AI tools hunt for secrets. Wiz
- Nov 2025
Shai-Hulud: a worm spread through npm and leaked secrets to 25,000 repos. The Register
- Dec 2025
Antigravity: asked to clear a cache, an agent wiped a whole drive. The Register
- Oct 2026
Railway: attackers reached customers' secret keys. Everyone had to rotate. GitGuardian
How often it happens
Four things to protect
People
Accounts and logins
Data
Anything users wouldn't post publicly
Keys
Passwords your app uses for other services
Money
AI, email and storage cost per use
For each: who can reach it, and what stops everyone else?
1Keys in the browser are public
Keep keys on the server. Give each one limited access, a spend cap and an expiry date.
2Logged in is not allowed
Authentication: who you are. Authorisation: what you may see.
Pick a request.
Developers: take the user from the session, never from the request.
3Your database needs rules
With Supabase or Firebase, the browser talks to the database directly. Rules are the only lock.
-- Supabase Row Level Security alter table expenses enable row level security; create policy "own rows" on expenses for select to authenticated using (auth.uid() = user_id);
| owner | item | £ |
|---|---|---|
| alice | Rent | 380 |
| alice | Lunch | 42 |
| bob | Train | 96 |
| bob | Food | 84 |
Rules are off.
4Anything a user sends can be faked
Text
A name field holding commands for your database.
Files
"invoice.pdf" that is really a script, or 4 GB.
Prices and roles
"price: £0.01" or "role: admin" sent from the browser.
Check it on the server, every time.
5No limits, no ceiling on the bill
Without limits
A bot presses your "summarise with AI" button 50,000 times overnight. You find out from the invoice.
With limits
- Spend caps on AI and email
- Rate limits per person
- Bot checks on sign-up
- Alerts when usage jumps
Set an AI spend limit tonight. It takes two minutes.
6Give AI agents intern access
Test, not live
The agent builds on a copy. Live data stays out of reach.
Check installs
AI invents package names. Attackers register them.
Watch what it reads
Pages and docs can hide instructions for your agent.
Ask: what's the worst it could do with this access?
More to check before launch
- Admin and staging pages behind a login
- Payment webhooks verified
- Debug mode off in production
- File storage private by default
- Reset links expire and work once
- Logs never store keys or passwords
- CORS only your own sites
- Packages kept up to date
How to fix each one: see the links page.
Don't build it yourself. Rent it.
Sign-in
Clerk · Supabase Auth · Firebase · Auth0 · Kinde
Database rules
Secret keys
Vercel · Railway · Cloudflare · Doppler · Infisical
Payments
Alerts
Sentry · PostHog · Better Stack · Datadog
Tip: name the service in your prompt. "Use Clerk for sign-in" beats "add login".
Cloudflare features to switch on
Access
Lock admin pages behind a login. Free for 50 users.
AI Gateway
Dollar spend limits and caching for AI calls.
Turnstile
Free bot check. No puzzles.
Rate limiting
Cap hits on login, sign-up and AI.
Bot Fight Mode
One switch for known bad bots.
WAF rules
Block common attacks automatically.
Keep your code safe
Switch on in GitHub
Free scanners
- Trivy ★ 39k
- Gitleaks ★ 30.7k
- TruffleHog ★ 28.9k
- Semgrep ★ 17.5k
- OSV-Scanner ★ 11.4k
- Aikido Safe Chain ★ 1.8k
GitHub stars as of November 2026.
Use AI to review AI
Reviewers
- Codex Security ★ 11.3k
- Claude Code review ★ 6.7k
Security skills
- Cloudflare ★ 60.5k
- Trail of Bits ★ 8k
- Supabase ★ 3k
- Vibe Security ★ 1.2k
- Sentry ★ 1.1k
A finding is a lead, not proof.
Find it. Fix it. Prove it.
Three things to tell your AI
Before you build
"Keep every secret key on the server. Use managed sign-in and database rules."
Before you launch
"Attack this app. Can one user see another's data? Prove each fix with a test."
Before it runs
"Never touch the live database. Ask me before deleting or deploying."
Full copyable prompts are on the links page.
The five-minute check
0 of 12 checked
Before you go
Tonight
Turn on 2FA. Set spend limits. Try to see one account's data from another.
This week
Switch on database rules, push protection and Dependabot.
Every release
Run the five-minute check. Keep AI away from live data.
AI changes who can build software.
Not who is responsible for it.
Scan for every link and the checklist