Deutsch
Security wikiAPI security

What is broken object level authorization (BOLA)?

Also known as: BOLA, API1:2023, object level authorization

BOLA is the API name for IDOR: an endpoint returns or changes an object without checking it belongs to the caller. Examples from Supabase apps and fixes.

By Tim GeithnerPublished 2 min read

Short answer

Broken object level authorization (BOLA) is the top risk in the OWASP API Security Top 10: an API endpoint accepts an object ID from the caller and acts on that object without checking that this caller may use it. In AI-built apps it shows up in edge functions and RPC functions that use admin rights and trust an ID from the request. Check ownership on the server or let RLS decide.

Ask an AI about this page:ChatGPTClaude

On this page

Broken object level authorization (BOLA) is an API flaw where an endpoint takes the ID of an object from the caller and reads or changes that object without checking that this caller may access it. It is ranked first in the OWASP API Security Top 10 (API1:2023), and OWASP calls it “extremely common in API-based applications”. It is the API name for what web developers call an IDOR.

BOLA in an AI-built app

Direct table queries from the browser are protected by RLS when it is set up. BOLA tends to hide in the places that skip RLS: edge functions that use the secret key and database functions declared SECURITY DEFINER. A typical example from a generated “download invoice” function:

Vulnerablesupabase/functions/invoice-pdf/index.ts
const { invoiceId } = await req.json();
const admin = createClient(url, Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!);
const { data } = await admin
  .from("invoices")
  .select("*")
  .eq("id", invoiceId)
  .single();
return new Response(JSON.stringify(data));

The function may even check that the caller is signed in. It never checks that the invoice belongs to them. Because the admin client bypasses RLS, any signed-in user can send another invoiceId and download someone else’s invoice.

How to check your app

  • List every edge function and every RPC function that receives an ID (id, userId, projectId, orgId) from the request.
  • For each one, find the line that proves the caller may use that object. A sign-in check alone is not enough; you are looking for a comparison with the owner or a team membership lookup.
  • Test it with two accounts of your own: call the function as user B with an ID that belongs to user A. The answer must be an error or nothing.

How to fix or prevent it

The simplest fix is to not use admin rights for user data at all. Create the Supabase client in the function with the caller’s own token, so RLS decides which invoices they can see. If the function really needs the secret key, read the user from the verified session token and add the owner to the query:

SafeOwner check in the query
const { data: { user } } = await supabase.auth.getUser(token);
const { data } = await admin
  .from("invoices")
  .select("*")
  .eq("id", invoiceId)
  .eq("user_id", user.id)
  .single();

Never take the owner from the request body; that is the bug described in Edge function trusts user_id from the request body. OWASP also recommends random, unpredictable IDs and tests for authorization logic, so a future change can’t quietly reopen the hole. If the problem is not which object but which action a user may call, such as an admin-only endpoint, that is the sister risk BFLA.

The two snippets above are sketches: url, token and the error handling come from your own function.

Frequently asked questions

Is BOLA the same as IDOR?

In practice, yes. Both mean that an object reference from the caller is used without an authorization check. CWE-639 lists IDOR and BOLA as alternate terms for the same weakness; BOLA is the name used in the OWASP API Security Top 10.

Does comparing the user ID in the request with the session fix BOLA?

Not on its own. OWASP notes that comparing the session user’s ID with an ID parameter is not enough. The check has to answer whether this user may access this specific object, which usually means looking up the object’s owner or team.

Can BOLA happen if every table has RLS?

Yes, through code that skips RLS: an edge function or a SECURITY DEFINER function that reads data with admin rights. Those paths need their own ownership check.

Sources

  1. 1.API1:2023 Broken Object Level Authorization — OWASP API Security Top 10
  2. 2.OWASP Top 10 API Security Risks – 2023 — OWASP API Security Top 10
  3. 3.CWE-639: Authorization Bypass Through User-Controlled Key — MITRE

Find this in your own app

ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.

Run a demo audit
  • Read-only access to your repository
  • Every finding with file and line
  • Fix prompts for Lovable, Cursor, Claude Code and Bolt