AICI · Free practical security guides · 9 min read
API authorization: how to test object access without attacking another account
A practical checklist for engineers to prevent broken object-level authorization in an API, with a safe two-account training scenario.
Authentication answers who made a request. Authorization answers whether that identity may read or change the particular resource. An endpoint can authenticate correctly and still expose another customer's record when it trusts an object identifier supplied by the browser. Use the following method only on applications you own or are expressly authorized to test.
Who this guide is for
Backend engineers, code reviewers, product security teams and developers of multi-tenant applications.
1. Describe the access rule before writing the endpoint
Write the expected decision for each action and resource: who owns the record, which organization it belongs to, and what roles may read or update it. Avoid interpreting an authenticated session as permission to access every identifier. In a multi-tenant API, checking the user's role without checking the requested object's tenant can still cross a boundary.
- List actors (owner, teammate, administrator), actions (read, edit, delete) and the resource ownership field.
- Use deny-by-default decisions and verify them server-side on every request, including internal routes.
- Define legitimate exceptions, such as an audited organization administrator, in policy rather than scattered UI conditionals.
2. Query within the authorized scope
Do not fetch a record by client-provided ID and assume the caller may use it. For a basic owner-only resource, include the authenticated user ID in the server-side lookup. For organizations, resolve trusted membership on the server and constrain by that organization. A hidden button or an opaque UUID is not an authorization control.
- Derive the caller from a verified server session, never from an untrusted userId parameter.
- Read or mutate using both the requested resource identifier and its permitted ownership or tenant scope.
- Treat 403 and 404 consistently with your information-disclosure policy; never return a forbidden record's body.
3. Test the negative cases and keep the evidence safe
A green happy-path test is insufficient. In an isolated test environment, create two ordinary accounts with distinct sample records. Assert that each can access its own data and cannot read, modify or remove the other's. Repeat the test across list endpoints, exports, nested paths and bulk operations. Avoid placing real customer data in tests or screenshots.
- Test anonymous, signed-in owner, signed-in non-owner and authorized administrator separately.
- Cover GET, PATCH and DELETE for cross-account IDs, plus pagination and search filters that might leak items.
- Record status, sanitized response and policy decision in test evidence; log failed authorization without sensitive payloads.
Worked example — hypothetical training API
A training app exposes GET /api/records/42. Test account A owns record 42; test account B owns record 57. A correct login for B does not make record 42 available to B. An insecure implementation searches only for id=42, then returns the record.
What the response should show
Change the server lookup to enforce the ownership predicate for the verified session. Re-run: A receives its own record; B receives a safe forbidden/not-found response without record content; an authorized administrative pathway is tested separately. The example demonstrates a decision rule, not a claim about a live AICI client.
Deliverable: an authorization matrix, scoped database query, automated negative tests and a concise remediation note. For production systems, adapt the rule to your actual tenancy and RBAC model.