IDOR(Insecure Direct Object Reference)

Anindya Sankar Roy
4 min readSep 10, 2023

What is IDOR ??

An IDOR, or Insecure Direct Object Reference, is a type of security vulnerability that occurs when an application provides direct access to objects based on user-supplied input. In simpler terms, it happens when an attacker can manipulate input, such as changing URLs or form data, to access resources or perform actions they are not authorized to do.

Types of IDOR ?

Insecure Direct Object Reference (IDOR) vulnerabilities can occur in various contexts within web applications. They can manifest in different forms, including GET-based IDOR and other types. Here’s an overview of GET-based IDOR and some other common types of IDOR vulnerabilities:

  1. GET-based IDOR (URL Manipulation):
  • Numeric IDOR: This occurs when an application uses numeric identifiers in the URL to access resources or data, and attackers manipulate these numbers to access unauthorized data. For example, changing the numeric ID in a URL from example.com/user?id=123 to example.com/user?id=124 to access another user's data.
  • Username-based IDOR: In this case, the attacker manipulates usernames or other identifiers in GET requests to access or modify data belonging to different users. For instance, changing the username in a URL from example.com/profile?username=johndoe to example.com/profile?username=admin to access an admin's profile.
  • Resource Path Manipulation: Attackers may manipulate file paths or resource identifiers in GET requests to access unauthorized files or data. For example, changing the file path in a URL from example.com/download?file=report.pdf to example.com/download?file=confidential.pdf to access sensitive data.

2. POST-based IDOR (Form and Parameter Manipulation):

  • In this scenario, attackers manipulate form fields or parameters in POST requests to access or modify data or perform unauthorized actions. This can include changing hidden fields, such as user IDs or privileges, in a form submission to escalate privileges or gain unauthorized access.

3. Cookie-based IDOR:

  • Attackers can manipulate cookies or session data to impersonate other users or gain unauthorized access. This can involve modifying session tokens, user IDs, or roles in cookies to escalate privileges or access restricted areas of an application.

4. API-based IDOR:

  • IDOR vulnerabilities can exist in APIs when attackers manipulate API endpoints, parameters, or headers to access or modify data or perform unauthorized actions. This is often seen in RESTful APIs where resource identifiers or parameters are manipulated.

5. Database-based IDOR:

  • In database-driven applications, attackers may tamper with SQL queries or database parameters to access, modify, or delete records that they are not authorized to access. This can lead to data leakage or data manipulation.

6. Session-based IDOR:

  • Attackers can manipulate session variables or tokens to gain unauthorized access or privileges within an application. They may change session IDs or session data to impersonate other users.

Mitigation for IDOR

Mitigating Insecure Direct Object Reference (IDOR) vulnerabilities requires a combination of secure coding practices and security controls tailored to the specific context of the application. Here are general mitigation strategies for various types of IDOR:

  1. GET-based IDOR (URL Manipulation):
  • Implement Proper Authorization: Use strong authorization checks to ensure that users can only access or modify resources they are authorized for.
  • Avoid Sequential or Predictable Identifiers: Use non-sequential or unpredictable identifiers for objects to make it harder for attackers to guess valid references.
  • Encode Sensitive Data: If sensitive information must be included in URLs, ensure it’s properly encoded or hashed.

2. POST-based IDOR (Form and Parameter Manipulation):

  • Validate User Input: Validate and sanitize all user inputs to prevent malicious input from being processed.
  • Use Hidden Fields Securely: Avoid relying solely on hidden fields for security. Always verify user permissions on the server side.
  • Implement CSRF Protection: Use anti-CSRF (Cross-Site Request Forgery) tokens to protect against attacks that manipulate POST requests.

3. Cookie-based IDOR:

  • Secure Cookies: Ensure that session cookies are secure by setting the HttpOnly and Secure flags, as well as using strong encryption for session data.
  • Regenerate Session Tokens: Reissue session tokens upon login or privilege changes to mitigate session-based IDOR.

4. API-based IDOR:

  • Enforce Strong API Authentication: Implement robust authentication mechanisms, such as API keys, OAuth, or JWTs, and authorize users based on their roles and permissions.
  • Use Rate Limiting: Implement rate limiting on API requests to prevent abuse or enumeration attempts.
  • Validate and Sanitize Inputs: Validate and sanitize all input data from API requests.

5. Database-based IDOR:

  • Use Prepared Statements: Employ prepared statements or parameterized queries to prevent SQL injection attacks and enforce proper access controls.
  • Implement Role-Based Access Control: Define and enforce strict role-based access control (RBAC) to limit database access to authorized users.

6. Session-based IDOR:

  • Store Session Data Securely: Ensure that session data is stored securely and cannot be easily manipulated.
  • Regenerate Session IDs: Reissue session IDs upon login or privilege changes to mitigate session-based IDOR.

7. General Best Practices:

  • Apply the Principle of Least Privilege: Ensure that users, whether through URLs, forms, or APIs, only have access to the resources and actions they need for their role or function.
  • Conduct Regular Security Testing: Perform thorough security testing, including penetration testing and code reviews, to identify and remediate IDOR vulnerabilities.
  • Educate Developers: Train developers on secure coding practices, emphasizing the importance of input validation and access control.
  • Implement Web Application Firewalls (WAFs): Use WAFs to help detect and block IDOR attacks in real-time.

--

--

Anindya Sankar Roy

IoT Security Researcher | Bug-bounty Hunter | Freelancer | Jiu-jitsu Athlete