Summary
An insecure direct object reference (IDOR) in a user profile API endpoint allows authenticated users to access other users' profiles by modifying the numeric ID in the request.
When authorization checks are based solely on user-supplied identifiers rather than the caller's identity and permissions, attackers can pivot across accounts and potentially access sensitive data at scale.
Affected context
This vulnerability occurs in an authenticated API endpoint that serves user profile data based on an id parameter supplied by the client.
The issue typically appears where:
- The application trusts client-controlled identifiers (e.g.,
/api/users/{id}) to select records - Authorization logic verifies that the caller is authenticated, but not that they are the rightful owner of the requested resource
- Object-level access control is missing or inconsistently enforced on profile read operations
It is most relevant in multi-user systems where profiles or account data are mapped to predictable numeric IDs or similar direct keys.
Exploit preconditions
- Attack surface: Authenticated web or mobile API endpoint that returns user profile data
- Required access: Valid user account or session; no elevated privileges needed
- Trigger point: An HTTP request where the attacker can modify the
id(path parameter, query string, or body field) to reference another user's profile - Why exploitation is possible: The backend uses the provided
iddirectly to look up and return a profile record without confirming that the authenticated caller is authorized for that specific resource, enabling horizontal privilege escalation through simple ID manipulation.
Why this happens
The underlying bug is a missing object-level authorization check, matching CWE-639: Authorization Bypass Through User-Controlled Key.
Instead of deriving the profile to be returned from the authenticated principal (e.g., session user ID, token subject) or verifying ownership/permissions, the endpoint trusts a client-controlled identifier to select database records.
This pattern leads to insecure direct object references (IDOR), where predictable or enumerable identifiers (like incremental integers) allow users to pivot across resources that should be isolated per account.
Potential impact
- Unauthorized reading of other users' profile information and associated personal data
- Enumeration of all user profiles by iterating over ID values
- Exposure of sensitive fields that may aid further attacks (e.g., email addresses, internal IDs, metadata)
- Regulatory and compliance impacts where personal or regulated data is exposed across accounts
- Loss of user trust due to cross-account data leakage
General mitigation guidance
Effective mitigation focuses on enforcing object-level access control and reducing reliance on client-controlled identifiers:
- Derive the target user profile from the authenticated identity (e.g., from the session or token claims) instead of trusting an
idparameter for self-profile endpoints. - Where access to other users' profiles is legitimate (e.g., admin or support tools), enforce explicit authorization checks tying each requested object to the caller's role and permissions.
- Introduce a dedicated authorization layer or middleware that evaluates access for every object fetch or mutation operation.
- Avoid using predictable identifiers as the sole reference when isolation is expected; consider opaque, non-enumerable identifiers or indirection layers where appropriate.
- Apply the principle of least privilege to API roles so that standard users cannot access data beyond their own resources, even if request parameters are manipulated.
How teams detect issues like this
Detection typically combines security testing, code review, and automated checks:
- Perform targeted authorization testing in QA and security assessments by manipulating IDs in authenticated API requests to confirm isolation between accounts.
- Use static analysis or custom linting rules to flag controllers/services that:
- Accept resource IDs from clients
- Query database records directly by those IDs
- Lack adjacent authorization checks or ownership validation.
- In code review, look for endpoints that read objects by ID and verify that each includes a clear authorization decision, not just authentication.
- Implement centralized authorization policies (e.g., policy-as-code) and require that all data-access layers call these policies when resolving user-owned resources.
- Monitor logs for unusual patterns such as single accounts accessing large ranges of IDs or sequential profile IDs, which may indicate IDOR probing.

