Patient chart
Billirubin
Invoicing for freelancers. Fictional app, realistic findings.
- Stack
- Next.js App Router, TypeScript, Supabase, Stripe
- Built with
- Lovable, then Cursor
- Size
- 8,900 lines
- Review
- Launch Review
- Diagnosis
- Not ready for real users yet. Treat the three problems under "Treat today" first.
Diagnosis
Slop Medic
- Patient
- Billirubin (fictional)
- Size
- 8,900 lines
Risk score61
| Problem | Urgency |
|---|---|
| Open database tables 3 | Critical |
| Fakeable payment webhooks 1 | Critical |
| Unchecked user input 3 | High |
| Exposed secret keys 0 | Clear |
| any types 143 | Medium |
| Swallowed errors 12 | Medium |
| Copy-pasted code 14% | Low |
| Code covered by tests 6% | Medium |
Numbers count places in the code, not findings: 3 open tables are one finding. Risk score: 0 is no known risk, 100 is not safe to use.
Red: fix these first.
How this review was made
- Your scan
- Lovable’s quick scan, pasted at booking: 4 findings. Each one checked in the code and on the live app; see "What your scan found".
- Software
- Automated checks for leaked keys, vulnerable and made-up packages, type errors and common security patterns, plus an AI search over the whole codebase: 38 candidates for me to look at.
- Human
- I read the app first: what it is for, how invoices and payments flow, the routes and the database rules. Then every candidate checked in the code: 9 were false alarms and removed. 3 problems the tools missed were added, including the Stripe webhook.
- Proof
- Both critical problems confirmed on the live app with two test accounts. No real user data was changed.
What your scan found
Lovable’s quick scan, pasted at booking. Each item checked in the code and on the live app. Anything listed here does not count toward the refund guarantee.
Your scanTable invoices: policy allows access to all rows (using (true))
My verdictConfirmed, critical: problem 1 below. The scan could not know that invoice_items and customers have the same hole; the fix covers all three.
Your scanTable products: row level security disabled
My verdictReal, but low for Billirubin: the table holds your public price list and nothing personal. Turn it on when you next touch the migrations; no rush.
Your scan2 packages with known vulnerabilities
My verdictReal but not urgent: both run only in your build step and never see user input. Update them when convenient.
Your scanStorage bucket logos is public
My verdictFine as it is: it holds company logos that appear on public invoice pages anyway.
Not on the scan’s list: the Stripe webhook (problem 2), the invoice form (problem 3) and the swallowed payment error (problem 4). Those are what a quick scan does not look for in an invoicing app.
Summary
Billirubin works, and the invoicing logic itself is better than most AI-built apps I see. The problems are in what surrounds it.
Three issues need fixing before you onboard more customers: any signed-in user can read and edit every other customer’s invoices, the Stripe webhook can be faked to mark any invoice as paid and the create-invoice action accepts whatever the browser sends. All three are small, contained fixes. Everything else can wait for a quiet week.
Treat today
Any signed-in user can read and edit every invoice
supabase/migrations/0004_invoices.sql:18Your own scan reported this tooThe select and update policies on invoices allow every row. Your publishable key (the anon key, in older projects) is public by design, so anyone with an account can list all invoices of all customers from the browser console, including names, addresses and amounts.
Proven on the live app: I signed up two test accounts. From the browser console, account B listed every invoice of account A, including the customer address. Screenshot in the full report.
create policy "Invoices are readable"
on invoices for select to authenticated
Removed: using (true);
Added: using (auth.uid() = owner_id);
Treatment: Restrict select, update and delete to the owner. Make inserts and updates check that the new row belongs to the user too. Then repeat for invoice_items and customers. Takes about an hour including a test with two accounts.
In supabase/migrations, add a new migration that replaces the policies on invoices, invoice_items and customers: select, update and delete only allow rows where owner_id = auth.uid() (using), and insert and update only accept rows where owner_id = auth.uid() (with check), so nobody can create or move a row into another user’s account. For invoice_items, check ownership through the parent invoice. Do not change any application code. List every policy you changed.
Signed
The Stripe webhook believes anyone
app/api/webhooks/stripe/route.ts:4The webhook parses the request body without checking Stripe’s signature. Anyone who finds the URL can send a fake checkout.session.completed event and mark any invoice as paid.
Proven on the live app: A hand-written request to the webhook URL marked one of my test invoices as paid. No money changed hands. Request and screenshot in the full report.
export async function POST(req: Request) {
Removed: const event = await req.json()
Added: const signature = req.headers.get('stripe-signature') ?? ''
Added: const event = stripe.webhooks.constructEvent(
Added: await req.text(), signature, env.STRIPE_WEBHOOK_SECRET
Added: )
if (event.type === 'checkout.session.completed') {
Treatment: Verify the signature with the raw body and your webhook secret, and return 400 when it fails.
In app/api/webhooks/stripe/route.ts, verify the Stripe signature before handling any event: read the raw body with req.text(), call stripe.webhooks.constructEvent with the stripe-signature header and STRIPE_WEBHOOK_SECRET. Return a 400 response if verification throws. Keep the existing event handling unchanged.
Signed
Creating an invoice trusts the whole request
app/invoices/actions.ts:12The server action inserts whatever object the form sends. A user can set owner_id to someone else, or create an invoice that is already marked as paid.
'use server'
Removed: export async function createInvoice(data: any) {
Removed: return supabase.from('invoices').insert(data)
Added: export async function createInvoice(input: unknown) {
Added: const { customerId, lines } = InvoiceInput.parse(input)
Added: const user = await requireUser()
Added: return supabase.from('invoices').insert({
Added: customer_id: customerId, lines, owner_id: user.id, status: 'draft'
Added: })
}
Treatment: Validate the input with a schema and set owner and status on the server. The same pattern applies to updateInvoice and createCustomer.
In app/invoices/actions.ts, change createInvoice to accept unknown, parse it with a zod schema that only allows customerId and lines, get the user from the session and insert owner_id = user.id and status = 'draft' on the server. Apply the same pattern to updateInvoice and createCustomer. Add the schemas to lib/validation.ts.
Signed
Treat when you can
The dashboard runs one query per customer
app/dashboard/page.tsx:31Totals are loaded one customer at a time, so an account with 200 customers makes 201 database calls on every page load. It feels fine today and gets slower with every customer. Replace it with one grouped query.
Strict mode is off and any is everywhere
tsconfig.json:7strict is false and there are 143 uses of any, most at the boundary where data comes in. TypeScript is not checking the parts most likely to break. Turn strict on and fix the types at the edges first.
A deprecated auth package
package.json@supabase/auth-helpers-nextjs is deprecated and no longer supported. Fixes and security updates go to its replacement, @supabase/ssr.
Almost nothing is tested
tests/invoice-totals.test.tsAbout 6% of the code runs under a test, all of it in the invoice totals. The access rules, the webhook and the forms above have none, so a later AI session can undo a fix and nobody notices. Add one test per fix from this report, starting with the two-account check.
Three date libraries
package.jsonmoment, date-fns and dayjs are all installed and all used. Keep date-fns, remove the other two and about 80 KB of compressed JavaScript from every page.
Healthy
- Sign-in with Supabase Auth is set up correctly, including email confirmation and session refresh.
- Stripe Checkout itself is integrated the standard way. Only the webhook needs work.
- Tax and rounding in the invoice totals are correct and covered by the few tests that do exist.
- The component structure is consistent enough that the fixes above will not ripple through the UI.
Discharge instructions for your AI
Paste these into your Lovable knowledge, Cursor rules or CLAUDE.md so the next session doesn’t bring the same problems back.
- Every server action and route handler validates its input with a schema from lib/validation.ts.
- Never use the secret key (the service role key, in older projects) outside supabase/functions.
- Every new table gets row level security and an owner policy in the same migration.
- No new dependencies without asking first.After the report
What comes next, and what you can ask for.
- One round of questions by email: send them all within 7 days of the report.
- A free follow-up check within 30 days, once the problems under Treat today are fixed.
- Rather I did the fixing? The three problems under Treat today as a fix list: $199, $100 and $199, pull requests you merge, re-checked on your live app, with the start date before you pay. Reply with the ones you want.
- Another look later: Aftercare, $249 for one check of what your AI changed, with who-sees-what and payments re-tested. Paid once, never a subscription.
Signed statement
Statement of review: Billirubin
I, Michel Wehrli, reviewed Billirubin for Billirubin’s founder (fictional). I read the app myself; software and AI helped me search. Every finding below is one I checked.
- Code reviewed
- github.com/billirubin-app/billirubin (private), commit
4e1c9a7of 21 Oct 2026 - Live app tested
- https://billirubin.lovable.app, 22 and 23 Oct 2026, with test accounts of my own
- Verdict
- Not ready for real users yet. Treat the three problems under "Treat today" first.
What I checked
- Logins, roles and admin actions, end to end
- Who can see and change whose invoices: every table’s database rules, against what the app is for
- Payments: the Stripe checkout and webhook, plans and limits
- Secret keys, packages and made-up package names
- Runaway costs, speed and swallowed errors
- Who owns the database, the domain and the billing accounts
Limits
- Nothing after commit 4e1c9a7 or after 23 Oct 2026
- No load testing and no automated attack tools; live tests with two test accounts of mine
- Hosting and Supabase account settings only as far as shown to me
- Not a penetration test, a certification or a guarantee of security
MichelMichel Wehrli, Founder of Katalyze. Signed 23 Oct 2026.
This statement describes the app at the commit and on the dates above, and nothing after them. It is an expert opinion, not a certification, an audit opinion or a guarantee that the app is secure, and sharing it creates no contract with Katalyze Wehrli. Terms, sections 2, 11 and 12: slopmedic.com/terms.
The full report continues with 24 more problems, the call notes and a fix order. Once the three problems above are fixed, Billirubin gets a free follow-up check. Book a review to get one for your app.