ThisCalculator

Everyday

How to Test an API for Broken Object Level

Updated · Standard formula, shown below

This guide walks you through testing an API for Broken Object Level Authorization (BOLA), a vulnerability where an attacker can access or modify objects (like user records, files, or orders) they shouldn’t be allowed to. You’ll learn a practical, step-by-step method to identify and confirm these flaws using only free tools and a browser, no prior security experience required.

What You’ll Need

  • An API endpoint you have legitimate access to (e.g., a test account on your own application or a sandbox environment).
  • A tool to send HTTP requests: Postman, Insomnia, or cURL (command line) all work.
  • Two or more accounts (or at least two different resource IDs) if possible, to compare access.
  • Basic understanding of HTTP methods (GET, POST, PUT, DELETE) and status codes (200, 403, 404).

Step-by-Step

  1. Identify a resource endpoint. Look at the API documentation or network traffic (browser DevTools → Network tab) to find URLs like /api/users/123, /api/orders/456, or /api/files/789. The key is a numeric or predictable ID in the path.
  2. Log in with your first account. Obtain a valid token (e.g., Bearer token, session cookie) by authenticating normally. Save this token for later.
  3. Make a legitimate request. Using your token, request the resource you own. For example, GET /api/users/123 should return your own data with a 200 status. Note the exact response structure.
  4. Change the ID to another value. Modify the ID in the URL to a different number (e.g., /api/users/124). Keep the same token. Send the request.
  5. Observe the response. If you get a 200 with data that isn’t yours, you’ve found a BOLA vulnerability. If you get a 403 (forbidden) or 404 (not found, often used to hide existence), the API is likely protected.
  6. Test with a second account (if available). Log out and log in with a different account. Take a resource ID you own from that account (e.g., /api/orders/456). Then, switch back to the first account’s token and try to access /api/orders/456. If you succeed, BOLA is confirmed.
  7. Test other HTTP methods. BOLA isn’t just about reading. Try PUT or DELETE on a resource you don’t own. For example, PUT /api/users/124 with a modified JSON body, or DELETE /api/files/124. Even if GET is blocked, these might not be.
  8. Test for IDOR in nested resources. Sometimes the object ID is in a sub-resource, like /api/accounts/123/transactions. Try changing the account ID to see if you can view another user’s transactions.
  9. Try alternative ID formats. If IDs are GUIDs (like a1b2c3d4-...), they’re harder to guess, but still test if you can find one via a public link or a shared resource. Also try array or batch endpoints like /api/users?ids=123,124.
  10. Document your findings. For each vulnerable endpoint, record the request (method, URL, headers, body) and the response. Note the impact: what data was exposed or modified? This is essential for a security report.

Common Mistakes

  • Only testing GET requests. BOLA often appears in write operations (POST, PUT, DELETE) even when reads are protected.
  • Assuming a 404 means safe. Some APIs return 404 for unauthorized access to hide resource existence. That’s good, but you should still test other methods and IDs.
  • Forgetting to test with a different user’s token. Using the same token to access your own resources with a different ID is the core test, but you must also cross-check between accounts to prove the flaw.
  • Ignoring indirect object references. Sometimes the ID is not in the URL but in a request parameter or a header (e.g., X-User-Id). Test those too.
  • Not testing authenticated endpoints. BOLA requires authentication; testing without a token may give a 401 (unauthorized) which is expected and not the vulnerability.

Tips

  • Use a systematic approach. Make a list of all endpoints from the API docs and test each one with a different ID. Automate with a script if you have many endpoints.
  • Look for patterns. If one endpoint is vulnerable, others likely are too. Check for consistent authorization checks across the API.
  • Check for UUIDs vs. sequential IDs. Sequential IDs (1,2,3) are easier to guess, but UUIDs can still leak via other endpoints (e.g., in a list response).
  • Test with a low-privilege account. A regular user account is best; admin accounts often have broad access that hides the issue.
  • Use a proxy tool like Burp Suite (free community edition) to intercept and modify requests easily, but the manual method above works fine.

Troubleshooting

  • You get a 401 (Unauthorized) on every request. Your token may have expired or you’re not sending it correctly. Check the Authorization header format (e.g., Bearer <token>).
  • You get a 403 (Forbidden) even on your own resource. The API might require a specific role or permission. Try using an account with higher privileges, or verify you’re using the correct endpoint.
  • You can’t find any IDs to test. Look at the API documentation for example requests, or create a new resource and note the ID returned in the response. Also check if the API returns a list of resources; those IDs are valid.
  • The response is always the same regardless of ID. The API might be returning a generic error message. Check the HTTP status code; if it’s always 200, the API might be ignoring the ID and returning your own data—that’s not BOLA but still odd.
  • You’re testing a third-party API without permission. Only test APIs you own or have explicit authorization to test. Unauthorized testing is illegal and unethical.

Frequently Asked Questions

What is the difference between BOLA and IDOR?

IDOR (Insecure Direct Object Reference) is a specific type of BOLA where the application uses user-supplied input to access objects directly without proper checks. BOLA is the broader category covering any broken object-level authorization.

Can BOLA be exploited without authentication?

No, BOLA requires an authenticated user. The flaw is that the authenticated user can access objects they shouldn’t. If no authentication is needed, that’s a broken authentication issue, not BOLA.

Is BOLA the same as Broken Function Level Authorization?

No. BOLA is about object-level access (e.g., a user’s own record), while Broken Function Level Authorization is about function-level access (e.g., admin-only endpoints). They are both in OWASP’s Top 10 under broken access control.

How can I prevent BOLA in my own API?

Always verify that the authenticated user has permission to access the specific object on every request. Use a central authorization layer, avoid using client-supplied IDs for authorization, and use unpredictable IDs (UUIDs) where possible.

What should I do if I find a BOLA vulnerability?

Report it to the API owner immediately. If it’s your own API, fix it by adding proper authorization checks. If it’s a third-party, follow responsible disclosure—contact their security team, don’t exploit it further.

Can I test BOLA with just a browser?

Yes, you can manually change the ID in the URL, but you’ll need to be logged in and the API must accept GET requests. For POST/PUT/DELETE, you’ll need a tool like Postman or a browser extension.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.