AI 編碼 Agent 審查 Supabase 安全設定,將權限大開的資料庫判為安全
I let an AI agent audit my Supabase security — it gave a clean bill of health to a wide-open database
作者讓 AI 編碼 Agent 檢查 Supabase 的 RLS 設定,Agent 卻把權限大開的資料庫判定為安全。作者自行檢查後發現 10 張資料表未啟用 RLS,主資料表可由任何持有 publishable key 的人讀取、寫入及刪除;原因是 Agent 使用唯讀角色,無法在 role_table_grants 中看到授權紀錄。
Last week I asked an AI coding agent to audit the RLS setup on one of my Supabase projects. It connected, ran its checks, and came back confident: everything secure, no issues found.
I ran my own checks after. Ten tables with RLS off. The main table readable, writable, and deletable by anyone holding the publishable key.
The agent wasn't lazy. It was blind — and the reason matters if you let AI anywhere near your database.
The trap
The agent queried information_schema.role_table_grants to see which roles could touch which tables. Zero rows came back. It concluded: no grants anywhere, nothing exposed.
Here's the problem: that view only shows what the current role is allowed to see. The agent was connected through a read-only role, so it got zero rows — the exact same zero rows it would get on a perfectly locked-down database. The query that was supposed to prove "nothing is exposed" returns the same answer whether the database is secure or wide open. It's a test that cannot fail.
The agent reported the absence of evidence as evidence of absence. And it did so confidently.
How to actually check
Run this as the table owner (or a superuser) in the SQL Editor — not through the agent's connection:
select grantee, string_agg(privilege_type, ', ') as privileges
from information_schema.role_table_grants
where table_schema = 'public'
group by grantee;
If anon shows up with SELECT, INSERT, UPDATE, DELETE on tables you didn't intend to expose, you have a hole no agent audit will find for you — because the agent literally cannot see it from where it sits.
The rule
AI agents are good at writing the queries. They're bad at knowing which role they're asking as. Every permissions check has to be run as the role you're actually worried about — or by someone who can see all of them. "The agent checked" is not a security posture.
The full kit
The free 10-check audit is here: https://tavora2.gumroad.com/l/adwgfz. Check 11 — the grant-visibility trap above, as a query that always returns one row with a verdict and warns you when you're querying from a role that can't see grants — is in the paid kit, because it's the one that specifically bites AI-built apps: $39: https://tavora2.gumroad.com/l/lsoerp
Scope note: this is a review aid for projects you own or are authorized to test — not a penetration test, not a certification. (Project names anonymized; findings are real.)
來源:DEV Community · dev.to