{
  "id": 22960249,
  "title": "Your M-Pesa callback runs as service_role: where Supabase tenant isolation really breaks",
  "url": "https://urgent.news/2026/12/01/your-m-pesa-callback-runs-as-service-role-where-supabase-tenant",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T13:38:20.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/cal-me_j/your-m-pesa-callback-runs-as-servicerole-where-supabase-tenant-isolation-really-breaks-121d"
  },
  "original_language": null,
  "account": "Supabase has introduced a change where public tables are no longer automatically exposed to the Data API, scheduled to take effect on 30th October 2026. While new tables will be restricted by Row Level Security (RLS), existing tables retain their current grants. Server-side paths of Supabase applications have been reported to have large-scale exposure issues. This article focuses on the server-side aspects that are not covered by the upcoming changes.\n\nThe source code for testing tenant isolation can be found at https://github.com/cal-me-j/tenant-isolation-lab. The tests use two tenants, membership and invoice tables, and simulate M-Pesa callbacks using Daraja-shaped payloads. The testing environment uses Supabase CLI 3.2.0, Postgres 17.12, and GitHub Actions on ubuntu-latest.\n\nThree scenarios were identified where RLS does not prevent unintended tenant access:\n1. User metadata can be edited, allowing users to select their tenant.\n2. An INSERT policy only checks authorship.\n3. An UPDATE policy uses ownership-based checks without WITH CHECK.\n\nA specific M-Pesa-related issue arises from the fact that callbacks do not include tenant information. The handler in the vulnerable code matches payer phone numbers and amounts against open invoices across all tenants, a flawed approach as the callback carries no tenant reference. A better approach would be to store a record at the initiation of the checkout request and reject callbacks with no matching record. The updated handler logic also includes a WITH CHECK on writes, views with security_invoker, and a SECURITY DEFINER function to restrict access.",
  "summary": "RLS is enabled on every table. Tests pass. Then a payment callback writes a row to the wrong tenant: the handler runs as service_role, so RLS never sees it, and the callback carries no tenant, so the code guesses. 1. Why this matters now Supabase is changing public tables so new ones are no longer exposed to the Data API automatically. Its April 2026 changelog schedules this for all existing…",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}