Skip to content
ScanAnt

What is IDOR (insecure direct object reference)?

IDOR (insecure direct object reference) is an access control flaw where an application uses an ID from the request, such as /orders/1042, without checking that the logged-in user owns that record. Changing the number returns or edits someone else's data.

How it works

The user is signed in, so the app trusts them. The endpoint loads the record by ID and returns it, but never asks whether this record belongs to this user. An attacker simply tries neighbouring IDs. Random UUIDs make guessing harder, but they are not a fix: if an ID leaks in a URL, a log or a share link, the missing check still allows access. The fix is always a server-side ownership check on every read, update and delete.

// Vulnerable: any signed-in user can read any invoice
const inv = await db.invoice.findUnique({ where: { id: params.id } });

// Safe: scope the query to the owner
const inv = await db.invoice.findFirst({
  where: { id: params.id, userId: session.user.id },
});

How to tell if your site is affected

  • Endpoints take an id, email or filename in the path or query and fetch by that value alone.
  • While signed in as user A you can open a URL or API response belonging to user B by changing the ID.
  • Your API checks that the user is logged in, but not that the record belongs to them.
  • Update and delete calls accept a client-sent userId or role field that the server trusts.

How to fix it

  1. Add an ownership check on the server for every endpoint that reads or changes a record: filter by the user ID from the session, never from the request.

  2. Centralise the check in one helper or policy layer so a new route cannot forget it.

  3. On Supabase, enforce it in the database with row-level security policies such as auth.uid() = user_id, so the check applies to every client.

  4. In Firebase, write rules that compare request.auth.uid with the document owner.

  5. Do not accept role, plan or user_id fields from the client in update bodies. Write a test that logs in as two users and tries to read each other's records.

How ScanAnt checks for it

Deep scanCode scan

IDOR cannot be found without being signed in, so the free quick scan does not test it. In the deep scan, a verified owner can provide two test accounts so ScanAnt checks that one account cannot read the other's records. The code scan flags routes in an uploaded project that load records by ID without an owner check. Neither replaces a manual access-control review.

Questions

Are UUIDs enough to prevent IDOR?

No. Unpredictable IDs make guessing hard, but any leaked ID still works if the server does not check ownership.

Is IDOR the same as broken access control?

IDOR is one common form of it. Broken access control is the top category in the OWASP Top 10 and includes missing role checks and privilege escalation.

Why is IDOR common in apps built by AI tools?

Generated code often fetches by ID and ships without ownership checks or database policies, because the demo works with one user.

How do I test for IDOR myself?

Create two accounts, copy a request that returns user A's data, replay it with user B's session and see whether it still returns A's data.

See if your site is affected

Free for any public site, no signup. Need the verified or deep scan? Choose the level on the scan page.

Choose a scan level →