← All tracks
FoundationsIDOR10 labsFoundation → Intermediate → Advanced5h practice

IDOR: The Record You Were Never Meant to See

Authorization is a property of every object, not a property of the page.

“The portal showed only Sarah's invoices. One number later, it showed the CFO's settlement note.”

CWE-639OWASP API Security API1:2023OWASP ASVS 4.1.3
The mental model
Ask one question before every request: who owns this object, and did the server compare that owner with me? Authentication tells the server who you are. Authorization tells it whether this specific record is yours.

The UI lists your records, so the brain assumes the server filters them. Often the server only checks that you are logged in, then looks up whatever ID the request supplies. The identifier becomes a key to every tenant's filing cabinet.

Your brain trusts the interface because it was designed for you. An attacker trusts the request because it is the only thing the server actually receives.

Threat model

What is actually at stake?

Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.

Assets

  • Customer invoices, tickets and documents
  • Tenant identifiers and internal references
  • Actions that change ownership or state

Actors

  • Authenticated customer with a legitimate low-privilege account
  • Malicious tenant or paid researcher
  • Insider with access to one business unit

Trust boundaries

  • Session identity to requested object
  • Tenant to tenant
  • User role to object action
  • UI route to API handler

Abuse cases

  • Increment a numeric identifier and read another tenant's record
  • Swap a UUID copied from an export or GraphQL response
  • Replay a state-changing request against another user's object
  • Use a nested object reference that bypasses the parent check
PrerequisitesHTTP requests and responses, including status codes and cookiesThe difference between authentication and authorizationHow to replay a request with a proxy or browser developer tools
Request anatomy

Follow the decision, not the payload

Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.

  1. 01

    Authenticate

    The session proves who you are. It does not prove which rows you may read.

  2. 02

    Resolve the reference

    The handler turns a path, query or body value into a database key, file name or downstream API call.

  3. 03

    Authorize the object

    A correct handler loads the object and compares its owner or tenant with the current subject before returning data.

  4. 04

    Act

    Read, update, delete or export the object. Every verb needs the same object-level decision.

  5. 05

    Observe

    A missing check usually looks like a normal 200 with different data; a correct check returns 403 or a deliberately indistinguishable 404.

Case study

Sequential document IDs at First American Financial

First American Financial, 2019, public reporting
Context

A public document portal exposed closing documents by changing a numeric identifier in a URL. Authentication was present; object-level authorization was not.

Discovery

A researcher noticed that document links were sequential and that the server returned any document for a valid ID. No special tooling was required beyond editing the URL.

Impact

Public reporting described hundreds of millions of records exposed, including identity and financial information. The incident became a canonical example of why an unguessable URL is not an authorization control.

Root cause

The application treated possession of an authenticated session as sufficient and never compared the document owner with the requester.

Fix

Load the object, derive the subject's tenant and role on the server, enforce the decision in one policy layer, and add two-account regression tests for every object route.

Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.

Attacker lens

A repeatable testing sequence

  1. Map the identifiers you can see: invoice numbers, ticket IDs, user IDs, document names.
  2. Change one identifier at a time and compare status codes, body length and field names.
  3. Test list, detail, export, API and mobile endpoints; one may skip the ownership check.
  4. Look for sequential gaps. The missing ID is often the foreign record.

Where smart people get fooled

  • Hidden links are not access control.
  • Random or long IDs are obfuscation, not authorization.
  • A 403 on one endpoint does not prove the whole object family is protected.
Detection engineering

What would the logs show?

A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.

  • One session requests object IDs that belong to a different tenant or user
  • A burst of sequential or nearby identifiers from the same account
  • Successful 200 responses to IDs that never appeared in the user's UI
  • Exports or GraphQL queries that return more objects than the caller owns
Starter query
index=web sourcetype=app_logs status=200 | eval owner_match=if(requester_tenant=object_tenant,"yes","no") | where owner_match="no" | stats count values(path) by user_id, requester_tenant | where count > 3
The defender's move

Fix the decision, then prove it stays fixed

  • Enforce object-level authorization in the query or policy layer, not in the template.
  • Scope every lookup by the authenticated tenant and user, and return 404 when it does not match.
  • Add automated cross-tenant tests for every object type and every verb.
Vulnerable patterntypescript
const invoice = await db.invoice.findUnique({ where: { id } });
return Response.json(invoice);
Safer patterntypescript
const invoice = await db.invoice.findFirst({
  where: { id, tenantId: session.tenantId }
});
if (!invoice) return new Response("Not found", { status: 404 });
return Response.json(invoice);

Put the tenant predicate in the query, not in a later if statement that a future branch can skip. For updates, include the tenant in the WHERE clause and check the affected row count.

Regression tests a reviewer would ask for

Cross-tenant read

GivenTwo users in different tenants each own one object

WhenUser A requests User B's object identifier

ThenThe API returns 403 or an indistinguishable 404 and no object fields

Cross-tenant write

GivenUser A knows User B's object identifier

WhenUser A sends PATCH or DELETE for that object

ThenNo row changes and the response does not reveal whether the object exists

Nested reference

GivenAn endpoint accepts a parent ID and a child ID

WhenThe parent belongs to User A and the child belongs to User B

ThenThe request is rejected; the child is not resolved through the parent alone

Export and search

GivenA bulk endpoint accepts filters or pagination

WhenUser A searches without an owner filter

ThenThe server injects the tenant scope and never returns foreign rows

False positives

What this finding is not

Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.

  • The identifier is a UUID and therefore hard to guess: unpredictability reduces discovery but is not authorization.
  • The UI only lists your own records: the API can still accept a foreign identifier.
  • The response is 403 for one guessed ID: test another tenant, another verb and a nested reference before concluding the control is complete.
  • The endpoint requires a valid session: authentication is not the same as ownership.
Working vocabulary

Terms you should be able to use precisely

Object-level authorization
A decision about whether this subject may perform this action on this specific object.
IDOR
Insecure Direct Object Reference: a reference controlled by the client reaches an object without an ownership check.
Tenant isolation
The guarantee that data and actions in one customer organization cannot affect another.
BOLA
Broken Object Level Authorization, the API Security term for the same failure class.
Indistinguishable 404
Returning the same not-found response whether an object is absent or forbidden, so the API does not confirm existence.
Mass assignment adjacent
A related failure where a client changes an object field such as ownerId instead of the object reference itself.
Interview drill

Answer these without reciting a payload

Why is a random UUID not an access control?

Authorization must be based on the subject's relationship to the object, not on the difficulty of guessing the identifier. UUIDs leak through exports, logs, referrers and APIs, and an insider can still obtain them.

Where should the tenant check live?

In the data-access policy or query itself, close to the object load, and be reused by every verb. A check in one controller is fragile because new routes and bulk operations bypass it.

How do you test for blind IDOR?

Use two accounts, perform a state-changing request against the other account's object, then verify the effect from the victim session. Compare response timing and status codes only as secondary signals.

Knowledge check

Can you separate the mechanism from the payload?

Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.

4 questions
01A user changes /invoices/1042 to /invoices/1043 and receives another customer's invoice. Which control failed?
02Which change most directly prevents a cross-tenant read?
03Why should a forbidden object often return 404 instead of 403?
04Which regression test catches the widest class of IDOR?
الخلاصة الموسّعة
لماذا هذا مهم؟

الثغرة الحقيقية هنا ليست في الرقم التسلسلي، بل في أن الخادم عرف من أنت ثم نسي أن يسأل: هل هذا الكائن يخصك؟

UUID أو رابط مخفي لا يحلان المشكلة؛ التخمين يصبح أصعب فقط. الحل الصحيح هو ربط كل قراءة وكتابة وحذف بهوية المستخدم والمستأجر داخل طبقة الصلاحيات نفسها، ثم اختبار ذلك بحسابين منفصلين. أي مسار جديد أو تصدير أو استعلام متداخل يجب أن يمر بنفس القرار.

If you changed the ID and received 200, what exactly did the server fail to compare?