Insecure Direct Object Reference
IDOR
Introduction
Insecure Direct Object References(IDOR) occur when an application provides direct access to objects based on user-supplied input. As a result of this vulnerability, attackers can bypass authorization and access resources in the system directly, for example, database records or files.In simple words, it’s like getting sensitive information by just changing a few values in the parameter.
How it Works
Hacker identifies web application using direct object reference(s) and requests verified information. Valid http request is executed and direct object reference entity is revealed.
Here for the particular user, he can allowed to access only 2 fruits details.

So if we view apple it appears as id=1, as well as id=2 for grapes.

Direct object reference entity is manipulated and http request is performed again. Http request is performed without user verification and hacker is granted access to sensitive information.
Here by manipulating the id parameter we can view the other users information too.

How to Fix
We have to validate with the session
Enforce access control policies such that users cannot act outside of their intended permissions.
Use hash function and use hashed values instead of normal numbers or strings.
For PHP
we have to validate the session like this,
In the database, it has to be like this, sample poc

References
Last updated
Was this helpful?