DEV Community

Cover image for The app AI built for you might be leaking its database. Here is how to check.

The app AI built for you might be leaking its database. Here is how to check.

AheadKit on November 29, 2026

You asked an AI tool to build your app and it works. The login works, the data shows up, the buttons do what they should. What you cannot see is wh...
Collapse
 
sunnatulla_dev profile image
Sunnatulla •

For the SECURITY DEFINER query, listing them isn't quite the test. What matters is has_function_privilege('anon', fn, 'execute'). On PG17, revoke execute ... from anon still left it true and anon read the secrets table, because EXECUTE is granted to PUBLIC by default. Only revoking from public turned it false.

Collapse
 
aheadkit profile image
AheadKit •

Listing them only says they exist, it doesn't say anon can run one — the privilege check is the real test. The PUBLIC default is the nasty bit, revoke from anon looking like it worked while nothing changed. Going to run the privilege version against the same dummy schema and see if revoke-from-public is what actually closes it. Was that a real Supabase project or a local PG17?

Collapse
 
sunnatulla_dev profile image
Sunnatulla •

Local PG17, not a real project. One thing to watch on Supabase though: as far as I know the public schema there has default privileges that grant execute on new functions straight to anon, so it's not only via PUBLIC. I mimicked that locally and revoke from public alone left has_function_privilege true for anon. Only after revoking from anon as well did it go false, so I'd do both.

Thread Thread
 
aheadkit profile image
AheadKit •

Local PG17 makes it cleaner, no real project to worry about breaking. The Supabase default-privilege bit is the part I missed. Revoke from public alone still leaves anon with execute, so the run has to test both revokes side by side. Going to run it that way. Is that default privilege written down anywhere on Supabase's side, or just something you found by poking at it?

Thread Thread
 
sunnatulla_dev profile image
Sunnatulla •

Half and half. Supabase's Database Functions guide has a "Function privileges" section that says any role can run a function by default and tells you to revoke from both public and the role you're restricting, same for default privileges on future functions: supabase.com/docs/guides/database/...

The anon grant on its own is what I saw poking at it, the docs only imply it by telling you to revoke from both. So I'd still check has_function_privilege('anon', ...) on the real project after the revoke rather than trust either of us.

Thread Thread
 
aheadkit profile image
AheadKit •

Half and half is the honest answer then, the docs tell you to revoke from both without ever saying the anon grant is there on its own. The check after the revoke stays in the run either way.

Collapse
 
x1y1co profile image
X1Y1 •

The MCP baseline half deserves its own post. Cursor's MCPoison bug (CVE-2025-54136) was exactly that case: an approved server entry whose command was swapped later, with no new prompt. A diff against a saved tool list would have caught it.

Collapse
 
aheadkit profile image
AheadKit •

That's exactly the case the second half was built for and never got to show. The script in the piece catches an added tool and a widened input, but a swapped command on an approved entry is the sharper test, and MCPoison is the real version of it. I'll run that one, same baseline script, one entry whose command changes after approval, and see the diff catch it. Have you seen the same pattern anywhere outside Cursor, or is that the one example?

Collapse
 
x1y1co profile image
X1Y1 •

Same idea one layer down: Invariant Labs called it a rug pull in their April 2025 tool poisoning write-up. The server changes its tool descriptions after you approved it. Your baseline diff on tools/list would catch that one too.

Thread Thread
 
aheadkit profile image
AheadKit •

That's the case the baseline half was built for, a description swap after approval is exactly what a diff on tools/list would catch. Going to run the swap against the same baseline script. Did the write-up say whether it was a one-off swap or the descriptions kept drifting?

Collapse
 
userxnom profile image
Abdullah Naseer •

This is a useful checklist, and being upfront that the RLS audit was not run on a live Supabase project yet makes it more trustworthy, not less. One addition I would suggest: after the catalogue queries, test as the anon role itself with a real request against a table that should be locked. Policies can read correctly in the catalogue and still behave differently in practice, especially with the default-privilege issue Sunnatulla raised. And I agree with X1Y1 that the MCP baseline half deserves its own post — a saved tool list that diffs on every run would catch exactly the kind of silent swap that worries me most.

Collapse
 
aheadkit profile image
AheadKit •

The anon-role test is the part the piece missed — a policy can read right in the catalogue and still let anon through in practice. Going to run that against a locked table and see what actually comes back. And yeah, the MCP baseline half is getting its own post, you and X1Y1 both pointed at the same gap.

Collapse
 
the_daily_flare profile image
The daily flare •

I would run those eight read-only queries before I trust any AI-built app with my data.

Collapse
 
aheadkit profile image
AheadKit •

That's the order that matters — run them before you trust it, not after something goes wrong. Have you got an app in mind to try them on?