/

CVE-2023-36331

Severity:

HIGH RISK

(8.2)

Insecure Direct Object Reference in xmall orderList API

CVE-2023-36331

Analyzed

Vulnerability type

Category:

Insecure Direct Object Reference

CWE:

CWE-639

Impact:

Unauthorized Access to Sensitive Order Data

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The /member/orderList API in xmall v1.1 performs insufficient access control on the userId query parameter, allowing attackers to request order data for arbitrary users.

By manipulating this parameter, an attacker can access other customers' order details whenever the API trusts the client-supplied user identifier without proper authorization checks.

Affected context

This vulnerability occurs in xmall v1.1 within the authenticated order management functionality exposed at /member/orderList.

The API appears to rely on a userId value supplied by the client to determine which orders to return, rather than deriving the user identity purely from the authenticated session or token.

In environments where session handling or API authentication is present but not tightly coupled to authorization checks, this design can allow one user to pull order information belonging to others.

Exploit preconditions

  • Attack surface: HTTP(S) API endpoint /member/orderList
  • Required access: Network access to the xmall application and the ability to invoke the order list API (typically as any logged-in or, in weaker deployments, even unauthenticated user)
  • Trigger point: Supplying a crafted or modified userId query parameter when calling /member/orderList
  • Why exploitation is possible: The backend logic appears to trust the client-provided userId without performing a robust authorization check that ties requested resources to the caller's authenticated identity, leading to an Insecure Direct Object Reference (IDOR) condition.

Why this happens

At its core, this issue stems from relying on user-controlled identifiers to make authorization decisions.

Instead of using the identity derived from the authenticated session or token, the API reads a userId from the request and uses it directly to query the order store.

This matches CWE-639: Authorization Bypass Through User-Controlled Key, where the application uses a key from the client to access data without confirming that the caller is entitled to that resource.

The insecure pattern is: select orders where user_id = request.userId without checking that request.userId matches the authenticated principal.

Potential impact

  • Attackers can view other users' order histories and details.
  • Exposure of personal information embedded in order records (names, addresses, contact details, or partial payment data depending on implementation).
  • Aggregation of business intelligence, such as customer behavior, purchase frequency, and product popularity, by scraping multiple user IDs.
  • Potential regulatory or compliance violations due to leakage of customer data.

General mitigation guidance

Effective mitigation focuses on enforcing server-side authorization tied to the authenticated user, rather than trusting client-supplied identifiers.

Recommended patterns include:

  • Derive the effective user identity from the session, token, or API key, and use that identity exclusively for order lookups (e.g., ignore or remove the userId parameter for end-user flows).
  • Implement object-level authorization checks that verify the requesting principal is permitted to access each order record before returning it.
  • Centralize authorization logic in reusable middlewares or service layers so resource ownership checks are applied consistently across endpoints.
  • Minimize the number of endpoints that accept arbitrary user or account identifiers directly from clients; where necessary (e.g., admin tooling), clearly separate them from normal user APIs and guard them with stronger authorization policies and roles.
  • Apply the principle of least privilege by ensuring that non-admin accounts can only ever access their own resources, regardless of request parameters.

How teams detect issues like this

Organizations can identify this class of vulnerability using a combination of review and testing:

  • Static analysis and code review:
  • Search for controller or service methods that accept user IDs or account IDs as parameters and directly use them in queries (e.g., where user_id = param_user_id).
  • Check that for each such usage, there is an explicit comparison between the requested ID and the authenticated user, or a central authorization call.
  • Flag endpoints that expose list or detail operations on sensitive entities (orders, invoices, profiles) without clear authorization logic.
  • Dynamic testing:
  • During QA or security testing, log in as one user and systematically change IDs in query parameters to see if resources from other users are returned.
  • Use automated API testing tools or scripts to iterate over likely userId ranges and observe whether cross-account data is exposed.
  • Policy and tooling:
  • Enforce patterns where controllers do not directly consume userId from request parameters for end-user operations.
  • Integrate security linters or SAST tools that understand authorization frameworks and can flag missing ownership checks around sensitive models.

Sources

SourceLink
github.comgithub.com/Exrick/xmall/issues/100

Frequently asked

questions

The issue can be exploited by any party that can reach the /member/orderList endpoint and is able to manipulate the userId parameter.

If the endpoint requires login but does not tie userId to the logged-in account, then any valid user could potentially access other users' orders.

Typically no.

In many IDOR-style flaws, a standard user account (or even an unauthenticated user, depending on deployment) is sufficient, as the weakness lies in missing or weak authorization checks rather than missing authentication.

The most robust fix is to stop trusting client-supplied identifiers for resource ownership.

Always derive the user identity on the server side from the authenticated context and ensure that queries for user-owned resources (like orders) are based solely on that identity, with explicit checks that the requester is allowed to see each returned record.

Design APIs with authorization in mind from the start:

  • Treat all client-supplied IDs as untrusted and require explicit ownership verification.
  • Centralize access control logic and adopt frameworks or libraries that provide built-in resource-level authorization primitives.
  • Add automated tests that exercise parameter tampering scenarios and incorporate security reviews into your development and CI/CD processes.
Find out what's already
exploitable in your codebase.