CIDADAXSEC
← All topics
Practitioner

Access control

The server trusts what the client sends: an id in the URL, a hidden field, or a role stored in a cookie.

Material

Broken access control means a user can do something they are not entitled to do. The two common shapes are horizontal, opening another user data with an equivalent id, and vertical, escalating to a higher role.

IDOR

Insecure direct object reference appears when an endpoint fetches an object by a client-supplied id without checking ownership. Example: GET /api/invoices/1042 returns another user invoice because only the id is checked.

javascript
// Salah: hanya id yang dipakai
const invoice = await db.invoice.findUnique({ where: { id } });

// Benar: kepemilikan ikut jadi syarat
const invoice = await db.invoice.findFirst({
  where: { id, userId: session.userId },
});

Prevention

  • Check ownership on every endpoint, not only in the UI page.
  • Never store the role in a cookie or a field the client can edit.
  • Deny by default, then open access per role explicitly.
  • Test with two different accounts on every endpoint that accepts an id.
The IDOR lab is already available in Phase 1. Vertical access and per-role authorization labs come in Phase 2.

Labs in this topic

Labs run on a domain separate from this site, so a payload cannot reach your account session.

IDOR: another user invoiceThe invoice endpoint checks the id, not the owner.
LevelApprentice
Not solved

Challenges in this category

Challenges from the PortSwigger Web Security Academy. The original labs run on PortSwigger domains, so the link opens there.