Lorixen.
EN

Symptoms of a Cross-Customer Data Leak in a Multi-Tenant App, and Where to Look

Short answer: In a multi-tenant app, where many customer companies share one system, a cross-customer leak almost always comes from a query or a cache that forgot to filter by the customer. Start from the symptom: a wrong record on a list usually means a missing filter, a wrong record at a guessed address means missing ownership checks, and a wrong value that appears briefly points at a cache or a background job. Fix the one case, then make the rule structural so one forgotten filter cannot cause the next leak.

If you believe real customer data has been exposed, treat it as an incident first: contain it, keep the logs, and check the notification rules that apply to you in the official guidance for your country or state. This article covers diagnosis, not legal advice.

The idea in one paragraph

"Tenant" here means one customer company and its users. Every row that belongs to a tenant carries a tenant identifier, and every read or write must respect it. The system is only as safe as the weakest path that touches data: a list screen, a search box, a CSV export, a report, an email template, a file download, a background job. The usual failure is not a clever attack. It is one path where somebody forgot the filter.

Symptom, cause and fix

What you see Likely cause First fix
A customer's list contains a row that belongs to someone else Query joins or filters without the tenant condition, often after a new feature Add the condition, then search the codebase for every query on that table
Changing a number in the page address shows another company's record The endpoint loads by record number and never checks ownership Load by record number and tenant together, return "not found" when they do not match
A report total includes other companies' rows Raw reporting query skipped the shared data layer Route reports through the same scoped access layer or add a mandatory filter
A file download works with a copied link when logged out or as another tenant Files served from a public storage address Use short-lived signed links generated after an ownership check
A dashboard shows another tenant's name for a few seconds Cache key built without the tenant identifier Include tenant in every cache key, and clear affected entries
An email contains the wrong company's data Template reads "current customer" from a global variable set by an earlier job Pass the tenant explicitly into each job, never through shared state
Search suggestions reveal names from other tenants Search index is global and filtered only in the front end Filter on the server inside the search query itself
An admin of Company A can promote themselves in Company B Role check looks at the role but not where the role applies Store roles per tenant and check both
A background import writes rows without a tenant Job runs without a tenant context and defaults to null or the first tenant Fail the job when the tenant is missing

Where leaks hide in small systems

  • Newly added features. The original screens were scoped properly; the new "quick export" was written on a Friday.
  • Admin tools and scripts. Internal pages often bypass scoping because staff are meant to see everything. Make that an explicit "staff mode" with logging, not a silent default.
  • Joins. Scoping the main table but not the joined table can pull in other tenants' related rows.
  • Aggregates. Counts, totals and averages leak less obviously, but a competitor seeing a total number of orders is still a leak.
  • Webhooks and integrations. An incoming message must be mapped to the right tenant before any data is touched.
  • Soft-deleted and archived rows. They can slip through filters designed for live data.

Make the rule structural

Scope in one place

Put tenant filtering inside a shared data-access layer that every feature uses, so forgetting is harder than remembering. Frameworks often support default scopes for this.

Consider database-level enforcement

Some databases can enforce the filter themselves. PostgreSQL's row security policies let the database refuse rows that do not belong to the current tenant, even when application code forgets. It adds setup work and needs care with connection pooling, so discuss it with your developer rather than switching it on blindly.

Check authorisation at the object, not just the page

The OWASP authorization cheat sheet stresses checking access on every request for every object. Hiding a button is not access control.

Use identifiers that are hard to guess, but never rely on that

Random identifiers make guessing harder, yet they are a second line of defence. The ownership check is the first.

A test that catches the next leak

Create two test tenants with similar data. Write automated tests that sign in as tenant A and attempt to read, change, export and delete tenant B's records through every route, including direct addresses, search, exports and files. All attempts should return "not found" or "forbidden". Run these tests on every release, and add one whenever you add a new route.

For a manual spot check with a non-developer, give two staff members two test companies and ask them to try to break in for an hour. People are good at finding odd paths.

FAQ

Is a separate database per customer safer?

It removes a class of filter mistakes, at the cost of more operations work: migrations, backups and monitoring multiply. For a few large clients it can be right. For hundreds of small ones it is often impractical.

How would we know a leak has already happened?

Review access logs for requests where the signed-in tenant and the tenant of the returned record differ. If you do not log both, start now.

Do shared test accounts count?

They blur the picture. Use named test tenants so strange appearances are obvious.

Should we tell customers if we find a leak?

That depends on what was exposed and on the rules where you and your customers are. Contact the official regulator guidance for your jurisdiction and take professional advice.

If you run a shared portal or SaaS and want an independent look at how tenant separation is built, contact us for a review.

Sources

WhatsAppBook a call