Supabase のテナントを越えた読み取りを検知

supatripwire はプロジェクトの API ゲートウェイのログを読み、あるテナントの利用者が別のテナントの行を受け取った読み取りを報告します。

$ npx supatripwire check --since 24hsupatripwire — 2026-11-25T05:00:00.000Z to 2026-11-26T05:00:00.000ZSigned-in reads scanned: 1284  found from 2026-11-25 05:00:12 to 2026-11-26 04:58:40 (UTC)  fully checked: 1243  on tables missing from the config: 0  without a row count: 0  on tables the config ignores: 41 (countries 41)Data crossed tenants: 2  2026-11-26 03:12:08  projects  user 2d9a7c41-8e3b-4f06-b5d2-91a0c6e4f378  (named another tenant)    rows: 3  status: 200  log id: a41f0c9e-63d2-4b8a-9f17-5e2c08d3b6a1    named tenants not theirs: b83e5d10-27c4-4f9a-a6e1-3c9d0f4e7b52    their tenants: 6f1c2a9e-4b7d-4e21-9c3a-0d5e8f7b2a14    query: ?select=*&org_id=eq.b83e5d10-27c4-4f9a-a6e1-3c9d0f4e7b52  2026-11-26 03:14:51  tasks  user 2d9a7c41-8e3b-4f06-b5d2-91a0c6e4f378  (more rows than their tenants hold)    rows: 50  status: 200  log id: c7e2b815-0f4a-4d39-8c6e-2a91f5d0e743    saw at least 50 rows; their tenants hold 12    their tenants: 6f1c2a9e-4b7d-4e21-9c3a-0d5e8f7b2a14    query: ?select=*&order=created_at.desc&limit=50
Data crossed tenants: 2  2026-11-26 03:12:08  projects  user 2d9a7c41-8e3b-4f06-b5d2-91a0c6e4f378  (named another tenant)    rows: 3  status: 200  log id: a41f0c9e-63d2-4b8a-9f17-5e2c08d3b6a1    named tenants not theirs: b83e5d10-27c4-4f9a-a6e1-3c9d0f4e7b52    their tenants: 6f1c2a9e-4b7d-4e21-9c3a-0d5e8f7b2a14    query: ?select=*&org_id=eq.b83e5d10-27c4-4f9a-a6e1-3c9d0f4e7b52

別のテナントを指定した読み取り

ログには、ログイン中の読み取りが送った絞り込みの条件が残ります。supatripwire はそこにある id をテナントに引き当て、呼び出した利用者の所属と照らします。行が返っていればデータが越えています。返っていなければ、RLS が試みを止めています。

何を報告するかは README に詳しく書いています。

Data crossed tenants: 2  2026-11-26 03:14:51  tasks  user 2d9a7c41-8e3b-4f06-b5d2-91a0c6e4f378  (more rows than their tenants hold)    rows: 50  status: 200  log id: c7e2b815-0f4a-4d39-8c6e-2a91f5d0e743    saw at least 50 rows; their tenants hold 12    their tenants: 6f1c2a9e-4b7d-4e21-9c3a-0d5e8f7b2a14    query: ?select=*&order=created_at.desc&limit=50

見えるはずの件数を超えた読み取り

絞り込みは件数を減らすだけです。利用者のテナントにある行より多くを見た読み取りは、条件が何であっても、条件が無くても、テナントを越えています。

$ npx supatripwire doctorDatabase: connected as supatripwire  ✓ memberships: sees every row  ✓ projects: sees every row  ✓ tasks: sees every rowLogs API: ✓ reachable; signed-in reads found in the last hourNot checked: whether the config matches your app — which column holds the tenant,and whether the membership table is complete. Confirm those yourself.

リクエストの経路に何も挟まない

ログは Management API から、id はお使いの側で作る読み取り専用のロールから読みます。ロールに許すのは id とテナントの列だけです。プロキシも SDK も要らず、行の中身も読みません。

設定は npx supatripwire doctor で確かめられます。