What Is IDOR? Insecure Direct Object Reference Examples & How to Prevent IDOR Attacks
What is IDOR? See real insecure direct object reference examples, a worked lab test with Burp Suite, and how to prevent IDOR with server-side checks.
What Is IDOR?
Insecure Direct Object Reference (IDOR) is a web vulnerability that lets one user read, change, or delete another user's data by changing an object identifier — a user ID, invoice number, or file name — in a request the application never checks. It is an authorization failure, not an authentication failure: the attacker is logged in, but the application never verifies that the logged-in user is allowed to touch that specific object.
You change a number in the URL: /user/profile/123 to /user/profile/124. The page loads another user's name, email, and billing details. No password prompt, no error — just someone else's private data. This is IDOR: the app exposes internal object references (user IDs, invoice numbers, file paths) without checking whether the current user is authorized to access them.
IDOR is one of the most commonly reported web vulnerabilities in bug-bounty programs, and it sits at the heart of the OWASP Top 10. In the OWASP Top 10:2021 and the 2025 edition, Broken Access Control (A01) holds the number one spot, and IDOR is its classic example. In the OWASP API Security Top 10:2023, the same flaw is called BOLA — Broken Object Level Authorization (API1:2023) — and it is also number one. A joint advisory from the ACSC, CISA, and NSA (AA23-208A, July 27, 2023) warned that IDOR flaws are among the most routinely exploited access-control weaknesses. The flaw is old, well understood, and still everywhere — because it is a missing check, not a clever exploit, and a missing check is easy to leave out of one endpoint among hundreds.
The three ingredients
The OWASP IDOR Prevention Cheat Sheet describes three ingredients, and removing any one of them breaks the attack:
Remove the third ingredient and the first two are harmless. That is the most important point in this guide: IDOR is not caused by exposing IDs. It is caused by not checking them.
Authentication is not authorization
A common misunderstanding is that login protects data. It does not. Authentication answers "who are you?" Authorization answers "may you do this to this object?" An application can have perfect login and still be wide open to IDOR, because every logged-in user passes authentication — and then the application hands over whatever object the request names. IDOR is the gap between those two questions.
Prerequisites
Before studying IDOR, you should understand:
If any of those are new, read our Web Security Fundamentals guide first, then come back — the worked example below uses Burp Suite's Repeater, which that guide and our Burp Suite Introduction both cover.
How IDOR Works
Applications use identifiers to reference objects:
Every identifier the client can see is an identifier the client can change. The server receives a request, looks up the object by that identifier, and returns it — unless a check intervenes.
The vulnerable pattern
// Vulnerable — no authorization check
app.get('/api/invoices/:id', (req, res) => {
const invoice = db.invoices.findById(req.params.id);
res.json(invoice);
});
The attacker simply changes the ID:
GET /api/invoices/1001 -> User's own invoice
GET /api/invoices/1002 -> Another user's invoice (IDOR!)
Nothing about the second request looks suspicious. It is a well-formed, authenticated request for an existing object. The only thing wrong is that the user asking for invoice 1002 does not own it — and nobody checked.
Where identifiers hide
IDOR is not only about URLs. Object references appear in many places, and testers must check all of them:
| Location | Example | What to change |
|---|---|---|
| URL path | /api/users/123 | The number in the path |
| Query string | /download?file=report-1234.pdf | The file name or ID |
| POST body | {"user_id": 123, "action": "view"} | The user_id field |
| JSON API field | {"invoice_id": 1002} | The invoice_id value |
| HTTP header | X-Account-Id: 123 | The header value |
| Cookie | account=123 | The cookie value |
| JWT claim | "sub": "123" (unsigned change is not possible, but a stale or over-broad token may carry another user's ID) | The claim, if the token is forgeable or misissued |
The pattern is always the same: the client supplies an identifier, the server trusts it, and no ownership check runs.
Types of IDOR
Horizontal IDOR
Accessing resources at the same privilege level but belonging to another user — viewing another user's private messages, invoices, or medical records. This is the most common form, and the one most bug-bounty reports describe.
Vertical IDOR (Privilege Escalation)
Accessing resources requiring higher privileges — a regular user accessing an admin endpoint, such as changing /api/users/123/role from user to admin, or calling an admin-only export endpoint with their own low-privilege session. Vertical IDOR can lead to full privilege escalation.
File-Based IDOR
GET /download?file=user_1234_report.pdf
GET /download?file=user_5678_report.pdf
Download endpoints are a classic IDOR location: the file name is the reference, and the server streams whatever file is named. The same flaw appears in profile-picture uploads, document previews, and backup downloads.
API IDOR (BOLA)
In APIs, the same flaw is called Broken Object Level Authorization. A REST endpoint such as GET /api/v1/orders/4821 that returns any order to any authenticated caller is BOLA. Because APIs expose dozens of object endpoints, a single missing check can expose an entire data set — and because APIs return structured data, the exposure is easy to automate.
| Type | Attacker gains | Typical target | Severity |
|---|---|---|---|
| Horizontal IDOR | Another user's data at the same level | Profiles, invoices, messages, photos | High |
| Vertical IDOR | Higher-privilege functions or data | Admin panels, role changes, exports | Critical |
| File-based IDOR | Another user's files | Documents, reports, backups | High |
| API IDOR / BOLA | Any object the API serves | Orders, accounts, records, files | High to Critical |
IDOR vs BOLA
IDOR and BOLA describe the same flaw in different contexts. IDOR is the older, web-application term from the OWASP Top 10; BOLA is the API term from the OWASP API Security Top 10:2023, where it ranks API1 — the most common API vulnerability.
| Aspect | IDOR | BOLA |
|---|---|---|
| Context | Web applications (browser flows) | APIs (REST, GraphQL) |
| Reference | URL, form field, cookie | Path parameter, JSON body field |
| OWASP list | Top 10:2021/2025 A01 Broken Access Control | API Security Top 10:2023 API1 |
| Root cause | Missing object-level authorization | Missing object-level authorization |
| Fix | Server-side ownership check on every request | Server-side ownership check on every request |
If you can test for IDOR in a web app, you can test for BOLA in an API — the workflow is identical, only the transport changes. Our API Hacking Guide covers BOLA testing in depth, including GraphQL and JWT contexts.
Worked Example: Finding and Fixing IDOR in a Local Lab
Everything below runs against a local Flask document API with two test users (alice and bob) and four documents, deliberately missing the ownership check. Run it only on your own machine, never against a real site.
Step 1 — Build the vulnerable lab app
# lab_app.py — DELIBERATELY VULNERABLE, local lab only
from flask import Flask, request, jsonify
app = Flask(__name__)
DOCUMENTS = {
1: {"id": 1, "owner": "alice", "title": "Alice tax return", "body": "Salary: 52000"},
2: {"id": 2, "owner": "alice", "title": "Alice contract", "body": "Signed 2026-01-15"},
3: {"id": 3, "owner": "bob", "title": "Bob medical note", "body": "Appointment 2026-02-02"},
4: {"id": 4, "owner": "bob", "title": "Bob bank letter", "body": "Account ending 4417"},
}
@app.route("/api/documents/<int:doc_id>")
def get_document(doc_id):
# VULNERABLE: no ownership check — any logged-in user gets any document
doc = DOCUMENTS.get(doc_id)
if not doc:
return jsonify({"error": "not found"}), 404
return jsonify(doc)
if __name__ == "__main__":
app.run(host="127.0.0.1", port=5000)
pip install flask
python3 lab_app.py
Step 2 — Log in as alice and capture a request
Log in to the lab app as alice in the browser with Burp Suite intercepting. Open document 1. Burp captures:
GET /api/documents/1 HTTP/1.1
Host: 127.0.0.1:5000
Cookie: session=alice-session-token
The response is alice's own document — expected and legitimate.
Step 3 — Change the ID in Repeater
Send the request to Burp Repeater and change the ID from 1 to 3:
GET /api/documents/3 HTTP/1.1
Host: 127.0.0.1:5000
Cookie: session=alice-session-token
Illustrative response:
{"id": 3, "owner": "bob", "title": "Bob medical note", "body": "Appointment 2026-02-02"}
Alice just read bob's medical note. That is IDOR — confirmed in one changed number.
Step 4 — Enumerate with Intruder
To show the scale, send the request to Burp Intruder with the ID as the payload position and a numeric range of 1–100. Every ID that returns 200 is an accessible document. In a real application with sequential IDs, this is how one missing check becomes a full data breach: the attacker iterates through all IDs and downloads every record.
# Same check from the terminal, for the record
curl -s -b "session=alice-session-token" http://127.0.0.1:5000/api/documents/3 | jq .
Step 5 — Apply the fix
The fix is a server-side ownership check on every request:
# FIXED: check ownership before returning the document
@app.route("/api/documents/<int:doc_id>")
def get_document_fixed(doc_id):
current_user = request.cookies.get("session", "").replace("-session-token", "")
doc = DOCUMENTS.get(doc_id)
if not doc:
return jsonify({"error": "not found"}), 404
if doc["owner"] != current_user:
return jsonify({"error": "not found"}), 404
return jsonify(doc)
Two details matter. First, the check runs on the server, on trusted code the client cannot modify. Second, the fixed version returns 404 for both missing and not-owned documents, so an attacker cannot tell whether document 3 exists — there is no existence oracle leaking information.
Step 6 — Re-test and confirm
Repeat Step 3 against the fixed app. Alice requesting document 3 now receives:
HTTP/1.1 404 Not Found
{"error": "not found"}
The same request that exposed bob's data now returns nothing. Turn this two-account test into a regression test: every object endpoint should have a test where user A requests user B's object and expects a 403 or 404. If that test ever passes the wrong way, the build fails.
How to Prevent IDOR Attacks
Prevention is an architecture rule, not a per-endpoint scramble. The OWASP guidance and the worked example above both point to one rule: verify authorization on the server for every object, every time. Everything else is defense in depth.
The 7-layer prevention checklist
user_id or tenant_id values sent by the client for the caller's own actions. Take identity from the session.Prevention in code
The vulnerable Express handler from the "How IDOR Works" section becomes safe with two additions — authentication middleware and an ownership check:
app.get('/api/invoices/:id', authenticate, (req, res) => {
const invoice = db.invoices.findById(req.params.id);
if (!invoice) return res.status(404).send('Not found');
if (invoice.userId !== req.user.id) {
return res.status(403).send('Forbidden');
}
res.json(invoice);
});
Better still, scope the query so the unauthorized record is never loaded:
// Scoped query — the invoice must belong to the current user
const invoice = db.invoices.findOne({
where: { id: req.params.id, userId: req.user.id }
});
if (!invoice) return res.status(404).send('Not found');
Use indirect references
app.get('/my/invoices/:ref', authenticate, (req, res) => {
const invoiceId = sessionInvoiceMap[req.session.id][req.params.ref];
if (!invoiceId) return res.status(404).send('Not found');
const invoice = db.invoices.findById(invoiceId);
res.json(invoice);
});
Use unpredictable identifiers — as defense in depth only
CREATE TABLE invoices (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id INTEGER REFERENCES users(id)
);
Note: Unpredictable IDs are obfuscation, not security. Always pair with authorization.
Framework support
| Framework | What it offers | What you must still do |
|---|---|---|
| Express (Node.js) | Middleware pattern; no built-in object authorization | Write authorization middleware and apply it to every object route |
| Django | Object-level permissions via django-guardian; get_object_or_404 with owner filter | Scope every queryset to the current user |
| Laravel | Policies and Gates; route-model binding with authorize() | Define a policy per model and call it on every action |
| Ruby on Rails | Pundit / CanCanCan gems; scoped finds (@current_user.projects.find) | Scope every lookup to the current user, as the OWASP cheat sheet shows |
| Spring Boot | Spring Security method security (@PreAuthorize) | Write ownership expressions per endpoint; test with two accounts |
No framework prevents IDOR by default. Every one of them requires the developer to add the ownership check — which is exactly why the flaw keeps appearing.
Authorization tests in CI
Turn every IDOR finding into a regression test. A two-account test suite should run on every build: for each object endpoint, user A requests user B's object and the test expects a 403 or 404. If a future change drops a check, the build fails before the code ships.
Logging, alerting, and rate limits
Log access-control failures and alert on enumeration patterns — a single account requesting many sequential IDs, or bursts of 403 and 404 responses, is a strong IDOR-probing signal. Rate limits slow automated enumeration. Neither fixes the flaw, but both buy time to find and fix it.
Finding IDOR Vulnerabilities
Manual testing workflow
Where to look first
user_id in the body that the server trusts.Testing with Burp Suite
Burp Suite is the standard IDOR testing tool. Intercept a request in the Proxy, send it to Repeater, and change the identifier. For scale, send it to Intruder with a numeric payload range and watch for 200 responses on other users' objects. Compare the responses: a 200 with another user's data is a confirmed finding; a 403 or a 404 that matches the "not found" response is a pass.
# Quick terminal check with curl and jq
curl -s -b "session=alice-session-token" \
http://127.0.0.1:5000/api/documents/3 | jq .
Testing with ffuf
When identifiers are numeric and sequential, ffuf can enumerate them fast:
ffuf -w ids.txt -u 'http://127.0.0.1:5000/api/documents/FUZZ' \
-b "session=alice-session-token" -mc 200
Any ID returning 200 while logged in as alice that belongs to bob is IDOR. Use ffuf only against your own lab or a target you have explicit permission to test.
What a 403 vs 404 tells you
IDOR Cheat Sheet
Attack vectors — where identifiers hide
| Location | Example | Test |
|---|---|---|
| URL path | /api/users/123 | Change the number |
| Query string | /download?file=report-1234.pdf | Change the file name |
| POST body | {"user_id": 123} | Change the user_id |
| JSON field | {"invoice_id": 1002} | Change the invoice_id |
| Header | X-Account-Id: 123 | Change the header |
| Cookie | account=123 | Change the cookie |
| JWT claim | "sub": "123" | Check whether the token is forgeable or over-broad |
Prevention quick reference
| Control | Strength | Notes |
|---|---|---|
| Server-side ownership check, every request | Required | The only control that actually prevents IDOR |
| Scoped queries (user's records only) | Required | Unauthorized records are never loaded |
| Deny by default | Required | No rule means no access |
| Centralized authorization policy | Strongly recommended | One middleware, applied everywhere |
| Identity from the session | Strongly recommended | Ignore client-supplied user_id for own actions |
| Indirect reference maps | Defense in depth | Clients never see raw keys |
| UUIDs / random IDs | Defense in depth | Slows enumeration; never a substitute for checks |
| Authorization tests in CI | Strongly recommended | Two-account tests fail the build on regression |
| Logging, alerting, rate limits | Detective | Spots enumeration; does not fix the flaw |
Troubleshooting IDOR Problems
| Problem | What it usually means | Fix |
|---|---|---|
| 403 on your own object | The check is too strict, or the session identity is wrong | Verify the session carries the right user; check the ownership comparison |
| 404 vs 403 confusion | The app returns 404 for not-owned objects by design | That is correct — do not "fix" it into a 403 that leaks existence |
| UUID still exploitable | The UUID leaked via an API response, log, or shared link | UUIDs are not authorization — add the ownership check |
| Check works for GET but not DELETE | Authorization was added to one method only | Apply the check to every method on the endpoint |
| Test passes for one role only | The check covers one role's path, not all of them | Test every role against every object endpoint |
| Rate limits block the test | The test looks like enumeration to the WAF | Use a small ID range in the lab; test in a staging environment |
| Burp is not intercepting | Proxy not configured, or the app uses certificate pinning | Check the proxy listener and browser settings; use the lab app |
| Framework middleware order | The authorization middleware runs after the handler | Register authorization middleware before the route handler |
Real-World Examples
The old version of this article named three dated incidents. Their years could not be verified, so they are removed here — a security guide must not present uncertain history as fact. What is certain, and well documented, is the pattern:
IDOR is not a rare, exotic flaw. It is the most ordinary web vulnerability there is, which is why it keeps appearing in applications of every size.
Common Mistakes
Best Practices
Is IDOR Testing Legal?
Testing for IDOR is legal only on systems you own or have explicit permission to test — your own lab, a staging environment you control, or a bug-bounty program whose scope explicitly covers the target. Changing IDs in requests to a live site you do not own is unauthorized access, even if you only read one record and report it. Keep all testing inside the local lab described above until you have written permission.
Summary
IDOR vulnerabilities arise from missing authorization checks on object references. The fix is straightforward: verify the requesting user has permission to access the specific resource on every request. Use indirect references and centralized access control patterns to reduce risk. Remember the three ingredients — an object, a reference, and a missing check — and remove the third one everywhere. Authentication proves who you are; authorization proves you may touch this object. Test with two accounts, automate that test in CI, and treat every object endpoint as a potential IDOR until proven otherwise.
Knowledge Check
Answers: 1. An object, a reference to it, and a missing object-level authorization check; 2. Authentication proves who you are, but only authorization checks whether you may access that specific object; 3. Horizontal IDOR accesses another user's data at the same privilege level, while vertical IDOR accesses higher-privilege functions or data; 4. UUIDs are obfuscation, not authorization — a leaked or enumerated UUID still grants access without a permission check; 5. A 404 (or a 403) identical to the response for a missing object, so the attacker cannot tell whether the object exists; 6. An indirect reference map replaces the raw internal ID with a per-user or per-session handle that the server translates back; 7. Client-side checks run in code the attacker controls and can bypass, so the check must run on trusted server-side code; 8. They are the same flaw — IDOR is the web-application term, BOLA is the API term (OWASP API1:2023).
Keep Learning
Frequently Asked Questions
Continue Learning
What Is SSRF? Server-Side Request Forgery Examples & How to Prevent SSRF Attacks
What is SSRF? See real server-side request forgery examples, a worked lab test, and how to prevent SSRF attacks with allowlists, IMDSv2 and egress controls.
Web Security · IntermediateWhat Is SQL Injection? Types, Examples & How to Prevent SQL Injection Attacks
What is SQL injection? See real SQL injection examples, a worked DVWA lab test, and how to prevent SQL injection with parameterized queries.
Web Security · IntermediateWhat Is CSRF? Cross-Site Request Forgery Examples & How to Prevent CSRF Attacks
What is CSRF? Learn how cross-site request forgery tricks your browser into unwanted actions, see real examples and a DVWA worked test, and follow 7 steps to prevent CSRF attacks with tokens, SameSite cookies and framework protection.
Web Security · IntermediateJWT Security: What Is a JWT, Common Attacks & How to Test Them
What is a JWT? Learn JWT security: how JSON Web Tokens work, the none and algorithm confusion attacks, and how to test JWTs with jwt_tool and Burp Suite.
Related Security Tools
Burp Suite
Burp Suite is the industry-standard web application security testing platform from PortSwigger, free as Community Edition on Kali Linux. Learn how to use Burp Suite: install it, route your browser through its proxy, intercept your first request, and test it with Repeater and Intruder.
Web ApplicationSQLMap
SQLMap is an open-source penetration testing tool that automates SQL injection detection and exploitation. It supports six SQL injection techniques (boolean-based blind, time-based blind, error-based, UNION query-based, stacked queries, and out-of-band) and over 30 database backends including MySQL, Oracle, PostgreSQL, Microsoft SQL Server, and many more.
Vulnerability AnalysisNikto
Learn how to use Nikto, an open-source web server scanner written in Perl and pre-installed on Kali Linux, to audit servers you own or have written permission to test. Its 6700+ checks for potentially dangerous files and programs, plus tests for outdated software and misconfigurations, highlight issues that need verification.
Web SecuritySecurity Headers Checker
Check HTTP security headers (CSP, HSTS, X-Frame-Options, X-XSS-Protection, Referrer-Policy, and more) with security scoring.