Cybersecurity-Mastery

Home › Vulnerabilities › Insecure Direct Object References

Insecure Direct Object References

Object-level authorization, identifier enumeration, tenant isolation and systematic testing.

Beginner⌨ ~36 min hands-on📖 ~12 min read

▶ Here to build, not read? Jump to the Hands-On Practice.

Prerequisites: Web Application Architecture · HTTP for Security Testing

Overview

Object-level authorization, identifier enumeration, tenant isolation and systematic testing. In one line: insecure direct object references decides where trust is placed, and misplaced trust is where the security problem lives. That's the theory you need — the understanding comes from doing it, so the walkthrough below is the heart of this chapter.

How it works

Mechanically, insecure direct object references comes down to three things: what data is trusted, where it crosses a boundary, and what happens on the other side. The diagram traces that path; you'll walk it for real, step by step, in the practice below.

flowchart TD
    A["Insecure Direct Object References"] --> B["Concepts & terminology"]
    A --> C["Internal mechanics"]
    C --> D["Trust boundaries"]
    D --> E["Attack surface"]
    D --> F["Defensive controls"]
    E --> G["Detection & telemetry"]
    F --> G
    G --> H["Verification in the lab"]
🔑 Key terms
  • Trust boundary — where data or control passes between components of different privilege or trust.
  • Attack surface — the set of points an attacker can interact with.
  • Primary control — the single measure that most reduces this technique's impact.
  • Telemetry — the log or signal a defender uses to detect the technique.

Hands-On Practice

Tip
This is the main event. Bring up the lab, then work the walkthrough — every command has a ▸ Run button (needs the lab runner) and a 📋 Copy button. ~36 min, Kali attacker, fully local.

Mission. Access another user's objects by changing an identifier, then enforce object-level authorization.

🧪 Lab setup — Vulnerabilities

  • bWAPP / DVWA / Juice Shop — the web bug targets (see the Web Security part environment)
  • pwn-box — Ubuntu build/debug container for buffer/heap/format-string labs
docker-compose.yml
# vuln-lab/docker-compose.yml  —  Vulnerabilities part environment
services:
  bwapp:
    image: raesene/bwapp
    ports: ["8081:80"]
    networks: [labnet]
  dvwa:
    image: vulnerables/web-dvwa
    ports: ["8082:80"]
    networks: [labnet]
  pwn-box:
    image: ubuntu:22.04
    container_name: pwn-box
    cap_add: ["SYS_PTRACE"]          # allow gdb inside the container
    security_opt: ["seccomp=unconfined"]
    command: sleep infinity
    networks: [labnet]

networks:
  labnet:
    driver: bridge

Target for this lesson: Juice Shop http://localhost:8083 (basket / order history) or bWAPP IDOR. Full setup: Vulnerabilities lab environment.

Guided walkthrough

1Find an object reference
command
# log in, open your basket; note the id in the request: GET /rest/basket/1
Expected output
Your basket is id 1.
The id is user-controllable and maps directly to a database row.
2Change the reference
command
curl -s http://localhost:8083/rest/basket/2 -H "Authorization: Bearer $TOKEN"
Expected output
You receive basket 2 — another user's items.
The server checked authentication (valid token) but not ownership — classic IDOR.
3Enumerate
command
for i in $(seq 1 20); do curl -s .../rest/basket/$i ...; done
Expected output
Multiple baskets returned across users.
Sequential ids make bulk access trivial — the impact scales.
4Fix: object-level checks
command
# WHERE basket.id = :id AND basket.user_id = :current_user
Expected output
Requests for baskets you don't own now return 403/404.
Authorization must be checked per object, not just 'is the user logged in'.

Live terminal

kali@idor — start the lab runner for a live shelloffline
Start the Lab Runner (see labserver/README.md), then click Connect lab runner and paste the token. Until then, copy commands from the walkthrough and run them in your own Kali terminal.
$

Try it yourself

Note
Try each for real. Open the hint only when stuck, the solution only to check.

Challenge 1. Find an IDOR that leaks data via a non-numeric identifier (UUID/filename).

Hint

UUIDs aren't guessable but may leak via other endpoints/responses.

Solution

Harvest ids from listing endpoints or referrers, then replay — 'unguessable' ≠ 'authorized'.

Challenge 2. Escalate an IDOR from read to write (change someone else's object).

Hint

Try the same id swap on PUT/PATCH/DELETE.

Solution

If write endpoints share the missing ownership check, you can modify others' data — often higher impact.

Challenge 3. Explain why rate-limiting alone doesn't fix IDOR.

Hint

Rate limiting slows enumeration; it doesn't add authorization.

Solution

A single unauthorized read is still a breach; the fix is per-object authz, not throttling.

Quick quiz

An endpoint checks the user is logged in, then returns object by id. What's missing?
IDOR is broken object-level authorization: the server must verify the object belongs to (or is permitted for) the current user, not just that they're authenticated.

Detect & defend (blue-team view)

  • Alert on one account requesting many distinct object ids in a short window.
  • Log authorization decisions; a burst of 200s across sequential ids from one session is an IDOR signal.

Skills check

You can move on when you can, without notes:

Check Yourself

Quick self-test — answers hidden. If you can't answer without notes, redo the relevant walkthrough step.

Q1. In one sentence, what security problem does Insecure Direct Object References address or create?

Show answer

Insecure Direct Object References matters because its behaviour determines where trust is placed; misplacing that trust is the root of the associated bug class.

Q2. Name one trust boundary involved in Insecure Direct Object References and what crosses it.

Show answer

Any point where attacker-influenced data meets privileged processing — e.g. user input reaching an interpreter, or a token reaching a verifier.

Q3. Give one attack against Insecure Direct Object References and the single control that most reduces its impact.

Show answer

State the attack precisely, then the primary control (validation, encoding, isolation, authentication, or least privilege) — not a laundry list.

Interview angles

  • Walk me through how Insecure Direct Object References works, then tell me where you would attack it.
  • How would you detect Insecure Direct Object References being abused in an environment you defend?
  • What is the difference between mitigating and eliminating the risk associated with Insecure Direct Object References?

Pitfalls & Best Practice

Common mistakes

  • Treating insecure direct object references as a checkbox instead of understanding the mechanism — defences copied without comprehension fail silently.
  • Trusting client-side or default controls to enforce a server-side security property.
  • Testing only the happy path and never the abuse cases or malformed input.
  • Fixing the symptom (one payload) instead of the class (the missing control).

Do this instead

  • Push security decisions to a single, well-tested enforcement point rather than scattering checks.
  • Fail closed: when in doubt, deny and log, so misconfiguration reduces access rather than expanding it.
  • Instrument the trust boundaries so the same event is visible to offence (as a target) and defence (as a signal).
  • Validate your understanding of insecure direct object references empirically in the lab before trusting it in production.
  • Prefer safe, high-level APIs and secure defaults over hand-rolled primitives.

Reference

MITRE ATT&CK Mapping

No single ATT&CK technique maps cleanly to this concept. Once you apply it offensively or defensively, map the specific behaviour using the ATT&CK chapter.

OWASP Mapping

CWE Mapping

CWEWeakness
CWE-639Authorization Bypass Through User-Controlled Key
CWE-284Improper Access Control

CAPEC Mapping

  • No single attack pattern; see the CAPEC chapter to map behaviour to patterns.

CVE References

  • No canonical CVE for a concept page. Search the NVD for concrete instances when studying real cases.

NIST References

RFC References

  • No governing RFC for this topic. Where a protocol is involved, its RFC is linked from the relevant networking chapter.

Research Papers

  • Reflections on Trusting Trust — Ken Thompson, 1984
  • Smashing the Stack for Fun and Profit — Aleph One, Phrack 49, 1996
  • The Protection of Information in Computer Systems — Saltzer & Schroeder, 1975

Books

  • The Web Application Hacker's Handbook, 2nd ed. — Stuttard & Pinto
  • Real-World Bug Hunting — Peter Yaworski
  • The Tangled Web — Michal Zalewski
  • Web Security for Developers — Malcolm McDonald

Official Documentation


Part of the Vulnerabilities section of Cybersecurity-Mastery. 🟢 Beginner · ~36 min hands-on · Last updated 2026-08-12.

Cybersecurity-Mastery — interactive security learning · runs locally