Skip to main content
Security guideReviewed

Broken access control and IDOR: where the check goes missing, and how to test for it

Broken access control is an application letting someone read, change or do something its own rules say they may not.

This guide explains horizontal and vertical access, the places in real applications where the check goes missing, and a two-account test matrix you can run against your own application, with a local lab that runs the matrix against a flawed and a fixed API.

Two-account access control test matrix, with a lab that runs it

Part 1 is the matrix: four accounts and a signed-out row, seven object routes, the expected result for every cell and the evidence to keep, usable on its own for an application you own or are authorised in writing to test. Part 2 is an illustration, not a client system: an invented expense app for two invented businesses, served by Node.js alone on 127.0.0.1 in a flawed and a fixed version, a runner that walks the matrix and prints every cell, and a regression test that fails on the flawed version and passes on the fixed one.

broken-access-control-idor.txt

Introduction5 lines

TWO-ACCOUNT ACCESS CONTROL TEST MATRIX Use it only on an application you own, or one you are authorised in writing to test, with test accounts and test records. Changing an identifier in a request to a system you do not own, without written authority from its owner, is not something this matrix is for. Part 1 is the matrix and works without the lab. Part 2 is the lab: an illustration that runs the same matrix on your own machine.

What broken access control is

An application with accounts makes two separate decisions on every request.

The first is who is asking. The second is whether that person may do this particular thing to this particular record. Access control is the second decision. OWASP's Top 10:2025 describes its job as enforcing policy so that users cannot act outside their intended permissions, and says failures typically lead to unauthorised information disclosure, modification or destruction of data, or a business function performed outside the user's limits.

Broken Access Control is A01, the first of the ten categories in the OWASP Top 10:2025. OWASP's page for the category says it keeps its position at number one, with some form of broken access control found in 100% of the applications tested.

MITRE's CWE list names the family and its shapes. CWE-284, Improper Access Control, is the broad entry: the product does not restrict, or incorrectly restricts, access to a resource from an unauthorised actor. Three more specific entries describe the shapes this page keeps returning to.

CWE-862, Missing Authorization, is a route that performs no authorisation check when someone asks for a resource or an action. CWE-863, Incorrect Authorization, is a route that performs a check but does not perform it correctly.

CWE-639, Authorization Bypass Through User-Controlled Key, which MITRE lists as a child of CWE-863, is one user reaching another user's data or record by changing the key value that identifies it.

IDOR, BOLA and the other names for it

IDOR stands for insecure direct object reference. CWE-639 lists it, and Broken Object Level Authorization (BOLA), among its alternate terms, with two caveats: OWASP's IDOR term is broader than CWE-639 because it also covers path traversal, and BOLA appears to have some overlap with CWE-639 but may also apply to other weaknesses.

OWASP's IDOR Prevention Cheat Sheet breaks the flaw into three ingredients: an object, such as an account, a document, a support ticket or a transaction; a reference to it, such as an ID, UUID, account number, token or slug; and a missing object-level authorisation check that lets a user reach an object they should not be able to.

In OWASP's API list, the object-level form is API1:2023, Broken Object Level Authorization, the first entry in the OWASP Top 10 API Security Risks 2023. Its neighbour, API5:2023 Broken Function Level Authorization, is about reaching a function rather than a record, and OWASP's API1 page draws the line between them: an attacker who reaches an endpoint or function they should not have access to is a case of BFLA rather than BOLA.

Horizontal and vertical access, and the tenant boundary

Access control failures are described by direction.

WSTG v4.2's privilege escalation test, WSTG-ATHZ-03, says people usually refer to vertical escalation when someone reaches resources granted to more privileged accounts, such as administrative privileges for the application, and to horizontal escalation when they reach resources granted to a similarly configured account, such as information about a different user in an online banking application.

Horizontal is the IDOR case: the same role, someone else's record. Vertical is privilege escalation in a web application: a function above the caller's role, such as approving, refunding, inviting users or changing roles. The two are independent. In the lab on this page, member a1 owns claim a1-claim-1 and may read and edit it, yet approving it is still a vertical failure, because approval belongs to the administrator. Owning a record does not grant every action on it.

Multi-tenant applications add a boundary of their own. When several customer businesses share one database, a member of one tenant reaching another tenant's records is horizontal in form and larger in effect: OWASP's Multi-Tenant Application Security Cheat Sheet notes that a single vulnerability can expose all tenants' data.

It lists cross-tenant data leakage, IDOR through manipulated tenant or resource IDs, and privilege escalation across tenants through admin functions among its key risks.

ASVS 5.0 requirement 8.4.1, at Level 2, asks multi-tenant applications to use cross-tenant controls so that a consumer's operations cannot affect tenants they have no permission to interact with.

Inside one tenant, a colleague is not automatically entitled to your records either. Whether they are depends on the application's rules. In the lab's expense app, members see only their own claims and the administrator sees every claim in the tenant; in a household budgeting app, family members might be meant to share.

Write the rule down before you test it. ASVS 5.0 requirement 8.1.1, at Level 1, asks for authorisation documentation that defines rules for restricting function-level and data-specific access based on consumer permissions and resource attributes.

A role check on its own does not settle horizontal access. MITRE's guidance for CWE-862 notes that role-based access control may not protect against horizontal authorisation, since it will not stop a user attacking others with the same role. OWASP's Authorization Cheat Sheet says role-based models do a poor job of object-level or horizontal decisions, and prefers attribute-based and relationship-based rules for application development.

Why signing in is not the same as being allowed

Authentication answers who is asking.

Authorisation answers whether they may. OWASP's Authorization Cheat Sheet keeps the two apart and puts the practical consequence plainly: a user who has been authenticated is often not authorised to access every resource and perform every action that is technically possible through a system. MITRE's entry for CWE-284 lists authentication, authorisation and accountability as separate protection mechanisms within access control.

The two get confused in code because a sign-in guard can be added to a whole group of routes at once, while a record check depends on each route's data. A route behind a "must be signed in" guard looks protected, and against a signed-out visitor it is.

The lab's flawed API shows the gap. Every route turns away a request with no session with a 401, so the signed-out row matches the expected result in all seven columns.

Every leak in the matrix comes from an account that is signed in: a member reading a colleague's claim, a member of another business reading a receipt, and each ordinary account approving a claim.

Next.js builds the distinction into its own audit checklist. Its data security guide asks, of each "use server" file, whether the user is re-authorised inside the action and whether the action checks ownership of the resource, which the guide labels as authorisation rather than authentication alone.

One tempting half-fix compares the id in the request with the signed-in user's id. OWASP's API1:2023 page says comparing the user ID of the current session with the vulnerable ID parameter is not a sufficient solution, and could address only a small subset of cases.

The limit is structural: a session-id comparison can only protect a route where the record is the user, such as /users/123. An invoice, a receipt or a job has an id of its own, and it is not a user id.

Sign-in flaws themselves, such as account enumeration, password reset and session handling, belong to the authentication failures guide in this library, and checking a token's signature and claims belongs to the JWT security guide. This page starts at the point where the server already knows, correctly, who is asking.

Why an unguessable identifier is not an access check

Switching from sequential numbers to UUIDs or other long random identifiers makes guessing harder, and that is worth having.

It is not an access check. OWASP's IDOR Prevention Cheat Sheet says that in some cases, complex identifiers such as GUIDs can make it practically impossible for attackers to guess valid values, but that even with them, access control checks are essential: if attackers obtain URLs for unauthorised objects, the application should still block their access attempts. The cheat sheet treats random identifiers as an additional defence-in-depth measure.

OWASP's API1:2023 page recommends random and unpredictable values as GUIDs for records' IDs, and in the same entry notes that object IDs can be anything from sequential integers to UUIDs or generic strings, and that whatever their type they are easy to identify in the request path, query string, headers or payload.

The Multi-Tenant Application Security Cheat Sheet puts it in one line: opaque, random identifiers can reduce enumeration, but they are not authorisation controls.

Identifiers travel. A random id can sit in the address bar, in a link a customer forwards, in an exported spreadsheet, in a support ticket, in browser history and in the responses the application itself sends. An export job can hand its id back to the person who started it, and from then on that id is a string anyone holding it can paste into a request.

The question the server has to answer is not whether the caller could have guessed the id, but whether the record it names is theirs.

Next.js applies the same thinking to its own Server Actions. Its data security guide says it creates encrypted, non-deterministic IDs for them, recalculated periodically between builds, and that this reduces the risk where an authentication layer is missing. It then says to treat Server Actions as reachable by direct POST requests regardless, and to verify authentication and authorisation inside each one.

Where the check goes missing in real applications

The route behind the main screen is the one a team tests simply by using the product.

The gaps sit on the other ways into the same data. Each one below is a column in the matrix, with the lab's version of the flaw beside it.

Direct identifiers in the path, query or body

WSTG-ATHZ-04, the WSTG v4.2 test for insecure direct object references, starts by mapping every place where user input is used to reference objects directly, such as a database row, a file or an application page. 1 min read

Nested resources under a parent the caller owns

A route such as /claims/:claimId/receipts/:receiptId carries two identifiers, and WSTG-ATHZ-04 notes that an object reference may be split between more than one parameter, with testing adjusted to match. 1 min read

Lists, search and filters

A list route answers with many records at once, so a missing filter leaks in bulk. 1 min read

Exports and reports

An export route has a query of its own, so the filter that protects the list screen does not come with it. 1 min read

Background jobs and their results

A background job has two places to lose the check. 1 min read

Administrative functions

An administrative function reached from an ordinary account is the vertical case. 1 min read

Framework entry points in Next.js and Supabase

In a Next.js application, every Server Action and route handler is a door of its own. 1 min read

Put the check on the server, next to the data, in one place

On the server.

OWASP's A01 says access control is only effective in trusted server-side code or serverless APIs, where the attacker cannot modify the check or its metadata. ASVS 5.0 requirement 8.3.1, at Level 1, asks that authorisation rules are enforced at a trusted service layer and do not rely on controls an untrusted consumer could manipulate, such as client-side JavaScript.

Hiding a button is good interface design and is not access control. OWASP's Authorization Decisions and Output Handling Cheat Sheet says UI checks can decide which buttons to display, but the operation itself still requires server-side authorisation.

Next to the data. The check needs to know who owns the record, so it belongs where the record is loaded. OWASP's IDOR Prevention Cheat Sheet recommends working out the current user from session information and looking records up through the datasets that user can access, and the Next.js authentication guide recommends a Data Access Layer that centralises data requests and authorisation logic.

A check made earlier, in middleware that has only seen the URL, cannot know whose receipt a receipt id points to.

In one place. OWASP's A01 asks for access control mechanisms to be implemented once and reused throughout the application, with deny by default for everything except public resources, and model access controls that enforce record ownership. OWASP's API5:2023 asks for a consistent, easy-to-analyse authorisation module invoked from all business functions, and the Authorization Cheat Sheet wants permission validated on every request, by technology that allows global, application-wide configuration rather than a check applied to every method or class one at a time.

The lab's fixed API is built that way. One policy object holds four rules, each answering a single question, such as whether this user may approve this claim. One function, decide, applies them in order: a record the caller may not read gets the same 404 as a record that does not exist, and a record they may read but not act on gets a 403.

Lists and the export start from readableClaims, the set the caller may read, so a request parameter can narrow the result but cannot widen it.

Every route goes through one of those two functions, and the receipt route adds one more condition, that the receipt belongs to the claim in the path.

The rules are relationships between the user, the record and the tenant, plus the role, which is the attribute- and relationship-based style the Authorization Cheat Sheet prefers. When a rule changes, it changes in one place.

Keep a second layer where the platform offers one. Supabase describes row level security as defence in depth, because as a Postgres feature it also protects data reached through third-party tooling. A policy in the database and a check in the application make the same decision twice, so on a path where both apply, a gap has to exist in both before data leaks.

404 or 403: what each response gives away

A refusal still says something.

RFC 9110, the HTTP semantics standard, defines 403 Forbidden as the server understanding the request and refusing to fulfil it, and allows an origin server that wishes to hide the current existence of a forbidden resource to respond with 404 Not Found instead.

Its definition of 404 covers both cases: the origin server did not find a current representation for the target resource, or it is not willing to disclose that one exists.

The difference matters for records. If the server answers 403 for a record that exists and 404 for one that does not, the status alone tells an outsider which identifiers are real. With sequential ids that turns into a list of every record in the system; with random ones it still confirms that a leaked or shared link points at something live.

OWASP's IDOR Prevention Cheat Sheet notes that a check made after loading the record can tell a missing object from one the caller may not access, and says that where the resource's existence is sensitive, the scoped lookup should map both cases to the same public response, such as a 404.

The lab uses a simple rule. If the caller may not read the record, the answer is the same 404, with the same body, as for a record that does not exist. If the caller may read it but not perform the action, the answer is 403, because it reveals nothing they could not already see.

In the matrix output, a1 gets 403 for approving their own claim, and the administrator gets 403 for editing a member's claim.

For a regression test, either refusal is evidence the leak is closed. OWASP's Authorization Regression Testing Cheat Sheet asserts a 403 or a 404 for its multi-user replay, never a 200 OK. What matters is consistency: compare the body and headers of the refusal for a record that exists with those for one that does not, because a different error message gives away the same thing a different status code would.

Running the matrix on your own application

The matrix on this page is built for an application you own, or one you are authorised in writing to test, using test accounts and test records.

Changing an identifier in a request to a system you do not own, without written authority from its owner, is not something this page helps with.

It follows the method in WSTG v4.2. WSTG-ATHZ-04 says the best way to test for direct object references is with at least two users who own different objects and, where relevant, users with different privileges such as administrators. WSTG-ATHZ-02 keeps a session open for each user, swaps the session identifier and the relevant parameters between them on every request, and treats the application as vulnerable if the responses are the same, contain the same private data or indicate a successful operation on the other user's data.

  • Seed two tenants. In tenant A, create the owner account (A1), a second ordinary account (A2) and an administrator. In tenant B, create one ordinary account (B1). Give A1 a record of every kind the matrix touches: a record, a child record under it, something to export and a finished background job.
  • Write the expected result for every cell before you send anything, from your own rules. The lab's expected results are a starting point. Change any cell your application decides differently, such as records a household is meant to share.
  • Send each request as each account, changing only the session. In the nested column, name a parent the caller owns and the child that belongs to A1.
  • Where a route accepts more than one method, try the others as well. OWASP's API5:2023 includes swapping the HTTP method, such as GET for DELETE, among its questions.
  • Restore the records between cells that change data, so one cell's change does not alter the next, and run changes and administrator actions only against test records.
  • Keep the evidence the matrix lists for every cell, including the cells that pass. A recorded refusal is what lets you answer later whether a route was checked.
  • If administrators belong to a single tenant, add a row for tenant B's administrator. An administrator check that forgets the tenant fails only in that row.

The lab: one API in a flawed and a fixed version

The lab is an illustration: an invented expense app shared by two invented businesses, a bakery and a plumbing firm, with four users, five claims, four receipts and two finished export jobs.

It is five files that use only modules shipped with Node.js, so there is nothing to install. data.mjs holds the records and issues each user a random session token, sent back in a cookie. api.mjs serves the same seven routes in two versions. matrix.mjs holds the matrix as data and walks it. run-matrix.mjs prints every cell, and access.test.mjs is the regression test.

The server listens on 127.0.0.1 and asks for port 0. The Node.js documentation says a port of 0 makes the operating system assign an arbitrary unused port, and that a server given no host accepts connections on the unspecified address, which is why the lab names 127.0.0.1 explicitly.

It was written and run on Node.js 26.0.0, and every output in the asset comes from that run; test timings will differ on your machine.

Against the flawed version, 17 of the 35 cells do not match the expected result, and every column has at least one mismatch. Against the fixed version, all 35 match. The regression test fails all seven columns on the flawed version and passes all seven on the fixed one.

Turning the matrix into a regression test

A matrix run once tells you about one build.

Run in the pipeline, it tells you whether the next change broke something. OWASP's A01 asks developers and QA staff to include functional access control in their unit and integration tests, and OWASP's API1:2023 says to write tests that evaluate the authorisation mechanism and not to deploy changes that make those tests fail.

OWASP's Authorization Regression Testing Cheat Sheet describes the shape the lab follows: the matrix kept as data a test runner can read, rather than in a spreadsheet; a multi-user replay for horizontal access; a role demotion check that sends administrator requests from every lower role, signed-out included; and a cross-tenant boundary test, where it says even a single leaked record identifier constitutes a critical failure.

It also says the suite must be a required check, so a pull request cannot merge while an authorisation test fails.

The lab's access.test.mjs is that idea at its smallest. It walks the whole matrix, runs one test per column, and fails with the list of cells that differ. Run with node --test, Node.js finds it by its .test.mjs name, and a failing test sets the process exit code to 1, which is what stops a pipeline.

A passing suite speaks for the cases it contains. OWASP's Authorization Cheat Sheet says automated unit and integration tests of access control logic can help reduce the number of security flaws that make it into production, and are not a substitute for a dedicated security test or penetration test.

If other customers' records were reachable

A failing cell on a build that matches production means real customers' records were reachable there too, and the finding is about the past as well as the present: the route was open before you found it.

Work through these in order.

  • Keep the evidence. Save the test's request and response, and copy the access logs for the affected routes before you deploy anything, in case your hosting keeps logs only for a limited window or per deployment.
  • Close the gap. Deploy the fix, add the failing cell to the regression test, and run the matrix again on the deployed build for that route.
  • Answer the question from the logs, not by opening more records. Look for requests to the affected route where the account in the session and the identifier in the path or parameters belong to different customers, and note which records and accounts were involved. Opening more real customers' records to measure the problem adds to it.
  • Bring in whoever handles privacy for your business early, and check what any cyber insurance policy asks you to do and when, before taking steps it may have wanted to hear about first.
  • Under the Notifiable Data Breaches scheme, the OAIC explains that an organisation or agency covered by the Privacy Act 1988 must notify affected individuals and the OAIC when a data breach is likely to result in serious harm to a person whose personal information is involved. Whether that applies to your finding is a question for your privacy adviser, not for this page.
  • Watch for the next attempt. OWASP's A01 recommends logging access control failures and alerting administrators when appropriate, such as after repeated failures. Once the fix is live, a run of 404s to one signed-in account asking for other people's records is that signal.

Where an outside security test fits

Your own matrix covers the routes you know about.

For a Clever Ops web application and API penetration test, the scope asks for two test accounts in each role, and accounts in two separate customer organisations if your application serves more than one, so access can be tried in both directions between users and between tenants. Every route that names a record by id is sent again from a second account that does not own the record, and requests only an administrator should be able to make are sent from a lower role's session and with no session (WSTG-ATHZ-02, WSTG-ATHZ-04; ASVS 5.0 requirements 8.2.1 and 8.2.2).

Destructive actions are off by default for real people's accounts and records that existed before the test, and reset, lockout and deletion checks run only on test accounts and test records where the rules of engagement allow them. The report gives each finding with redacted evidence, its business impact, a fix and the criteria the retest will use.

A report is evidence for your decisions, not a certificate. If a tender or contract requires a CREST-accredited provider, Clever Ops is not CREST accredited, so we refer that work to a provider that is. If Clever Ops built or hosts your application, the work is a security review rather than an independent test, and the report says who built it and who hosts it.

Frequently asked questions

It is an application letting a user read, change or do something its own rules say they may not, such as opening another customer's invoice or reaching an administrator function. It is A01 in the OWASP Top 10:2025. MITRE catalogues it as CWE-284, Improper Access Control, with missing checks (CWE-862), incorrect checks (CWE-863) and user-controlled keys (CWE-639) as more specific forms.

An insecure direct object reference is a route that takes an identifier from the request, such as an invoice number, and returns or changes that record without checking the caller may have it. OWASP's IDOR Prevention Cheat Sheet names three ingredients: an object, a reference to it, and a missing object-level authorisation check. MITRE's CWE-639 lists IDOR and Broken Object Level Authorization (BOLA) among its alternate terms, while noting that OWASP's IDOR term is broader than CWE-639 and that BOLA appears to have some overlap with it but may apply to other weaknesses too. API1:2023 is OWASP's name for the object-level form in APIs.

They make identifiers harder to guess, which OWASP treats as defence in depth. They do not stop someone who obtains a real identifier from a link, an export or a response. OWASP's IDOR Prevention Cheat Sheet says access control checks are essential even with complex identifiers.

Horizontal escalation reaches resources belonging to a similarly configured account, such as another customer's records. Vertical escalation reaches resources or functions granted to a more privileged account, such as an administrator's. WSTG v4.2 tests both, and an application can fail one while passing the other.

If the caller is not allowed to know the record exists, return the same 404 you return for a missing record: RFC 9110 allows an origin server to hide a forbidden resource that way, and OWASP's IDOR Prevention Cheat Sheet suggests it where existence is sensitive. A 403 suits a record the caller can already see but may not act on. Keep the response body the same as well as the status.

On an application you own or are authorised in writing to test, create two ordinary accounts in one tenant, one in a second tenant and an administrator, give one account test records of each kind, and send every object route as every account. Compare each answer with the result your rules expect. The matrix and lab on this page give the cells, the expected results and the evidence to keep.

No. Signing in establishes who is asking. It does not decide which records that person may read or change. In the lab on this page, every flawed route turns away signed-out requests, and 17 of the 35 cells in the matrix still break the expense app's rules.

Scope the right test for your application

Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.