Broken Access Control and IDOR: The #1 Web Vulnerability

How broken access control and insecure direct object references happen, real attack examples, and robust fixes with centralised, deny-by-default authorizatio...

Published December 6, 2026

Broken access control means users can act outside their intended permissions: view another customer's invoice, edit someone else's profile, call admin APIs as a normal user. It tops the OWASP Top 10 because it is common, easy to exploit with nothing more than a browser's developer tools, and often devastating.

The concept

The classic form is an Insecure Direct Object Reference (IDOR): an endpoint like GET /api/invoices/1042 returns the invoice with that ID without checking that it belongs to the requesting user. Changing the number reveals other customers' data. Variants include missing function-level checks (admin endpoints reachable by anyone who knows the URL), mass assignment (setting role=admin in a profile update), and trusting client-side state like hidden form fields or JWT claims the client can influence.

Robust fixes are structural. Authorize on the server for every request, deny by default, and scope data queries to the current user or tenant rather than fetching by ID and checking afterwards. Centralise policy in one layer (middleware, policies, an authorization service) so it is consistent and testable, and write automated tests that try to access other users' resources.

How an IDOR works

Attacker (user 7)APIDatabaseGET /api/invoices/1042SELECT * FROM invoices WHERE id=1042invoice of user 12200 OK — data leaked
An IDOR: the query never checks ownership.

Common variants

VariantExampleFix
IDORFetch any order by IDScope queries: WHERE id = ? AND user_id = ?
Missing function-level check/admin/export works for normal usersRole checks in middleware/policies
Mass assignmentPATCH /me {"role":"admin"}Allow-list writable fields
Tenant leakageTenant A sees Tenant B data via filter paramTenant ID from session, never from client
Path traversal in file access/files?name=../../etc/passwdMap IDs to files; validate paths

Where authorization lives

Routerauthentication required by defaultPolicy layercan user X do action Y on resource Z?Data layerqueries scoped by user/tenantTestscross-user access attempts in CI
Defence in depth for authorization.

Practical examples

Scope queries to the current user (Laravel)

Fetching through the relationship makes other users' records unreachable.

public function show(Request $request, int $id)
{
    $invoice = $request->user()->invoices()->findOrFail($id);   // 404 for others
    return new InvoiceResource($invoice);
}

Policy-based authorization (Laravel policies)

One place to express the rule.

class InvoicePolicy {
    public function view(User $user, Invoice $invoice): bool {
        return $user->id === $invoice->user_id || $user->hasRole('billing-admin');
    }
}
// controller: $this->authorize('view', $invoice);

Automated IDOR test

Prove user A cannot read user B's resources.

def test_cannot_read_other_users_invoice(client, user_a, invoice_of_b):
    client.force_login(user_a)
    resp = client.get(f"/api/invoices/{invoice_of_b.id}")
    assert resp.status_code == 404

Common mistakes

  • Relying on unguessable IDs (UUIDs) instead of authorization checks.
  • Checking permissions in the frontend only.
  • Reading tenant or user IDs from request parameters.
  • Binding request bodies directly to models without allow-lists.

Key takeaways

  • Authorize every request on the server; deny by default.
  • Scope queries by user or tenant instead of checking after fetching.
  • Centralise authorization in policies or middleware.
  • Test cross-user access automatically.

FAQ

Do UUIDs prevent IDOR?

They make guessing harder but are not access control; IDs leak through URLs, logs and shared links.

403 or 404 for unauthorized resources?

404 avoids revealing that a resource exists; 403 is fine when existence is not sensitive.

What is RBAC vs ABAC?

Role-based access control grants permissions by role; attribute-based control evaluates attributes of user, resource and context, which suits ownership and tenant rules.

More Security articles