GuideIntermediate1 min read

Object-Level Authorization: The API Security Boundary People Miss

Prevent BOLA and IDOR by enforcing permission checks in the data access path and testing every alternate entry point.

Author
Pradeep Gajendra
Published
Updated

Scope of this article

Environment
TypeScript examples are framework-shaped pseudocode; supply actual imports and authenticated context.

Authentication answers who sent a request. Authorization answers whether that identity may access this particular object now. The most common API mistakes occur after authentication succeeds: one user alters an object ID and receives another user's data.

The IDOR / BOLA failure mode#

OWASP classifies broken object-level authorization as a leading API risk. UUIDs make enumeration harder but do not replace an access check [1].

unsafe.tstypescript
// WRONG: a signed-in user can supply any invoice ID.
const invoice = await db.query.invoices.findFirst({
  where: eq(invoices.id, params.id),
});
return Response.json(invoice);

Enforce ownership in the data access boundary#

safe.tstypescript
// Schematic Drizzle query; adapt to actual schema and auth context.
const [invoice] = await db.select().from(invoices).where(
  and(eq(invoices.id, params.id), eq(invoices.tenantId, session.tenantId)),
).limit(1);
if (!invoice) return new Response(null, { status: 404 });
if (!permissions.canReadInvoice(session, invoice)) {
  return new Response(null, { status: 403 });
}
return Response.json(invoice);

Scoping by tenant still does not prove the current user can read every invoice in that tenant. Domain roles, resource ownership, assignment state and organization membership are separate decisions. Prefer a centralized authorization policy that can be tested independently.

Fail closed across all entry points#

  • GET, PATCH, DELETE and bulk operations must all check object-level access.

  • Export/report endpoints, GraphQL resolvers, background jobs and file downloads need the same policy.

  • Do not trust user-supplied tenantId, ownerId, isAdmin or role flags.

  • Use short-lived presigned asset URLs only after policy checks and scope them to the specific object.

  • Log access denials with bounded metadata; never leak sensitive object contents into logs.

Regression matrix#

Minimum tests for each protected resource

Actor

Operation

Result

Unauthenticated

Read

401 / redirect to login

Authenticated same tenant, no grant

Read

403 or indistinguishable 404

Other tenant

Read, mutate, export

Denied

Authorized collaborator

Read

Allowed

Revoked collaborator

Read after revocation

Denied without stale cache

Sources

  1. [1]
    OWASP API1:2023 Broken Object Level Authorization

    OWASP · publication date unknown · API Security Top 10 2023 · retrieved 2026-11-02

Spotted an error? Use “Suggest a correction” in the discussion, or read our corrections policy.

Discussion

Sign in to join the discussion. Reading is always open.

Loading discussion…

Report comment