Skip to content

Insecure Direct Object Reference (IDOR)

Insecure Direct Object Reference (IDOR) is a specific type of Broken Access Control vulnerability. It occurs when an application provides direct access to objects (such as database records, files, or sensitive actions) based on user-supplied input.

If the application fails to verify whether the requesting user is actually authorized to view or modify the requested object, an IDOR vulnerability exists.

Developers often rely on predictability. When designing an API, it’s common to use sequential, guessable IDs:

  • User 1 is /api/users/1
  • User 2 is /api/users/2

The flaw is assuming that because User 1 doesn’t have a link to User 2’s profile in the UI, User 1 cannot access it. Attackers ignore the UI; they simply change the number in the URL or the POST body.


IDORs typically lead to one of two forms of privilege escalation:

This occurs when an attacker accesses data belonging to another user with the same level of privilege.

Example: Alice (Account ID: 501) visits her billing history: https://bank.com/invoices?account=501. She changes the URL to account=502. Because the backend fails to check if Alice owns account 502, the server returns Bob’s sensitive billing data. Alice escalated her access horizontally to another standard user.

This occurs when an attacker accesses data or functionality reserved for a user with a higher level of privilege, like an administrator.

Example: A standard user intercepts the request to update their own profile:

{
"user_id": 105,
"email": "hacker@example.com",
"role": "user"
}

They manipulate the payload before it reaches the server:

{
"user_id": 105,
"email": "hacker@example.com",
"role": "admin"
}

If the backend accepts the updated role parameter without verifying the user’s current administrative standing, the attacker has achieved vertical privilege escalation via parameter tampering.


The UUID “Fix” (Security by Obscurity)

Section titled “The UUID “Fix” (Security by Obscurity)”

A common, but flawed, attempt to fix IDOR is switching from sequential integers (1, 2, 3) to Universally Unique Identifiers (UUIDs). For example, GET /api/users/f47ac10b-58cc-4372-a567-0e02b2c3d479.

While UUIDs prevent enumeration (an attacker cannot simply loop through IDs 1 to 10,000), they do not fix the underlying broken access control. If the attacker obtains the UUID through another means (like a leaked log file, an exposed API, or social engineering), they can still access the data.

UUIDs make the vulnerability harder to find, but they do not secure the application.

The only robust mitigation against IDOR is implementing strict, data-layer authorization checks on every request that accesses a secure object.

  • When the server receives a request for Invoice 502, it must logically assert: Does the Session Token belonging to the current requesting user have ownership or administrative rights over Invoice 502?
  • Zero Trust: Never trust client-provided IDs for authorization. If the client is updating their own profile, read their User ID from their secure server-side session, not from a hidden <input> field or a JSON payload.
  • Role-Based Access Control (RBAC): Implement centralized authorization logic that clearly defines which roles can perform CRUD (Create, Read, Update, Delete) operations on which resources.