Can one customer of your AI-built app see another customer's data
You build a small app for teams. Each company signs up and sees its own projects, invoices and users. Your AI builder wrote the queries. Everything looks right in your own test account. Then a customer from Company B se
You build a small app for teams. Each company signs up and sees its own projects, invoices and users. Your AI builder wrote the queries. Everything looks right in your own test account.
Then a customer from Company B sends a request that names a project id from Company A, and the app answers with the data.
Why it happens
Apps with many customers (called multi-tenant apps) need every query to say "only rows that belong to this customer". AI builders often add that filter to the main list page and forget it on the detail page, the export button, the search box or the API route behind a background job. One missing filter is enough.
How to check your own app
- Create two test companies, A and B, each with a user and a few records.
- Signed in as B, copy the id of one of B's records from the address bar or the network tab.
- Sign in as A. Try to open B's record by id: the page, the API call, the file download, the export.
- Try the same with a search, a report and an invite link.
- Check that a user removed from Company A can no longer reach A's data with an old session.
If A can see anything of B's, you have found a tenant isolation bug.
What to look for
- Queries that filter by record id only, with no customer id.
- Customer id taken from the request body or a query parameter instead of from the signed-in session.
- Background jobs, exports and search that skip the filter the main page uses.
- Database tables with no row-level rule at all.
How to fix it
- Take the customer id from the session on the server, never from what the browser sends.
- Add the customer filter in one shared place, so every query gets it by default.
- Turn on row-level security in your database if it supports it, so a missed filter cannot leak rows.
- Write one test that signs in as A and asks for B's data. It must fail.
A prompt you can paste into your AI builder
"Audit every database query and API route in this project. For each one that reads or changes customer data, show me where it restricts the result to the signed-in user's organization. Take the organization id from the server-side session, not from request input. List any route that is missing the check and fix it. Then add a test that signs in as organization A and tries to read organization B's records."
What a scanner can and cannot tell you
An outside scan of your public pages does not sign in, so it cannot act as two customers and compare what they see. That test needs two accounts, as above. A passive scan can only tell you what a stranger sees without signing in.
I work on ProofForge. The free scan covers what a visitor can see and says plainly what it could not check.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.