Broken Access Control and IDOR, Explained
If you are reading this, you have probably seen "Broken Access Control" at number one in the OWASP Top 10, and "IDOR" in bug-bounty reports, and you want to know what these mean, why they are so common, and why they are so easy to miss.
By the end you will be able to explain what access control is and how it differs from login, describe vertical and horizontal privilege escalation, recognise IDOR and the other common patterns in code and in URLs, test for them with two accounts, and apply the rules that prevent them. It builds on the OWASP Top 10 overview. Every technique here is for understanding and for practice on labs you own or are allowed to test.
1. What access control is
An application has three jobs that are easy to confuse. PortSwigger describes access control as depending on all three:
| Job | The question | Example |
|---|---|---|
| Authentication | Who are you? | Logging in with a password and a code |
| Session management | Is this request from the same person who logged in? | A session cookie attached to each request |
| Access control | Are you allowed to do this? | A normal user cannot open the admin panel; you can read your invoices but not mine |
Access control (also called authorization) is the application of constraints on who or what is authorized to perform actions or access resources. Logging in proves who you are. It says nothing about what you may do. Broken access control is when those constraints are missing, incomplete or only enforced in the wrong place, so users can act outside their permissions.
OWASP lists it first in the 2025 Top 10 (A01:2025), and describes the usual results: unauthorized disclosure of data, modification or destruction of data, or performing a business function outside the user's limits. Unlike injection, it often needs no strange input at all: only a request the developer forgot to check.
2. Two directions of getting too much access
| Kind | What happens | Example |
|---|---|---|
| Vertical | A user gets access to functions meant for a higher privilege level | An ordinary customer opens the administrator page |
| Horizontal | A user gets access to resources belonging to another user at the same level | One customer views another customer's bank account |
| Horizontal to vertical | Horizontal access to a privileged user's account leads to higher privileges | Reading the administrator's account page reveals their password, and the attacker logs in as the administrator |
These are the same ideas as in Privilege Escalation, seen from the web application's side. The hotel picture still works: vertical is reaching the master-key door, horizontal is opening another guest's room.
A third group is context-dependent control: rules that depend on the state of a process, for example "you may not change an order after it has been paid". Skipping a step or repeating a request can break these.
3. The common patterns
Pattern 1: Unprotected functionality
The application hides a function by not linking to it, but never checks the user when the function is requested. A page such as https://example.com/admin is not shown in the menu for normal users, yet anyone who types the address gets in. Hidden is not protected. Addresses leak: through robots.txt, in JavaScript files, in old links, or by guessing common names. One of OWASP's own examples is someone requesting a restricted page such as /app/admin_getappInfo directly, without going through the interface. This is forced browsing: requesting addresses that the interface never offered.
Obscure addresses do not help. PortSwigger notes that hiding sensitive functionality does not provide effective access control, because users might discover the obscured URL in a number of ways.
Pattern 2: Trusting a parameter that the user controls
The application decides your role from something you can edit:
https://example.com/login/home.jsp?admin=true
or from a hidden form field, a cookie such as role=user, or a value in the request body. If the attacker changes it, the application believes them. The rule: never take permission information from the request. Get it from server-side session data.
Pattern 3: Insecure direct object reference (IDOR)
An object is anything the application stores: an invoice, a message, a profile, a file. A direct reference is an identifier in the request that points straight at it. An IDOR exists when the application looks up the object by that identifier and returns it without checking that the logged-in user is allowed to have it. PortSwigger describes the cause as using user-supplied input to access objects directly.
A typical case: a customer sees their own account at
https://example.com/customer_account?customer_number=132355
If changing 132355 to 132356 shows another customer's account, the application is vulnerable. The identifier could also be a file name (PortSwigger's example is chat transcripts saved as numbered files such as /static/12144.txt, where changing the number shows another user's transcript), a document ID in an API call, or a field in a JSON body.
IDOR is most commonly a horizontal access control failure, though it can be vertical when the object belongs to a higher-privileged user. And it often sits in APIs that a mobile app or a single-page app uses, where there is no page for a human to look at, only identifiers in requests.
Random or unguessable IDs are not a fix. Using UUIDs instead of sequential numbers makes guessing harder, but an identifier leaks easily (in a shared link, an email, a log, another API response). The server must still check ownership.
Pattern 4: Controls that only exist in the browser
The interface hides a button or disables a field, but the server accepts the request anyway. OWASP gives this scenario: a restriction that exists only in the front end can be bypassed by calling the backend directly with a tool such as curl. The browser is not a security boundary, because the attacker controls their own client.
Pattern 5: Weak or inconsistent enforcement
| Weakness | What goes wrong |
|---|---|
| Only some HTTP methods are checked | The restriction covers one method, but if an attacker can use GET (or another method) on the restricted URL to perform the action, the control is bypassed |
| Path matching differences | The rule matches one spelling of the address, but a request to /ADMIN/DELETEUSER may still be mapped to the /admin/deleteUser endpoint, or a trailing slash gets past the rule |
| Platform-level rules bypassed by headers | Some frameworks allow a header such as X-Original-URL to override the path after the front-end check |
| Checks on the first step only | A multi-step process (view, confirm, submit) checks the user on step one, but the final step trusts that earlier steps were checked |
Trusting the Referer header |
The client controls that header, so it proves nothing |
| Static files with guessable names | Files served directly, such as numbered chat transcripts, skip the application's checks, so changing the number reveals another user's file |
| Location-based rules | Restrictions based on the visitor's country can often be bypassed with proxies or VPNs |
4. The code behind it
A vulnerable endpoint in Python (Flask):
@app.route("/api/invoices/<int:invoice_id>")
@login_required
def get_invoice(invoice_id):
invoice = db.get_invoice(invoice_id)
return jsonify(invoice) # any logged-in user can read ANY invoice
@login_required only checks that you are logged in (authentication). Nothing checks that the invoice is yours. The fix is to tie every lookup to the current user:
@app.route("/api/invoices/<int:invoice_id>")
@login_required
def get_invoice(invoice_id):
invoice = db.get_invoice(invoice_id)
if invoice is None or invoice.owner_id != current_user.id:
abort(404) # same answer for "missing" and "not yours"
return jsonify(invoice)
Or, safer still, make the database query itself include the owner so that a wrong one finds nothing:
invoice = db.get_invoice(invoice_id, owner_id=current_user.id)
For role-based functions, check the role on the server, every time, and let the default be "no":
def require_role(role):
def wrap(fn):
@wraps(fn)
def inner(*a, **kw):
if role not in current_user.roles:
abort(403)
return fn(*a, **kw)
return inner
return wrap
@app.route("/admin/users")
@login_required
@require_role("admin")
def admin_users(): ...
Returning the same error for "does not exist" and "not yours" (404 in the example) avoids telling the attacker which identifiers exist.
5. How testers find it
Broken access control cannot be found by sending strange characters, because the requests are perfectly normal. It is found by comparing what different users can do. Automated scanners find little of it because they do not know who should be allowed to see what, so a person has to do the comparing.
- Create two accounts with the same role (A and B), and one with a higher role if you can (an admin account in a test environment).
- As A, use the application normally and note every request that has an identifier or sensitive function.
- Replay those requests as B (swap the session cookie or token) and see if B can read or change A's objects. That tests horizontal access.
- Replay admin-only requests as a normal user, and with no session at all. That tests vertical access and missing authentication.
- Change identifiers in URLs, bodies and headers.
- Try different methods (GET, POST, PUT, DELETE) and path variants.
- Check the functions the interface hides: look through JavaScript files and API documentation for addresses that are not linked.
Tools such as Burp Suite help record and replay requests, and extensions can automate the "same request, different user" comparison. Practise only on labs or with written permission.
| Resource | What you get |
|---|---|
| PortSwigger Web Security Academy: Access control | Labs for every pattern above, including IDOR and multi-step bypass |
| OWASP Juice Shop | A shop with broken access control challenges |
| OWASP Web Security Testing Guide | Step-by-step authorization testing |
6. How to prevent it
OWASP's guidance, in plain words:
| Rule | What it means |
|---|---|
| Deny by default | Except for public resources, refuse unless a rule explicitly allows it. A forgotten page then fails safe |
| Enforce on the server, always | Never rely on hidden buttons, hidden fields, cookies or client logic |
| Build the check once and reuse it | One shared mechanism (middleware, a policy engine, a decorator) is easier to get right than a hand-written check in every function |
| Enforce record ownership | The question is not "may this user use invoices?" but "may this user see this invoice?" |
| Use a declarative access control framework | State the rules in one place instead of scattering them |
| Do not expose directory listings, backup files or version-control folders | Disable listing, and keep .git folders and backups out of the web root |
| Log failures and alert | Repeated denied requests often mean someone is probing |
| Rate limit API and controller access | Reduces the harm from automated tools that try thousands of identifiers |
More habits that help:
- Give every user the least privilege they need. A normal user's account should not be able to do administrator things even if a check slips.
- Treat identifiers as public. Assume an attacker can learn any ID, and check access anyway.
- Write automated tests for authorization (user A cannot read B's data; a normal user gets 403 on every admin route). Add a test whenever you add an endpoint.
- Review new endpoints with the question "who is allowed to call this, and where is that checked?"
7. Common mistakes
| Myth | The facts |
|---|---|
| "Users must log in, so it is secure" | Logging in is authentication. It does not decide what each user may access |
| "The admin page is not linked anywhere" | Hidden is not protected; addresses are easy to find or guess |
| "Our IDs are random UUIDs" | That makes guessing harder, but links, logs and other responses leak them. Check ownership anyway |
| "We hide the button for normal users" | The server must still reject the request. Attackers do not use your interface |
| "A scanner will find it" | Scanners cannot know who should see what. A human has to test with several accounts |
| "Only the web pages matter" | APIs, downloads, exports and background jobs need the same checks |
| "403 on the page means the data is protected" | The same data might be reachable through an API, an old route, or another method |
Closing
Broken access control is the failure to enforce who may do what. It does not need clever tricks: the attacker changes a number, opens a page the menu did not offer, or edits a value the server should not trust. The defences are old and simple, and just have to be applied everywhere: deny by default, check on the server, tie every object to its owner, and test with more than one account.
Keep these points:
- Authentication says who you are; access control decides what you may do.
- Vertical means reaching a higher level. Horizontal means reaching someone else's data. IDOR is typically a horizontal failure.
- Hiding a link, a button or an ID is not protection.
- Check ownership of every object, on the server, on every request.
- Test with two accounts; scanners find little of this.
- It is the number one risk in the OWASP Top 10 and now includes SSRF.