Guide
Can users see each other's data? The "change the ID" test for vibe-coded apps
Short answer: make two accounts. As user A, open something that belongs to A (an invoice, a project, a profile) and note its ID. Then, signed in as user B, try to load that ID: first by editing the URL, then by replaying the app's own API request with A's ID in it. If B gets A's data back, your app has an IDOR (insecure direct object reference), which OWASP files under broken object level authorization.¹² The fix is never "hide it in the UI". The ownership check has to run on the server: in a Supabase app, that means a Row Level Security policy that compares the row's owner column to auth.uid().³
Only run these tests on an app you own, with test accounts you created.
Why AI-built apps get this wrong
A login screen proves who someone is. It says nothing about which rows they're allowed to read. AI builders are good at the first part and often stop there: the page filters a list to "my invoices", so it looks right, but the request underneath asks for any invoice by ID, and the database answers.
OWASP describes the attack exactly like this: change the ID in the request to an object that belongs to someone else.¹² It doesn't take a hacker. A curious user who notices /invoice/1042 in the address bar will try /invoice/1041.
Random IDs don't fix it. UUIDs make IDs hard to guess, and OWASP suggests them as an extra layer, but it lists them as defense in depth, not as the access check itself.¹ IDs leak through shared links, screenshots, logs and API responses that list other records.
The test (15 minutes)
You need two test accounts, A and B, and two browsers (or one normal and one private window) so both stay signed in.
1. The URL test
- As A, create a record of every private type your app has: a project, a note, an order, an uploaded file, a profile.
- Open each one and copy the URL. Note the ID (number, UUID or slug).
- In B's browser, paste each URL.
You should see "not found", "no access" or an empty page. If you see A's data, stop here: you have a confirmed leak. Skip to the fixes.
2. The API test (the one most people skip)
Passing the URL test doesn't mean you're safe. The page may hide the record while the API still returns it.
- In B's browser, open DevTools → Network and load one of B's own records.
- Find the request that fetched it. In a Supabase app it goes to
https://<project>.supabase.co/rest/v1/<table>?id=eq.<id>. In other apps it's usually something like/api/projects/<id>. - Right-click it → Copy as fetch (or Copy as cURL). It carries B's session token.
- Swap B's ID for A's ID and run it (paste the fetch into the DevTools console, or the cURL into a terminal).
If the response contains A's record, the check only lives in the UI.
3. The write test
Reads are only half of it. Repeat step 2 for changes:
- Update and delete: replay B's "save" or "delete" request with A's ID. Then check as A whether anything changed.
- Create as someone else: if the request body includes a
user_idorowner_id, set it to A's ID. If the row is saved under A, any user can plant data in another user's account.
4. Files
Open a file A uploaded (an avatar, an invoice PDF, an attachment), copy its URL and open it in B's browser, then signed out. In Supabase Storage, a public bucket bypasses access control for downloads: anyone with the URL gets the file.⁴ That's fine for profile pictures and blog images. It's not fine for receipts, IDs or private documents, which belong in a private bucket with policies.⁴⁵
5. Anything that uses the service role key
Edge Functions, API routes and server actions that use Supabase's service_role (secret) key skip RLS entirely.⁶ For each one that takes an ID, repeat the API test against it. Those functions need their own ownership check in code.
How to fix it in a Supabase app
Turn RLS on and write per-owner policies
For a table with a user_id column that stores the owner, Supabase's docs use this pattern:³
alter table public.projects enable row level security;
create policy "Owners can read their projects"
on public.projects for select
to authenticated
using ( (select auth.uid()) = user_id );
create policy "Owners can create their projects"
on public.projects for insert
to authenticated
with check ( (select auth.uid()) = user_id );
create policy "Owners can update their projects"
on public.projects for update
to authenticated
using ( (select auth.uid()) = user_id )
with check ( (select auth.uid()) = user_id );
create policy "Owners can delete their projects"
on public.projects for delete
to authenticated
using ( (select auth.uid()) = user_id );
using decides which existing rows a user can see or touch. with check decides what they're allowed to write, which is what stops the "create as someone else" trick in step 3.³ Wrapping auth.uid() in select is Supabase's own performance advice.³
On a live app, add the policies before you switch RLS on, and do one table at a time. Our guide to turning on Supabase RLS without breaking your app walks through it.
Watch for the policies that look safe but aren't
using (true)lets everyone read every row. RLS on with this policy behaves like RLS off.using (auth.uid() is not null)means "anyone signed in". With open sign-up, that's anyone.- Views run with the view owner's rights by default, so they skip the caller's RLS. On Postgres 15+ create them
with (security_invoker = true).³ - Shared data (teams, workspaces) needs a policy that checks membership, e.g. that the user has a row in a
memberstable for that workspace, not just that they're signed in.
Fix server code too
In any Edge Function or API route that uses the secret key, look up the record and compare its owner to the signed-in user before returning or changing it. Never trust a user_id sent from the browser; take it from the verified session.¹
A prompt for Lovable, Bolt or Cursor
For every table that stores user data, enable Row Level Security and add separate select, insert, update and delete policies that only allow rows where the owner column equals auth.uid(), with
with checkon insert and update. Don't useusing (true)orauth.uid() is not nullfor private data. List every Edge Function or API route that uses the service role key and add a check that the signed-in user owns the record before reading or changing it. Then show me the final policies as SQL.
Ask to see the SQL. Then run the test above again as user B. A passing re-test is the only proof the fix worked.
FAQ
What is an IDOR? An insecure direct object reference: the app takes an ID from the user (in a URL, form or API call) and returns or changes that object without checking the user is allowed to. OWASP's API list calls it broken object level authorization and ranks it first.
My app uses UUIDs. Am I safe? Not on their own. UUIDs are hard to guess, but they leak through links, logs and API responses. OWASP treats random IDs as an extra layer on top of a real access check, not a replacement for one.
RLS is on for every table. Can users still see each other's data?
Yes, if a policy is too broad (using (true) or "any signed-in user"), if a view skips RLS, if files sit in a public bucket, or if a server function uses the service role key without checking ownership. Run the two-account test to be sure.
Is it enough to hide other users' records in the UI? No. The browser is under the user's control, and anyone can replay the API request with a different ID. The check has to happen in the database (RLS) or on the server.
Want a second pair of eyes before launch? The free Quick Check looks at your live URL for leaked keys, exposed files, HTTPS and SEO basics in about 20 seconds. The $49 Launch Check goes further and gives you a plain-English fix list with copy-paste prompts for Lovable, Bolt or Cursor. Neither one signs in as two users, so run the test on this page yourself. For the database side, see the Supabase RLS launch checklist and the 5-minute leak check.
Sources
- OWASP Cheat Sheet Series, Insecure Direct Object Reference Prevention (definition, server-side access checks, random IDs as defense in depth): https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html
- OWASP API Security Top 10 2023, API1: Broken Object Level Authorization: https://owasp.org/API-Security/editions/2023/en/0xa1-broken-object-level-authorization/
- Supabase docs, Row Level Security (policies with
usingandwith check,(select auth.uid()), views withsecurity_invoker): https://supabase.com/docs/guides/database/postgres/row-level-security - Supabase docs, Storage buckets (public buckets bypass access control for retrieving files): https://supabase.com/docs/guides/storage/buckets/fundamentals
- Supabase docs, Storage access control: https://supabase.com/docs/guides/storage/security/access-control
- Supabase docs, Understanding API keys (service_role / secret keys bypass RLS): https://supabase.com/docs/guides/api/api-keys