API access control: how to prevent exposure of another user’s data
API data exposure poses a serious risk to any product. User authentication alone does not protect every data object. This guide explains why each resource request needs an access check and how to test your own API for permission failures.
Authentication and authorization: the difference
OWASP distinguishes authentication, which establishes who a user is, from authorization, which determines what that user may do. The server must check access rights on every resource request, rather than only when the user signs in.
BOLA and IDOR vulnerabilities
BOLA (Broken Object Level Authorization) and IDOR (Insecure Direct Object Reference) arise when an endpoint accepts an object identifier without adequately checking the caller’s rights to that object. For example, accepting an object UUID without checking whether the current user may access it can expose private data.
A hidden button, a restriction in the interface and a hard-to-guess identifier do not replace server-side access checks. A deliberately public object, such as a published article, may be accessible without login. Assess the resource’s purpose and the product’s rules, rather than treating any API response as a vulnerability.
How to test API access control
Start with a matrix of resources, owners, permitted roles and allowed operations. Test it with two dedicated test accounts and synthetic objects. In the fictional training project “Beacon”, test user A creates a note with a unique marker; test user B should be denied access to it.
For each operation, record the expected and observed result: the owner sees their own note, the other test account cannot see it, and a visitor without a session receives no private content. The exact denial status depends on the API contract; what matters is that the response body contains no protected fields. Use only objects created for testing with synthetic values.
- A request for a private object without login should be denied.
- Test account B must not receive a private object created by test account A.
- The response body must not disclose the synthetic private value.
How to fix permission failures
Determine the current user from a verified session instead of trusting a supplied owner_id. Look up private objects within the set the user may access, and account for the tenant or organization and the user’s role.
Apply the same policy to lists, search results, exports and attachments. Protecting a note’s detail page does not help if its text appears in a general search response. In a product serving several organizations, verify organization membership too: a role alone does not grant access to every customer’s data.
Priorities for verification and remediation
Start with the most sensitive resources, assign owners to the remediation tasks and repeat the tests after changes. A single permission failure may affect several endpoints, so review the shared access policy rather than fixing only one page.
What to give your developer
A useful assessment produces a reproducible task with clear expected behavior. Record the affected operation, test-account roles, private-object type and a minimal response example with sensitive values masked. After the fix, repeat the negative tests and confirm that the owner’s legitimate access still works.
- Add automated tests for successful owner access and denial to another test user.
- Assign a remediation owner and check every operation using the shared access policy.
- Prioritize messages, documents, payment data and other sensitive resources.