Deutsch
Security wikiAPI security

What is broken function level authorization (BFLA)?

Also known as: BFLA, API5:2023, function level authorization, vertical privilege escalation

BFLA means a normal user can call a function meant for admins, such as changing plans or deleting users. How it appears in Supabase apps, with tested SQL.

By Tim GeithnerPublished 2 min read

Short answer

Broken function level authorization (BFLA) is when an app does not check whether the caller’s role may use a function at all, so a normal user or a visitor can call an admin action. In Supabase apps the usual cause is an admin check that only exists in the React UI, or a database function that every role may execute. Deny by default and grant admin actions only to the server or to checked admins.

Ask an AI about this page:ChatGPTClaude

On this page

Broken function level authorization (BFLA) is when an app does not check whether the caller’s role or group may use a function, so a regular user, or a visitor without an account, can call actions meant for admins. It is number 5 in the OWASP API Security Top 10 (API5:2023). A missing role check is CWE-862 (opens in a new tab); a check that exists but is wrong is CWE-863 (opens in a new tab).

BFLA in an AI-built app

Ask an AI builder for an admin panel and you often get a React route that only renders for admins, plus a database function the panel calls with supabase.rpc("set_user_plan", …):

VulnerableAn admin function anyone can call
create function public.set_user_plan(target uuid, new_plan text)
returns void
language sql
security definer
set search_path = ''
as $$
  update public.profiles set plan = new_plan where id = target;
$$;

The admin check lives only in the React UI. In the database, the function is executable by the public roles, and security definer runs it with its owner’s rights, so the RLS policies on profiles do not stop it. Anyone with the public key can call it and give themselves the top plan. In our test this worked for a signed-in user and for a visitor without an account. OWASP describes the same pattern for APIs: an admin endpoint without its own check, found by guessing the URL or changing the HTTP method.

How to check your app

Run this in the Supabase SQL Editor. It lists every SECURITY DEFINER function in public that a signed-in user may execute:

Which privileged functions can a signed-in user call?
select p.proname as function_name
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
  and p.prosecdef
  and has_function_privilege('authenticated', p.oid, 'execute');

For every name it returns, decide: may every user call this? Then do the same for your edge functions and API routes: which of them change plans, credits, roles or other users, and where is the role check?

How to fix or prevent it

Deny by default, as OWASP recommends, and grant admin actions explicitly. If only your server should call the function, take it away from the public roles:

SafeFix: only your server may call it
revoke execute on function public.set_user_plan(uuid, text)
  from public, anon, authenticated;

After this, users and visitors get permission denied for function set_user_plan, while server code using the secret key (the service_role) can still call it. If admins must call it from the app, keep the grant but check the role inside the function, read from app_metadata or a roles table, never from data the user can edit. The full fixes are in Admin check only in the frontend and SECURITY DEFINER function without checks.

Frequently asked questions

What is the difference between BFLA and BOLA?

BOLA is about which object you may touch: your invoice, not someone else’s. BFLA is about which action you may call at all: a normal user should not be able to call ‘delete any user’ or ‘set plan’, no matter which object.

My admin page is hidden in the app. Isn’t that enough?

No. Hiding a button or a route in React only changes what the app shows. The function or endpoint behind it can still be called directly with the public key, so the role check has to happen on the server or in the database.

Can Supabase database functions be called by anyone?

Functions in the public schema can be called through the API by every role that has EXECUTE on them, and new functions are executable by the public roles unless you revoke it. Check each function that changes data or uses SECURITY DEFINER.

Sources

  1. 1.API5:2023 Broken Function Level Authorization — OWASP API Security Top 10
  2. 2.CWE-862: Missing Authorization — MITRE
  3. 3.CWE-863: Incorrect Authorization — MITRE
  4. 4.A01:2025 Broken Access Control — OWASP Top 10

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