Supabase M-Pesa Callbacks Can Leak Data Across Tenants Despite RLS
A developer found that tenant isolation in a Supabase app can fail on server-side payment paths even when row-level security is enabled everywhere and tests pass. Because the M-Pesa callback handler runs as service_role, RLS does not apply to its writes, and since the callback carries no tenant identifier, the code guessed the tenant by matching payer phone and amount across open invoices. Tests in a public repository reproduced cross-tenant writes from insecure INSERT and UPDATE policies and from a view lacking security_invoker. The author recommends resolving the tenant from a checkout record stored at payment initiation and rejecting callbacks without a match. The write-up also notes that Safaricom reportedly began masking callback phone numbers in March 2026, which would likely break phone-keyed lookups, though this is reported by community sources rather than confirmed by Safaricom.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in