What Is IDOR? Insecure Direct Object Reference Explained With Examples

An Insecure Direct Object Reference (IDOR) is an access control flaw. An application uses an identifier supplied by the user, such as an order number or file ID, to fetch a record, but never checks that the logged-in user is allowed to see or change that record. Changing the identifier can then expose another customer's data.

May 23, 2025 - 15:14
Updated: 
103.3k

Web & API Security in Cybersecurity & Ethical Hacking · Commands & reference

Cyber Threats, Scams & Online Safety, Ethical Hacking

What Is IDOR? Insecure Direct Object Reference Explained With Examples

Quick answer: An Insecure Direct Object Reference (IDOR) is an access control flaw. An application uses an identifier supplied by the user, such as an order number or file ID, to fetch a record, but never checks that the logged-in user is allowed to see or change that record. Changing the identifier can then expose another customer's data. OWASP lists the API form as Broken Object Level Authorization (API1:2023), and MITRE tracks it as CWE-639. The fix is a server-side ownership or permission check on every request, ideally by scoping database queries to the current user, backed by automated tests and logging.

Key takeaways

  • IDOR is missing authorisation, not missing authentication.
  • It is the top risk in the OWASP API Security Top 10 2023.
  • Random IDs make guessing harder but do not fix the flaw.
  • Check ownership on the server for every read, update and delete.
  • Test with two accounts and log access-denied events.

Table of Contents

How Does an IDOR Vulnerability Work?

Most apps reference records by key: a URL path with an invoice number, a JSON body with an account ID, or a download link with a file name. The flaw appears when the server trusts that key. Login proves who the user is; authorisation decides what they may touch. If the code fetches the record by ID alone, any logged-in user can request any record. The OWASP IDOR Prevention Cheat Sheet explains that the root cause is the missing check, whatever the ID format.

How Does IDOR Relate to BOLA and Broken Access Control?

NameSourceScope
IDOROWASP cheat sheet, testing guideObject access by user-supplied reference
BOLA (API1:2023)OWASP API Security Top 10Same flaw in APIs
A01 Broken Access ControlOWASP Top 10Wider category including IDOR
CWE-639MITREAuthorisation bypass via user-controlled key

In July 2023, CISA, Australia's ACSC and the NSA issued a joint advisory on IDOR, warning that these flaws were being abused in data breaches and urging vendors to adopt secure-by-design checks.

What Is the Impact of IDOR?

  • Data exposure: invoices, health records, identity documents.
  • Unauthorised changes: editing another user's profile, address or password reset email.
  • Deletion: removing other users' records.
  • Privilege escalation: reaching admin objects by ID.

In India, exposure of personal data can trigger duties under the DPDP Act 2023 and CERT-In's 6-hour incident reporting rule.

What Does Vulnerable and Safe Code Look Like?

Vulnerable pattern: the record is fetched by ID only.

# UNSAFE: any logged-in user can read any invoice
@app.get('/api/invoices/<int:invoice_id>')
@login_required
def get_invoice(invoice_id):
    invoice = Invoice.query.get_or_404(invoice_id)
    return jsonify(invoice.to_dict())

Safe pattern: the query is scoped to the current user, so other users' records simply do not exist for them.

# SAFE: ownership enforced in the query
@app.get('/api/invoices/<int:invoice_id>')
@login_required
def get_invoice(invoice_id):
    invoice = Invoice.query.filter_by(
        id=invoice_id, owner_id=current_user.id
    ).first_or_404()
    return jsonify(invoice.to_dict())

Returning 404 rather than 403 also avoids confirming that the record exists. For shared resources, call a central policy function, as the OWASP Authorization Cheat Sheet recommends.

Do Random IDs Prevent IDOR?

No. UUIDs make enumeration harder, but IDs leak through emails, shared links, logs and other API responses. Treat random IDs as defence in depth only. The authorisation check is the real control.

How Do You Detect and Test for IDOR?

MethodWhat it finds
Code reviewQueries by ID without user scope
Two-account testing (WSTG-ATHZ-04)User A requesting User B objects in your own test environment
Automated authorisation tests in CIRegressions after new endpoints
Log monitoringOne account touching many object IDs or many 404s

Only test applications you own or are authorised to assess in writing; unauthorised access breaks Sections 43 and 66 of the IT Act 2000. Our banking bug bounty IDOR case study shows how responsible disclosure works.

What Is the Prevention Checklist?

  1. Enforce authorisation on the server for every object action.
  2. Scope queries by the current user or tenant.
  3. Deny by default and centralise access rules.
  4. Never trust IDs from hidden fields, cookies or JSON bodies.
  5. Write tests for cross-user access on every endpoint.
  6. Log and alert on unusual object access patterns.

See the OWASP Top 10 guide for the wider picture, and explore WebAsha API and web security training.

References

Frequently Asked Questions

IDOR is an access control flaw where an application uses a user-supplied identifier to fetch a record without checking the user may access it.

Yes, broadly. BOLA, Broken Object Level Authorization, is the OWASP API Security Top 10 name for the same flaw in APIs.

MITRE CWE-639, Authorization Bypass Through User-Controlled Key, is the main weakness entry for IDOR vulnerabilities.

No. Random IDs make guessing harder, but they leak through links and responses. Only a server-side authorisation check fixes the flaw.

Check ownership or permission on the server for every object action, scope database queries to the current user, and add cross-user tests.

Returning 404 for records a user does not own avoids confirming that the record exists, which reduces information leakage to attackers.

Through code review, testing with two accounts in an authorised environment, automated authorisation tests and monitoring logs for unusual object access.

Yes. In July 2023 CISA, Australia’s ACSC and the NSA published a joint advisory urging vendors and developers to prevent IDOR flaws.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.