# I built a SaaS with Lovable in one prompt, then audited it like a paying client would

> Source: <https://dev.to/quc_chnhinh_857c0b2af/i-built-a-saas-with-lovable-in-one-prompt-then-audited-it-like-a-paying-client-would-1k0k>
> Published: 2026-11-29 15:15:01+00:00

**Recommendation:** Treat scanner output as leads, not verdicts: manually verify each alert and add per-user quotas plus subscription-status checks before launching an AI-built app.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

Most "AI-built apps are insecure" posts are based on 2025 data: RLS switched off, service-role keys in the browser, unsigned Stripe webhooks. I wanted to know if that's still true, so I tested it.

`/admin` page, and an AI button that drafts payment reminder emails.
Then I ran the same static review I do for clients: scanners first (my own heuristics, semgrep, gitleaks, trufflehog, osv-scanner), then reading every flagged file and walking a 7-area checklist.

`auth.uid()`. The invoice insert/update policies even check that the client row belongs to the same user.`plan` lives in a `subscriptions` table that users can only read; only the server-side webhook writes it.`user_roles` table with no insert policy for users, and the admin list is checked on the server.
My first automated pass scored the app **0/100 with six "critical" alerts. All six were false alarms.** Five came from a rule that expected `stripe.webhooks.constructEvent()` and didn't recognise a hand-written HMAC check, and it fired once per mention of "stripe". The sixth flagged a committed `.env` that only holds public values (Supabase URL and publishable key), which Lovable commits by default.

Meanwhile, the scanner missed both real problems. A scan is a set of leads, not a verdict.

**1. Uncapped AI spend (Medium).** The reminder feature is a `createServerFn` behind auth middleware, which is good. But any signed-in user can call it as often as they like, with no per-user quota. One script on a free account can drain your AI budget.

``` js
export const draftReminder = createServerFn({ method: "POST" })
  .middleware([requireSupabaseAuth])
  .inputValidator(/* invoiceId */)
  .handler(async ({ data, context }) => {
    // ...loads the invoice, then calls the model. No quota check.
  });
```

Fix: an `ai_usage(user_id, day, count)` table, incremented in the same call, refusing over a limit (for example 20/day free, 200/day Pro), plus a spend alert.

**2. Failed payments keep Pro (Medium).** The webhook upgrades on `checkout.session.completed` and downgrades only on `customer.subscription.deleted`. When a card fails, Stripe marks the subscription `past_due`/` unpaid` and retries for days or weeks before deleting it. The whole time the user keeps Pro for free, and your database says they're paying.

Fix: handle `customer.subscription.updated` and keep `plan = 'pro'` only while the status is `active` or `trialing`.

**Smaller ones (Low):**

`pg_advisory_xact_lock` fixes it).
**Final score after manual verification: 81/100: 0 critical, 0 high, 3 medium, 7 low.**

The full, unedited report, with file names and line numbers, is here: [https://chinh-launch-audit.netlify.app/sample-report.html](https://chinh-launch-audit.netlify.app/sample-report.html)

I do fixed-price launch-readiness reviews for AI-built apps. If you're about to launch something on Lovable, Bolt or Cursor and want a second pair of eyes, I'm doing a few free quick looks this week (read-only repo access, the 2 biggest risks by email, no call): [https://chinh-launch-audit.netlify.app/intake.html?plan=quick](https://chinh-launch-audit.netlify.app/intake.html?plan=quick)

*I used AI tools (Claude) to help run the review and draft this post; every finding was verified by reading the code.*
