IDOR (Insecure Direct Object Reference)

Securityadvancedaka BOLA

// Definition

A vulnerability where an application exposes internal object identifiers — database primary keys, file paths, account numbers — and fails to verify that the caller is authorised to access the referenced object. Example: user A requests GET /api/orders/1042; simply changing the ID to 1043 returns another user's order. IDORs are consistently one of the most prevalent API vulnerabilities (OWASP API Security Top 10: Broken Object Level Authorization). Testing: for every endpoint that accepts a resource ID, verify with a second authenticated account that it cannot access the first account's resources.

// Why it matters

IDOR is the classic, pre-OWASP-API name for the same flaw BOLA describes: a server exposes a direct reference (a DB id, filename, key) and trusts the client not to tamper with it. QA cares because it's the cheapest high-severity bug to find — change one number in a URL — yet routinely missed because automated suites replay valid ids only.

// How to test

// Enumerate a reference you shouldn't own
cy.request({ url: '/api/invoices/1042', headers: tokenA })
  .its('body.ownerId').should('eq', userA.id)

cy.request({ url: '/api/invoices/1043', headers: tokenA, failOnStatusCode: false })
  .then((res) => {
    // must NOT return another user's invoice
    expect(res.status).to.be.oneOf([403, 404])
  })

// Common mistakes

  • Assuming sequential ids are "internal" and therefore safe
  • Only testing IDs the test user legitimately owns
  • Confusing 404-on-missing with 403-on-forbidden (leaking existence)

// Related terms