If you run a SaaS product, many customers share the same application, the same database and the same API. Their data stays apart only because your code checks, on every request, that a user is touching what belongs to them. When that check is missing, you have an IDOR.
What IDOR means
IDOR stands for Insecure Direct Object Reference. In API security you may also see it called BOLA, Broken Object Level Authorization. Both names describe the same problem.
An “object” is anything your application stores: an invoice, a project, a file, a user profile. A “reference” is how the client points to it, usually an ID in a URL or request body:
GET /api/invoices/4512
An IDOR happens when the server fetches invoice 4512 because the client asked for it, without checking that the signed-in user is allowed to see it. Change the number and you see someone else’s invoice.
Why multi-tenant products are especially exposed
In a single-company tool, an IDOR might let one employee see a colleague’s record, which is bad but stays inside one organisation.
In multi-tenant SaaS, the same flaw lets one customer read another customer’s data. Every customer becomes a potential attacker against every other customer, and all they need is a normal account. Sign-up is often free.
So cross-tenant access is usually rated critical or high severity, and enterprise customers and auditors ask about tenant isolation directly.
How it usually happens
IDORs rarely come from carelessness; they usually come from reasonable-looking code in the wrong place:
- The front end only shows a user their own records, so nobody notices the API would return anyone’s.
- Some endpoints check and others don’t. Reading an invoice is protected; updating, exporting or deleting it is not.
- The request includes
tenantIdoraccountId, and the server trusts it instead of the user’s real session. - A feature added later, such as a file export or webhook, fetches objects directly by ID and skips the usual pattern.
- The project is checked, but the comments, attachments or line items inside it are fetched by their own IDs alone.
Why random IDs are not the fix
Switching from sequential numbers to UUIDs makes IDs much harder to guess, and that is worth doing. It still isn’t access control.
IDs leak. They appear in URLs, emails, logs, shared links, browser history and API responses. Once someone has an ID, a missing check is just as exploitable as before. Treat unguessable IDs as a second layer on top of the checks.
How to prevent it
Scope every query to the current tenant
The most reliable pattern is to never fetch an object by ID alone. Always include the tenant (or owner) from the authenticated session:
SELECT * FROM invoices WHERE id = ? AND tenant_id = ?
If the record does not belong to the caller’s tenant, the query returns nothing, and you return a 404.
Centralise the check
Don’t rely on every developer remembering. Put tenant scoping in a shared layer: a data-access helper, an ORM scope, middleware or database row-level security. A new endpoint is then protected by default, and skipping the check takes a deliberate choice.
Never trust tenant IDs from the client
Work out the user’s tenant from their session or token on the server. If the client sends a tenantId, ignore it or check it matches.
Test for it automatically
Add tests that sign in as a user in tenant A and request objects from tenant B, for every object type and every method (read, update, delete, export). They are cheap to write and catch regressions when new features ship.
Get it tested by people
Automated tests check the cases you thought of. A penetration test checks the ones you didn’t, including indirect paths like exports, webhooks, file downloads and nested objects. You can see how we test tenant isolation on our web application and API testing pages, or ask us to test yours.
