---
title: "Possible Insecure Direct Object References (IDOR)"
description: "HawkScan test information for plugin 421001: Possible Insecure Direct Object References (IDOR)"
url: https://docs.stackhawk.com/vulnerabilities/421001/
---

[Back to Index](https://docs.stackhawk.com/vulnerabilities/)

# Possible Insecure Direct Object References (IDOR)

###### Reference

- **Plugin ID:** 421001
- [**CWE:** 639](https://cwe.mitre.org/data/definitions/639.html)
- **Risk:** High
- **Type:** Passive
- **Category:**

###### Resources

- <https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html>
- <https://cwe.mitre.org/data/definitions/639.html>

### Remediation

To mitigate the risk of Insecure Direct Object References (IDOR) vulnerabilities in your OpenAPI specification, consider implementing the following measures:

1. **Proper Access Controls:** Ensure that access controls are properly implemented and enforced. Use OpenAPI security schemes to define authentication and authorization requirements. For example, use OAuth2 security schemes for more granular control over access to API endpoints.

   ```yaml
   securitySchemes:
     OAuth2:
       type: oauth2
       flows:
         authorizationCode:
           authorizationUrl: https://example.com/oauth/authorize
           tokenUrl: https://example.com/oauth/token
           scopes:
             read: Read access
             write: Write access
   ```

2. **Indirect Object References:** Replace direct object references with indirect ones. Utilize a combination of unique, non-sequential IDs and user-specific tokens. In OpenAPI, define parameters that are not predictable.

   ```yaml
   paths:
     /items/{itemId}:
       get:
         summary: Get an item
         parameters:
           - name: itemId
             in: path
             required: true
             schema:
               type: string
               format: uuid
   ```

3. **Context-based Access Controls:** Define role-based access control in your OpenAPI specification. Utilize security scopes to restrict access based on user roles and the context of the request.

   ```yaml
   paths:
     /admin/data:
       get:
         summary: Access admin data
         security:
           - OAuth2: [admin]
   ```

4. **Input Validation and Sanitization:** In your OpenAPI spec, strictly define acceptable input formats, types, and lengths. Use regular expressions for pattern validation to ensure that only legitimate input is processed.

   ```yaml
   parameters:
     - name: username
       in: query
       schema:
         type: string
         pattern: '^[a-zA-Z0-9]{5,12}
   ```

   `Regular Security Testing and Code Reviews: Regularly test your API using tools that understand OpenAPI specifications. Automated testing can identify potential IDOR vulnerabilities based on your spec.`

`About

Insecure Direct Object References (IDOR) occur when an application allows direct access to objects based on user-supplied input. Recognized as a common security issue in web applications, IDOR vulnerabilities can lead to unauthorized access or actions. They were first highlighted in the OWASP 2007 Top Ten.

Risks

The risks associated with IDOR vulnerabilities include unauthorized access to sensitive data, privilege escalation, data manipulation or deletion, and legal/compliance implications. Addressing these vulnerabilities is crucial for maintaining data confidentiality, integrity, availability, and user trust.`

- **Regular Security Testing and Code Reviews:** Regularly test your API using tools that understand OpenAPI specifications. Automated testing can identify potential IDOR vulnerabilities based on your spec.

### About

Insecure Direct Object References (IDOR) occur when an application allows direct access to objects based on user-supplied input. Recognized as a common security issue in web applications, IDOR vulnerabilities can lead to unauthorized access or actions. They were first highlighted in the OWASP 2007 Top Ten.

### Risks

The risks associated with IDOR vulnerabilities include unauthorized access to sensitive data, privilege escalation, data manipulation or deletion, and legal/compliance implications. Addressing these vulnerabilities is crucial for maintaining data confidentiality, integrity, availability, and user trust.
