Most bugs announce themselves. A tenant leak does not. The query runs, the status code is 200, the page renders, and somebody in one company is looking at another company's payroll.
That is what makes multi-tenancy different from the rest of the work. There is no stack trace to grep for and no error rate to alert on. The system is behaving exactly as written. It was written wrong.
This is how we build isolation into multi-tenant products so that a mistake has to get past three independent layers before it reaches a user, and so that every build actively tries to break it.
The two ways tenant data actually escapes
In every leak we have looked at, the cause was one of two things.
The first is a missing filter . Somebody wrote a query without the tenant predicate. Usually it is not the obvious code. It is the admin export, the cron job, the "quick" reporting endpoint, the findById helper that takes a primary key and nothing else.
// Looks harmless. It is the whole bug.β¦