Prompt

How do I stop BOLA and IDOR attacks on public APIs?

Technology / Cybersecurity2 observationsLast seen Nov 10, 2026

Latest observation

Nov 10, 2026OpenAI APIWeb search: off

To stop BOLA (Broken Object Level Authorization) and IDOR (Insecure Direct Object Reference) on public APIs, the key is: never trust object IDs from the client. Every request that references an object must be checked against the authenticated user’s permissions on the server.

Core defenses

1) Enforce object-level authorization on every request

For every endpoint that reads, updates, deletes, or performs actions on an object:

  • Authenticate the caller
  • Resolve the object by ID
  • Verify the caller is allowed to access that exact object
  • Deny access if not authorized

This must happen for every object reference, not just at login or at the endpoint level.

Example:

  • Bad: GET /orders/12345
  • Good: server checks whether the authenticated user owns order 12345 or has a role that permits access

2) Use authorization checks in the data access layer

Don’t rely only on controller or route-level checks. Put access control where the object is loaded from the database.

Examples:

  • SQL query includes WHERE user_id = :current_user_id
  • Repository method only returns objects belonging to the current tenant/user
  • Policy layer enforces ownership before data is returned

This prevents developers from forgetting checks in one endpoint.

3) Avoid predictable identifiers where possible

This alone does not fix BOLA/IDOR, but it reduces easy exploitation:

  • Prefer UUIDs or random opaque identifiers over sequential integers
  • Avoid exposing internal database IDs directly

Important: opaque IDs are not authorization. Attackers can still guess or replay them if checks are missing.

4) Implement tenant and ownership scoping

For multi-tenant systems:

  • Every query should be scoped by tenant/org/account
  • Never allow cross-tenant object access by default
  • Derive tenant context from the authenticated session/token, not client-supplied parameters

5) Check authorization on nested and indirect references

BOLA often appears in:

  • user_id
  • account_id
  • invoice_id
  • document_id
  • file URLs
  • batch endpoints
  • GraphQL resolvers
  • webhook callbacks
  • export/download links

Validate each referenced object, including parent-child relationships.

6) Protect “action” endpoints, not just CRUD

Examples:

  • POST /orders/123/cancel
  • POST /users/456/reset-password
  • POST /reports/789/export

These can be just as dangerous as GET, PUT, or DELETE.

7) Don’t trust hidden fields or client-side restrictions

Attackers can modify:

  • request bodies
  • query parameters
  • path parameters
  • form fields
  • headers
  • GraphQL input objects

Anything the client sends is attacker-controlled.

8) Use a centralized authorization model

Use a consistent approach such as:

  • RBAC for role-based access
  • ABAC/policy-based authorization for fine-grained control
  • Reusable permission checks or middleware

Good practice:

  • Define policies once
  • Apply them uniformly across endpoints

9) Secure file/object access separately

For downloads and media:

  • Do not expose raw storage paths
  • Use signed, short-lived URLs
  • Verify authorization before issuing the URL
  • Ensure the file ownership/tenant matches the requester

10) Test for BOLA/IDOR explicitly

Add automated security tests that attempt:

  • Accessing another user’s object
  • Swapping IDs in path/body/query
  • Cross-tenant access
  • Enumerating sequential IDs
  • Accessing objects through alternative endpoints

Use both positive and negative tests.

Common mistakes

  • Checking only “is authenticated?” instead of “is authorized for this object?”
  • Relying on front-end filtering
  • Using sequential IDs and assuming they’re safe if “hard to guess”
  • Forgetting object checks in one endpoint or one service
  • Missing authorization in GraphQL resolvers or batch APIs
  • Returning too much data from list endpoints and assuming that’s okay

Practical secure pattern

A good pattern is:

  1. Authenticate user
  2. Determine user/tenant context from token/session
  3. Load object with ownership/tenant constraint
  4. If not found, return 404 or 403 depending on your policy
  5. Perform action only if policy allows it

Example

Instead of:

GET /api/orders/1001

Do server-side logic like:

order = db.find_order(id=1001, tenant_id=current_user.tenant_id)
if order is null:
    deny
if not can_view_order(current_user, order):
    deny
return order

Extra layers of defense

  • Rate limit object access attempts
  • Monitor for sequential ID probing
  • Log authorization failures
  • Add anomaly detection for unusual access patterns
  • Use security reviews for every new endpoint

If you want, I can also give you:

  1. a language/framework-specific example (Node, Python, Java, .NET, Go), or
  2. a secure API checklist you can hand to developers.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.