GO KALI FREE
IntermediateWeb Security

IDOR Explained: Insecure Direct Object References

Learn about Insecure Direct Object Reference vulnerabilities where attackers access unauthorized data by manipulating object identifiers in requests.

#IDOR#Web Security#Access Control#Authorization#OWASP Top 10

When Any User Can Access Any Account

You change a number in the URL: /user/profile/123 to /user/profile/124. The page loads another user's name, email, and billing details. No password prompt, no error — just someone else's private data. This is Insecure Direct Object Reference (IDOR): the app exposes internal object references (user IDs, invoice numbers, file paths) without checking whether the current user is authorized to access them.

Prerequisites

Before studying IDOR, you should understand:

  • **Web Security Fundamentals** — HTTP requests, authentication vs authorization
  • **REST API Basics** — URL structure, resource identifiers
  • **Database Concepts** — Primary keys, object references
  • **Burp Suite Introduction** — Intercepting and modifying requests
  • How IDOR Works

    Applications use identifiers to reference objects:

  • **Numeric IDs**: /user/profile?id=1234
  • **UUIDs**: /invoice/download?ref=a1b2c3d4
  • **Usernames**: /documents/owner=jane
  • **Sequential numbers**: /order/confirm/5678
  • Basic Example

    // Vulnerable — no authorization check
    app.get('/api/invoices/:id', (req, res) => {
      const invoice = db.invoices.findById(req.params.id);
      res.json(invoice);
    });
    

    The attacker simply changes the ID:

    GET /api/invoices/1001  ->  User's own invoice
    GET /api/invoices/1002  ->  Another user's invoice (IDOR!)
    

    Types of IDOR

    Horizontal IDOR

    Accessing resources at the same privilege level but belonging to another user — viewing another user's private messages.

    Vertical IDOR (Privilege Escalation)

    Accessing resources requiring higher privileges — a regular user accessing an admin endpoint.

    File-Based IDOR

    GET /download?file=user_1234_report.pdf
    GET /download?file=user_5678_report.pdf
    

    Finding IDOR Vulnerabilities

    Manual Testing Workflow

  • Create two user accounts (User A and User B)
  • Log in as User A, capture requests
  • Note object identifiers in URLs, bodies, and headers
  • Log in as User B, modify identifiers from User A's requests
  • If User B can access User A's data, you found an IDOR
  • IDOR Prevention

    Implement Authorization Checks

    app.get('/api/invoices/:id', authenticate, (req, res) => {
      const invoice = db.invoices.findById(req.params.id);
      if (!invoice) return res.status(404).send('Not found');
    
      if (invoice.userId !== req.user.id) {
        return res.status(403).send('Forbidden');
      }
    
      res.json(invoice);
    });
    

    Use Indirect References

    app.get('/my/invoices/:ref', authenticate, (req, res) => {
      const invoiceId = sessionInvoiceMap[req.session.id][req.params.ref];
      if (!invoiceId) return res.status(404).send('Not found');
      const invoice = db.invoices.findById(invoiceId);
      res.json(invoice);
    });
    

    Use Unpredictable Identifiers

    CREATE TABLE invoices (
      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
      user_id INTEGER REFERENCES users(id)
    );
    

    Note: Unpredictable IDs are obfuscation, not security. Always pair with authorization.

    Real-World Examples

    Telegram IDOR (2020): A researcher discovered Telegram's "People Nearby" feature exposed precise user locations through an IDOR vulnerability.

    Facebook IDOR (2019): Security researchers found an IDOR vulnerability allowing viewing private photos from any Facebook album.

    Uber Bug Bounty (2015): Multiple IDORs in Uber's partner dashboard allowed accessing driver earnings, trip histories, and personal information.

    Common Mistakes

    Assuming UUIDs are secure: Unpredictable IDs are not authorization — endpoints still need permission checks.

    Client-side checks only: Frontend authorization is easily bypassed. All checks must be server-side.

    Inconsistent authorization patterns: Some endpoints check authorization while others do not.

    Best Practices

  • **Check authorization on every request** — Treat every endpoint as potentially unauthorized
  • **Use indirect references** — Map user-facing IDs to internal IDs server-side
  • **Implement least privilege** — Users should only access resources they need
  • **Use consistent authorization middleware** — Apply same checks everywhere
  • **Test with multiple user accounts** — Verify User A cannot access User B's data
  • Related Tools

  • **Burp Suite** — Proxy, Repeater, Intruder for IDOR testing
  • **ffuf** — Fuzzing for valid object IDs
  • **curl** — Manual request manipulation
  • **jq** — Parse JSON responses
  • Related Articles

  • Web Security Fundamentals
  • Burp Suite Introduction
  • Authentication Attacks
  • Session Security
  • Summary

    IDOR vulnerabilities arise from missing authorization checks on object references. The fix is straightforward: verify the requesting user has permission to access the specific resource on every request. Use indirect references and centralized access control patterns to reduce risk.

    Knowledge Check

  • What is the difference between horizontal and vertical IDOR?
  • Why are UUIDs not a sufficient defense against IDOR?
  • What is the recommended testing approach for IDOR?
  • How does an indirect reference map differ from direct object references?
  • Why must authorization checks be server-side rather than client-side?
  • Frequently Asked Questions

    What is IDOR and how does it work?

    IDOR (Insecure Direct Object Reference) occurs when an application exposes a reference to an internal object (like a user ID or filename) and fails to verify the requesting user has permission to access it. The attacker simply changes the identifier — for example, changing `/invoices/1001` to `/invoices/1002` — to access another user's data.

    What is the difference between horizontal and vertical IDOR?

    Horizontal IDOR accesses resources at the same privilege level belonging to another user — viewing another customer's order. Vertical IDOR accesses resources requiring higher privileges — a regular user accessing admin functions. Both stem from missing authorization checks, but vertical IDOR can lead to full privilege escalation.

    Why are UUIDs not a sufficient defense against IDOR?

    UUIDs are obfuscation, not authorization. While unpredictable IDs make guessing harder, they do not prevent access if the endpoint still lacks permission checks. If a user can enumerate or obtain valid UUIDs (via API responses, logs, or leaks), they can access unauthorized resources. Always pair unpredictable IDs with server-side authorization.

    What is the recommended testing approach for IDOR?

    Create two user accounts (User A and User B). Log in as User A, capture requests with Burp Suite, note object identifiers in URLs and bodies. Log in as User B and replay User A's requests with modified identifiers. If User B accesses User A's data, you found an IDOR. Test every endpoint that references user-specific objects.

    How does an indirect reference map differ from direct object references?

    Direct object references expose internal IDs (database primary keys) in URLs. Indirect references map user-facing tokens to internal IDs server-side — the client never sees the real database ID. This prevents IDOR because the attacker cannot guess or manipulate the internal identifier, even if they can access the indirect reference.

    Why must authorization checks be server-side rather than client-side?

    Client-side checks (JavaScript validation, hidden HTML elements) are easily bypassed. An attacker can intercept and modify requests with Burp Suite, disable JavaScript, or send raw HTTP requests. All authorization must be enforced on the server where the attacker cannot manipulate the code executing the checks.

    What are real-world examples of IDOR vulnerabilities?

    Telegram IDOR (2020) exposed precise user locations through the People Nearby feature. Facebook IDOR (2019) allowed viewing private photos from any album. Uber Bug Bounty (2015) revealed multiple IDORs in the partner dashboard exposing driver earnings and personal information. All were fixed by adding authorization checks.

    How do I test for IDOR in an API?

    Capture API requests with Burp Suite or curl, identify object references in URLs, query parameters, and request bodies. Authenticate as different users and replay requests with modified identifiers. Check for consistent authorization across all endpoints — developers often secure some routes but forget others. Use ffuf to fuzz for valid object IDs.

    What is the relationship between IDOR and the OWASP Top 10?

    IDOR falls under OWASP A01:2021 — Broken Access Control, the number one web application security risk. Broken access control includes privilege escalation, insecure direct object references, and missing restrictions on API endpoints. Implementing role-based access control (RBAC) with server-side enforcement addresses IDOR.

    How do I prevent IDOR in a REST API?

    Implement authorization middleware that checks permissions on every request. Use indirect references — map user-facing IDs to internal IDs server-side. Apply the principle of least privilege — users should only access resources they need. Use consistent authorization patterns across all endpoints rather than checking some and not others.

    Can IDOR vulnerabilities lead to data breaches?

    Yes — IDOR is one of the most common causes of large-scale data breaches. If an application exposes sequential user IDs without authorization checks, an attacker can iterate through all IDs and exfiltrate every user's data. Automating IDOR exploitation with tools like Burp Intruder or ffuf can expose millions of records.

    How does IDOR differ from SSRF?

    IDOR exploits missing authorization on object references the client can see and manipulate. SSRF tricks the server into making requests to unintended locations the client cannot directly access. IDOR is about accessing other users' data through manipulated identifiers; SSRF is about using the server as a proxy to reach internal resources.