An API can authenticate a request correctly and still disclose another customer's record. The failure is at the object boundary: the server accepts an identifier supplied by the caller but does not prove that the authenticated principal may act on that particular object. OWASP calls this broken object-level authorization (BOLA), historically also known as insecure direct object reference. It is a server-side authorization defect, not a property of whether an identifier is sequential, UUID-shaped, or difficult to guess.
This guide describes a controlled way to test the boundary in an application you own or are authorized to assess. Use test tenants and synthetic records. Do not swap identifiers against a real service or inspect another person's data. The goal is to establish that authorization is checked for every object operation and that denial does not reveal protected fields.
Create two ordinary test accounts, Alice and Bob, and one record owned by each. Record the IDs and access tokens in a local test environment. Alice should be able to read and update Alice's record; Bob should be able to read and update Bob's record. Neither should access the other's record. If the system has organizations, create one user in each tenant and repeat the test across tenant boundaries. Avoid administrator accounts for the initial test because broad privileges can conceal a missing user-level check.
The important fixture is a relationship, not a particular identifier format:
alice -> tenant A -> invoice A
bob -> tenant B -> invoice B
An opaque ID may reduce casual enumeration, but it is not an authorization control. A secure implementation makes the decision using the authenticated identity and the requested object's ownership or policy relationship.
List every API operation that accepts an object identifier in a path, query, body, nested object, or batch. Include reads, edits, deletion, exports, attachments, and actions such as approval or payment. Authorization bugs often appear in a secondary route even when the main GET endpoint is correct.
For each operation, run this matrix in a local or explicitly authorized test environment:
| Caller | Object | Expected result | | --- | --- | --- | | Alice | Alice's record | Allowed according to the role policy | | Alice | Bob's record | Denied without protected data | | Bob | Bob's record | Allowed according to the role policy | | Unauthenticated | Either record | Authentication required |
Use the same HTTP method and payload shape as the normal application. Compare more than status codes: inspect response fields, error bodies, timing where meaningful, side effects, and audit events. A response that returns 404 for an unauthorized ID can avoid confirming existence, but consistency is a product decision; the essential requirement is that protected data and actions remain unavailable. Do not assume 403 is always required.
Example using a local fixture and curl:
API=http://localhost:3000/api
curl -i -H "Authorization: Bearer $ALICE_TOKEN" "$API/invoices/$BOB_INVOICE_ID"
The shell variables above should contain disposable test credentials and IDs only. The expected response must not contain Bob's invoice fields. Repeat for PATCH, DELETE, and any export endpoint, but use disposable data so destructive checks cannot affect production.
A fragile design loads a record by ID and returns it before checking its owner. A stronger pattern constrains the query itself to the authorized scope. Pseudocode:
const invoice = await db.invoice.findFirst({
where: {
id: invoiceId,
tenantId: principal.tenantId,
},
});
if (!invoice) return notFound();
The exact query depends on the authorization model. Some records are shared, delegated, or governed by role-based policies. In those cases, use a central policy function or a scoped repository method that receives the principal and object context. Avoid duplicating subtly different checks across controllers. For an update, include the authorization predicate in the write when possible, then verify that exactly one eligible row changed. This reduces the gap between checking access and performing the action.
Do not trust an ownerId or tenantId sent in the request body. Derive identity from the validated session or token and derive object relationships from server-side records. If the client may choose a destination tenant, that choice needs its own permission check.
Object access is not limited to /invoices/{id}. Test nested routes such as /projects/{projectId}/files/{fileId} where the project belongs to Alice but the file belongs elsewhere. Test bulk endpoints with a mix of permitted and forbidden IDs. The API must not partially process a batch in an undocumented way or leak which IDs exist. Test GraphQL node IDs, download links, webhook replay endpoints, and search filters if present.
Also inspect indirect effects. An unauthorized request should not enqueue a job, send a notification, generate an export, mutate a relationship, or expose a signed URL. For asynchronous operations, follow the job status and result routes using both principals. A one-time URL is still a bearer capability: keep it short-lived, narrowly scoped, and avoid including sensitive data in logs.
Add tests around the service or API route using two principals and seeded records. A useful assertion checks both the denial and absence of a side effect:
expect(response.status).toBe(404);
expect(await response.text()).not.toContain(bobsPrivateMarker);
expect(mockQueue.publish).not.toHaveBeenCalled();
Use unique synthetic markers, such as BOB-PRIVATE-TEST-7F3A, so accidental disclosure is easy to detect. Test authorization failures before creating mutation assertions. Include a tenant-switch case and an elevated-role case to catch policies that are too broad as well as policies that are missing. A test suite should encode the intended sharing model, not merely assert that a route returns some error.
OWASP's API Security Top 10 describes BOLA as a risk in endpoints that act on records using IDs supplied by the client. NIST SP 800-53 access-control and information-flow controls provide a broader control catalog for organizations that need policy mapping. Neither checklist substitutes for modeling the application's real ownership and sharing rules.
Editorial status: Owner authorized publication without an individual reviewer. Written for authorized testing with synthetic data.