Can a user see someone else's data by changing the ID in the URL? (IDOR in Next.js and Supabase apps)
By Abbi Labs · Last updated 23 November 2026
Scan your app free and see what a stranger can already read.
Abbi Labs checks your live site from the outside: Supabase tables readable with your public key, secret keys like service_role in the JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS certificate expiry. Read-only. No sign-up for the quick check.
No app handy?
No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.
Run on every deploy or use from Cursor / Claude Code via MCP →
Weekly AI-app security checklist
One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.
Your app has a page like /orders/1042 or an API call like GET /api/invoices?id=1042. You sign in, it shows your order. Now change 1042 to 1043. If you see someone else's order, that's IDOR, and it's one of the most common bugs in apps built fast with an AI agent. Nothing looks broken in normal use, because normal users only ever click their own links.
Supabase behaviour below is from the Row Level Security and API keys docs; server action guidance is from the Next.js data security docs. Short version in our tip: change the ID, see someone else's data.
Why AI-built apps end up with this
- The route checks you're signed in, not that the row is yours. "Require auth" gets added, so a signed-out request fails. A signed-in stranger passes.
- The server uses the service_role key. When an RLS error shows up, the quick fix an agent often reaches for is the service_role key in the API route. That key skips RLS, so the only thing standing between a user and every row is your
whereclause. - The ID comes from the request, the user doesn't. Code like
where id = req.query.idtrusts whatever the client sends. The user's ID should come from the session on the server, never from the body. - Server actions look private. They're called from your own form, but they're public endpoints. Anyone can call one with any ID.
The 5-minute two-account test
- Make two test accounts, A and B. As A, create something: an order, a note, an invoice, a file.
- Open DevTools, Network tab. Find the request that loads it and copy the URL or the request (right-click, Copy as cURL). Note the ID.
- Sign out, sign in as B in a private window. Open A's URL, or replay the request with B's cookie or token.
- Do the same for update and delete: as B, send A's ID to the edit and delete endpoints (or server actions). Use a throwaway record.
- Any 200 with A's data, or any change to A's record, is the bug. You want a 404 or 403.
Repeat for anything that takes an ID: files and signed URLs, exports, team/workspace IDs, Stripe customer or invoice lookups, and "share" links.
What the bug looks like, and the fix
// Vulnerable: any signed-in user can read any order
const { data } = await supabaseAdmin // service_role, RLS skipped
.from("orders").select("*")
.eq("id", params.id).single();
// Fixed: match the owner from the session, not the request
const user = await getUser(); // from the session cookie
if (!user) return new Response("Unauthorized", { status: 401 });
const { data } = await supabaseAdmin
.from("orders").select("*")
.eq("id", params.id)
.eq("user_id", user.id) // ownership check
.maybeSingle();
if (!data) return new Response("Not found", { status: 404 });Better still, don't use the service_role key for user requests at all. Create the Supabase client with the user's session (cookies on the server, or the browser client) and let RLS do it:
create policy "own orders"
on public.orders for select
to authenticated
using ((select auth.uid()) = user_id);Same rule for writes. On update and delete, filter by id and owner, and never take user_id from the request body on insert. Set it from the session (or a column default of auth.uid()).
Return 404 rather than 403 for rows that aren't theirs if you don't want to confirm the ID exists.
Paste this into your AI builder
Audit every API route, route handler and server action that takes an ID
(URL param, query string, form field or JSON body). For each one:
1. Get the current user from the server-side session. Return 401 if none.
2. Make every select, update and delete filter by the record id AND the
owner (user_id, or team membership), using the session user's id.
Never trust a user_id sent by the client.
3. Where possible, query Supabase with the user's session instead of the
service_role key so RLS applies.
4. Return 404 when the record isn't found or isn't theirs.
List each route you changed and anything you couldn't fix.Then run the two-account test again yourself. Don't take "fixed" from the agent as the test.
What Abbi Labs checks
Honest scope: the free outside scan reads your live site signed out with your own public key. It reports Supabase tables a stranger can read without an account, secret keys (including service_role) in your JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS expiry. It doesn't sign in as two users or call your API routes with other people's IDs, so it can't prove an IDOR either way. For tables open to "any signed-in user", use the free policy checker, which runs in your browser on one read-only query. Nothing writes to your database.
FAQ
What is IDOR?
Insecure Direct Object Reference. The app takes an ID from the request (URL, query string, form or JSON body), looks up that record and returns or changes it without checking the person asking is allowed to. OWASP's API Security Top 10 (2023) lists it first, as Broken Object Level Authorization.
Do UUIDs fix IDOR?
No. Random UUIDs are harder to guess than 1, 2, 3, but IDs leak all the time: in shared links, emails, browser history, logs, screenshots and other API responses. The fix is an ownership check on the server, not a harder-to-guess ID.
Does Supabase RLS protect against this?
Only when the query runs as the user. If the browser or your server queries Supabase with the user's session, RLS policies like auth.uid() = user_id stop the read. If your API route uses the service_role key or a direct Postgres connection, RLS is skipped and your code has to do the check.
Are Next.js server actions safe from this?
No. A server action is a POST endpoint anyone can call with any arguments, not only the ones your form sends. Next.js's own docs say to treat them like public API routes and check auth and permissions inside each one.
Is hiding the ID from the UI enough?
No. Anyone can open DevTools, see the request your page makes and replay it with a different ID. What matters is what the server does with the ID it gets.
Can Abbi Labs find IDOR bugs?
Not directly. The free scan reads your live site signed out, so it doesn't sign in as two users and swap IDs. It does flag things that usually make IDOR worse: a service_role key in your JavaScript, and Supabase tables any stranger can read with your public key. The two-account test below is the real check.