Insecure Direct Object Reference Prevention - OWASP Cheat Sheet Series
Insecure Direct Object Reference Prevention - OWASP Cheat Sheet Series
Sheet
Introduction
Insecure Direct Object Reference (IDOR) is a vulnerability that arises when attackers can access or
modify objects by manipulating identi?ers used in a web application's URLs or parameters. It occurs
due to missing access control checks, which fail to verify whether a user should be allowed to access
speci?c data.
Examples
For instance, when a user accesses their pro?le, the application might generate a URL like this:
https://example.org/users/123
The 123 in the URL is a direct reference to the user's record in the database, often represented by the
primary key. If an attacker changes this number to 124 and gains access to another user's
information, the application is vulnerable to Insecure Direct Object Reference. This happens because
the app didn't properly check if the user had permission to view data for user 124 before displaying it.
In some cases, the identi?er may not be in the URL, but rather in the POST body, as shown in the
following example:
In this example, the application allows users to update their pro?les by submitting a form with the
user ID in a hidden ?eld. If the app doesn't perform proper access control on the server-side, attackers
can manipulate the "user_id" ?eld to modify pro?les of other users without authorization.
Identi2er complexity
In some cases, using more complex identi?ers like GUIDs can make it practically impossible for
https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html 03.02.25, 21 22
Page 1 of 2
:
attackers to guess valid values. However, even with complex identi?ers, access control checks are
essential. If attackers obtain URLs for unauthorized objects, the application should still block their
access attempts.
Mitigation
To mitigate IDOR, implement access control checks for each object that users try to access. Web
frameworks often provide ways to facilitate this. Additionally, use complex identi?ers as a defense-in-
depth measure, but remember that access control is crucial even with these identi?ers.
Avoid exposing identi?ers in URLs and POST bodies if possible. Instead, determine the currently
authenticated user from session information. When using multi-step Wows, pass identi?ers in the
session to prevent tampering.
When looking up objects based on primary keys, use datasets that users have access to. For
example, in Ruby on Rails:
Verify the user's permission every time an access attempt is made. Implement this structurally using
the recommended approach for your web framework.
https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html 03.02.25, 21 22
Page 2 of 2
: