How IDOR Works : A Pentester’s Guide

IDOR

IDOR stands for Insecure Direct Object Reference. In this article, we will describe how IDOR works. It is a vulnerability that occurs when an application allows a user to access or manipulate objects (e.g., files, database records, resources) directly through user-supplied input, such as parameters in the URL or form data. This allows attackers to bypass authorization checks and access unauthorized resources.

How IDOR Works

IDOR is a common high-impact vulnerability. Below, we describe how IDOR works step-by-step.

IDOR in User Profile Access

Picture having a web application that uses URLs like:

https://example.com/users/1 (User ID 1)
https://example.com/users/2 (User ID 2)

A user should only be able to access their own profile, but there’s insufficient access control checks. An attacker could change the user ID in the URL to access other user profiles directly, even if they don’t have the appropriate permissions.

IDOR in File Access

Users can access and download their files through URLs using file-sharing applications.

https://example.com/files/12345 (File ID 12345)

The application fails to verify the access rights of authenticated users, allowing attackers to manipulate URLs and access files belonging to other users by changing the File ID.

IDOR in Order Management:

An e-commerce platform has URLs for order details like:

https://example.com/orders/1001 (Order ID 1001)
https://example.com/orders/1002 (Order ID 1002)

If the application fails to verify the user’s ownership of an order, attackers can view other users’ orders by altering the URL, even those not meant to be accessible to them.

Test For IDOR

Testing for IDOR as a web application Pentester involves a systematic approach to identify and exploit insecure direct object reference vulnerabilities. Here’s a step-by-step guide on how to test for IDOR:

Understand the Application and Functionality

Familiarize yourself with the application’s features, user roles, and how it manages resources (e.g., files, data, URLs). Understanding the business logic is crucial for identifying potential IDOR vulnerabilities.

Identify Sensitive Endpoints

Identify endpoints that deal with sensitive operations, such as user data, files, orders, or any other resource that should be protected from unauthorized access.

Examine Request Parameters

Analyze the parameters passed in HTTP requests, such as query parameters, form fields, or path variables. Look for any parameters that directly reference objects like IDs, names, or numerical identifiers.

Testing for IDOR

Now, you can begin testing for IDOR using various techniques:

  • Bypassing Sequential IDs: If the application uses sequential or predictable IDs
    (e.g., https://example.com/users/1, https://example.com/users/2),
    try changing the IDs to see if you can access resources that should be restricted.
  • Parameter Manipulation: Modify the parameters directly in the URL or request body to access other users’ resources or sensitive data.
  • Burp Collaborator: Use Burp Suite’s Collaborator feature to check for differences in responses based on ID manipulation. This can help detect hidden IDOR vulnerabilities.
  • Enumeration: Enumerate possible IDs or resources to find hidden or unpublished endpoints that might be vulnerable.
  • Change HTTP Methods: Try accessing resources using different HTTP methods (e.g., GET, POST, PUT, DELETE) to check if the access controls are enforced consistently.

Analyze Server Responses

Pay attention to the application’s responses. If you get different responses for unauthorized requests, such as an error message, it could indicate potential IDOR issues.

Confirm Vulnerabilities

Once you identify a potential IDOR vulnerability, verify its impact by accessing unauthorized resources or performing unauthorized actions. Take screenshots or record the steps as evidence for reporting.

Report and Remediation

Document the identified IDOR vulnerabilities along with their impact and possible attack scenarios. Provide clear steps for reproducing the issue and suggest remediation measures. Report the findings to the development team and assist in fixing the vulnerabilities.

Remember, always obtain proper authorization from the application owners before performing any security testing, and never engage in any unauthorized activities that could harm the application or its users. Ethical hacking and responsible disclosure are essential in the field of web application security testing.

How to fix IDOR

Fixing IDOR in a web application requires implementing proper access controls and ensuring that users can only access resources they are authorized to. Here are some technical examples of how to fix IDOR vulnerabilities:

Use Indirect Object References

Avoid exposing direct references to sensitive resources like IDs in URLs or parameters. Instead, use indirect references such as unique tokens or session-based identifiers.


Example:
Instead of using https://example.com/users/1, use a unique token like https://example.com/users/j2h4k1.

How IDOR Works

Authorization and Validation Checks

Ensure appropriate user permissions by implementing strong server-side authorization and validation checks.


Example: If a user wants to view their order details, the server should verify their ownership before displaying the information.

URL Parameter Obfuscation

Encrypt or obfuscate URL parameters to make them harder to manipulate and guess by attackers.


Example: Instead of using plain numeric IDs, use encrypted or hashed values for IDs that are used in URLs.

Role-Based Access Control (RBAC)

Implement role-based access control to define what actions and resources each user role can access.


Example: Assign roles such as “admin,” “user,” and “guest,” and enforce access control based on these roles.

Hidden Endpoints

Avoid creating hidden or unpublished endpoints that can be accessed by altering URLs.


Example: If an endpoint is not meant to be publicly accessible, don’t expose it in the web application.

Limit User Access

Make sure users can only access their own resources, not others’


Example: If a user wants to view their profile, the application should only allow access to https://example.com/users/{current_user_id} and not permit access to other users’ profiles.

Proper Error Handling

Be cautious about the information revealed in error messages. Avoid exposing sensitive details about the application’s internal structure or resources in error responses.


Example: Instead of displaying “User ID not found” when trying to access an unauthorized resource, provide a generic error message like “Access denied.”

Test and Security Review

Regularly conduct security reviews, code audits, and penetration testing to identify and fix any potential IDOR vulnerabilities.

To minimize the risk of IDOR vulnerabilities and safeguard important data and resources on your web application, it is crucial to implement appropriate technical measures and adhere to best practices. Additionally, it is important to remain current with the latest security guidelines and employ secure coding practices.

As a Pentester, you would actively search for IDOR vulnerabilities during your testing and verify if the application correctly validates and authorizes user access to sensitive resources. To prevent IDOR issues, developers should implement proper access controls and use indirect references (e.g., using unique tokens or session-based identifiers) rather than exposing direct references in URLs or parameters.

Contact RedNode to save yourself from IDOR.