Key takeaways
- A successful login does not grant permission to every record, field, or action.
- Check object, function, tenant, and field-level rules on every server request.
- Test direct requests with separate identities, including export, download, bulk, and background paths.
- Assert both the denial response and unchanged persisted state.
What is broken access control?
Broken access control occurs when a caller can read or change data or perform an action beyond the permissions the application intends to grant. Authentication establishes who made a request; authorization decides whether that identity may perform this operation on this resource now. OWASP recommends denying by default and checking permissions on every request in its Authorization Cheat Sheet.
Common forms include changing an object ID to reach another user’s record, calling an administrative function as an ordinary user, crossing tenant boundaries, trusting an owner or role value supplied by the client, and changing protected fields through mass assignment.
Example: changing an invoice ID
Customer A can read /api/invoices/1842. They change the path to /api/invoices/1843. If the server loads an invoice by ID and returns it without checking the current principal’s relationship to that invoice, authentication succeeded but authorization failed.
The server should load the record through a trusted ownership or tenant relationship and enforce the action policy. A Laravel controller can make the decision explicit:
$invoice = Invoice::findOrFail($id);
$this->authorize('view', $invoice);
return new InvoiceResource($invoice);
The policy must represent the product’s real access model. For a team product, checking only user_id may incorrectly deny a valid collaborator or miss tenant membership rules. Do not accept owner_id, tenant_id, role, or is_admin from untrusted update input.
Which authorization paths should I test?
Create two users in separate tenants using synthetic data. As user A, request user B’s record directly, then try read and state-changing methods. Call privileged routes even if the interface hides them. Repeat for exports, downloads, nested resources, bulk actions, and asynchronous jobs because they may use different code paths.
For a denied update, assert the intended 403 or privacy-preserving 404, confirm that the response contains no protected fields, and reload the record to prove it did not change. In a feature test, this pattern is more useful than asserting only that a button is absent:
$this->actingAs($userA)
->putJson("/api/invoices/{$invoiceB->id}", ['status' => 'paid'])
->assertForbidden();
$this->assertDatabaseHas('invoices', [
'id' => $invoiceB->id,
'status' => 'open',
]);
Use the status code your application chose consistently. A 404 can avoid confirming that a record exists; a 403 can make the policy outcome clearer. The essential properties are no unauthorized disclosure and no unauthorized state change.
Common approaches that fail
Hiding a button, using unpredictable IDs, checking that an ID is numeric, or validating permissions only in the frontend do not enforce access control. A caller can send a direct request. A policy on the main page is also insufficient if an export endpoint or background job skips the same rule. Validate fields that can be updated and explicitly exclude privileged ownership and role fields.
Log repeated denied attempts when useful for detection, but avoid recording credentials or full private payloads. Use rate limits where automated guessing creates operational risk.
Limits and related guidance
An authorization policy is only as accurate as the business rules it implements. Shared access, delegated roles, and tenant membership need tests that represent real combinations. Revisit the policy when roles or relationships change, and use tests to keep the invariant visible.
For the 2025 OWASP category context and additional controlled examples, read the OWASP Top 10:2025 developer guide. For the identity checks that happen before authorization, see how secure API authentication should work.
← Back to all articles
Contact Blueleaf