Your AI Chat Showed One Customer Another's Data
One customer saw another's document in the assistant. The leak is a shared index, a memory, or a tool with no tenant filter. Trace the query and close it.
By Muhammad Saif and Aashan Khan · Techtribe co-founders
A customer wrote to you because the assistant answered with someone else's contract, ticket, or note. They could read a name, a price, or a sentence they have no relationship to. That message is the incident. The model did not invent another company's private file from weights. Something in the request handed it the file.
The path is usually one of three. A search index that holds every tenant and was queried without a filter. A memory or chat history loaded by user id that was missing, wrong, or taken from a shared cache. A tool, a SQL query, a CRM lookup, a file fetch, that runs with an admin credential and trusts the model to pass the right account. Login succeeded. The login never reached the query.
This is the incident, not the policy checklist. Row-level security mistakes in generated Supabase apps are covered in the RLS note. Read that if the product is a generated app on Supabase and the tables themselves return the wrong rows to a logged-in user. Read this if the assistant answered with data the user could not have opened in the rest of the product. The screen and the chat disagreed. The chat is the bug you have to close before the next session.
What the model is allowed to say
The model will use the text you supply. Retrieved chunks, previous turns, and tool results are the text. A system prompt that says "only discuss the current customer's data" is a wish. If the chunk in the prompt belongs to another customer, the wish has already failed. The control is to never place that chunk in the prompt.
That sounds obvious, and the implementation drifts. The first demo has one user, so the index has no tenant field. The second customer is added by uploading their files into the same index. Search still returns the nearest chunks. Nearest is not "this account." A metadata filter is a line someone meant to add after the pilot. The pilot became production when the first invoice went out.
Caches do the same thing more quietly. A response cached by the question text, without the tenant id in the key, serves customer A's answer to customer B when they ask the same question. "What is our renewal date" is a common question. The dates are not common. A cache key of the prompt alone is a cross-tenant read.
Conversation memory fails when the session id is predictable, reused, or taken from a header the client can set. A missing session falls through to a default thread. Developers hit this as "the bot remembers the last test." Customers hit it as "the bot remembers a stranger."
Tools fail when the implementation uses a service role. The model emits an account id. The tool queries by that id, or queries without it because the argument was empty and the query forgot the WHERE clause. An empty filter that means "all rows" is the bug. The model is not in a position to notice. Your handler is.
Trace one query before you change architecture
You need a single bad answer and the records around it. Guessing which layer failed leads to a rewrite of the wrong layer while the hole stays open.
- Take the report. The time, the user, the tenant, and the text they saw. If they forwarded a screenshot, pull the phrases that could only have come from another account. Those phrases are the search key.
- Find the request id in your gateway or app log. You want the retrieved document ids, the tool names and arguments, and the tenant id the server believed. If you do not log document ids, you cannot finish this trace. Add that log after you preserve what you still have, and treat the missing log as part of the fix.
- Open each retrieved id and read its tenant. The moment an id belongs to someone else, you have the store that crossed. Stop looking for a second root cause until this one is closed. There may be a second. The first is enough to justify taking the feature down.
- If the retrieved ids are clean and the answer is still foreign, look at memory and cache. Compare the cache key to the tenant. Compare the thread id to the user. A clean retrieval plus a dirty answer means the extra text joined later.
- If a tool ran, read the query the tool executed, not the query the prompt suggested. An admin client with a missing parameter is visible in the database log as a query without the tenant predicate. That log is the evidence. A prompt that said the right tenant is not.
- Identify who else could have received the same class of answer. Same index, same cache, same tool, between the date the filter was absent and now. You will not reconstruct every session. You can bound the set: tenants in that index, users who called that tool. That bound is what counsel and the customers need.
- Disable the path until a repeated trace on two test tenants returns only their own ids. Disabling means the route, the tool, or the whole assistant, not a prompt line. Bring it back only when the test is in the repo and fails the build if the filter is removed.
While the feature is down, answer the reporting customer with what you know: what you saw in their session, that you have stopped the feature, and when you will say whether their data was shown to anyone else. Do not promise a clean bill of health on the first day if the log does not support it. A precise partial answer is the one they can trust later.
Where the filter has to live
The tenant predicate belongs in code the model cannot skip. A required argument on the search function. A client constructed for that tenant, so a query cannot name another. A database role that cannot read the other tenant even if the application asks. Pick the layer you can test. A filter only in the prompt will be dropped the first time the model is told, by a retrieved page, to ignore instructions.
Indexes need a metadata field that is written at ingest from the server, not from the file the user uploaded. A user-supplied tenant id in a document is an invitation. The authenticated session chooses the id. Ingest rejects a write that does not carry it. Search rejects a query that does not filter on it. A migration backfills the field for old chunks or deletes them. Orphan chunks with no tenant are the ones that match everyone.
Tools get the tenant from the session, not from the model. The model can pass a business argument, an order number, a date. It does not pass the tenant. If the order number is not in that tenant, the tool returns nothing. Returning "not found" is the success case for a cross-tenant guess.
Caches include the tenant and the permission version in the key. When you revoke a user's access, you do not wait for the TTL to forget an answer that contained their old documents. A short TTL is not a substitute for the key. It only limits how long a bad key hurts.
Conversation storage is keyed by user and tenant together. Support tools that load a transcript take an audited path, not the same function the model uses. A support shortcut that queries by keyword across all tenants will recreate the incident in the admin UI.
Log the filter. A line that records tenant id and hit count, without the document body, is enough to see a query that ran unscoped. A log of full prompts in a shared debug tool is itself a place another engineer, or another tenant's admin, can read the data. Keep the trace. Do not widen who can open it.
What you tell the customers
If customer A's data appeared in customer B's session, both need to hear from you. A saw their confidentiality fail. B saw data they should not have. Your agreement's notice window starts when you know, not when the write-up is elegant. Say what class of data, the dates you can bound, and what you turned off. Skip the architecture essay.
If you cannot tell whether A's data was shown to anyone besides the reporter, say that, and say what you are checking. Inventing certainty is how a small incident becomes a story that you lied. The trace either produces ids or it does not. Report the state of the trace.
Fix the store before you ask them to try the bot again. A second screenshot from the same customer ends the relationship. A short, boring confirmation that two test accounts stayed inside their own data is the note you send when you turn the feature back on.
What does not hold
Telling the model to respect tenancy does not hold. The model does not enforce queries. The handler does. A longer system prompt is not a migration.
Deleting the one conversation the customer saw does not hold. The index still returns the chunk. The cache may still hold the answer. The tool can run again on the next question. Delete or quarantine the path, then the copy.
Rotating the model API key does not hold. The key did not leak. The data did. Rotation is right when a key was exposed. It does not filter an index.
Row-level security on the tables does not hold if the assistant uses a service role that bypasses it. Generated apps do this so the server can "see everything it needs." The server then sees everything. If the chat uses that client, the RLS policies on the user-facing API are not the control for the chat. Check the client the handler imports.
A vector database's "namespace" does not hold unless every query sets it and ingest cannot write outside it. A default namespace that accumulates stragglers is a shared index with an extra label. Test a query that forgets the namespace. It must fail, not search the default.
After the hole is closed
Add the two-tenant test to CI. Load two customers, ask a question whose only true answer is in customer A's documents, as customer B, and assert the retrieved ids and the answer. Run it when the index code changes, not when someone remembers. A test that is manual will be skipped on the day a new file type is added.
Write down the stores that are allowed to hold customer text: the index, the transcript table, the provider, the trace tool. Anything else is a finding. New stores require the same filter before they ship. The review is a few lines in the pull request template. It works if someone rejects a PR that adds a query without a tenant predicate.
Give the assistant a kill switch the on-call can flip without a deploy argument. You used it once. You will want it again. The switch should be boring and documented.
If the product is a retrieval feature you still intend to sell, the design of that feature is the work in RAG development: what is retrieved, for whom, and how you know. An assistant that can quote the corpus is a product. An assistant that can quote the wrong corpus is an incident waiting for the next upload.
What to rebuild versus what to patch
Not every cross-tenant answer requires a new vector database. If one query missed a filter and the index already stores tenant metadata, the patch is the query and the test. Shipping a migration to a new vendor in the same week feels like action and leaves the broken query in place until the migration finishes. Patch the query today. Schedule the new platform only if the current one cannot express a mandatory filter.
Rebuild when the tenant is not in the data at all. Chunks with no metadata cannot be filtered. You will re-embed or you will delete and reload from the source of truth, writing the tenant server-side as you go. That is a job with a progress bar, a rollback, and a period where search is off. Tell customers the assistant is offline. Do not serve partial results from the old index "while it catches up." Partial is how the bad chunk survives.
Also rebuild the cache key and the session store even if the index was the reporter's bug. Those paths are the next report. A team that fixes only the layer named in the ticket gets a second ticket. The list of stores from the trace is the list you finish, not a menu.
Staff the inbox while the feature is down. The people writing in are frightened or angry, and they are right to be. A named human replies. An autoresponder that says the AI will help them is a bad joke on this particular day. Give support the sentence they may send and the sentence they may not. They may say the feature is off and that you are checking who was affected. They may not speculate about other customers' names, and they may not promise a legal conclusion.
If more than one report arrives, treat them as one incident with several witnesses unless the traces show different holes. Opening five war rooms for one missing filter wastes the hour you needed for the test. One owner, one timeline, one customer note.
Look at tools next. A CRM tool, a ticket tool, and a file tool each need the same session-scoped tenant. One clean index does not clean the tool that runs beside it. The report you just handled may have been the index. The next report may be the tool. List them while the incident is fresh.
If this is your app, send the repo.
A 30-minute scope call. We read what is live, name what is dangerous, and quote a fixed scope.
How Techtribe traces the answer the customer saw
We take the conversation that crossed a boundary and follow it to the index, the memory, or the tool that returned the foreign id. You get the path in writing, the tenants in the blast radius we can actually bound, and the change that makes the same query return nothing for the wrong account. The feature stays off until that change is tested with two tenants.
A single traced incident, with the filter put back, fits a fixed pass when the product is otherwise stable. A Dedicated Team fits when new sources keep getting connected and each one can forget the tenant. The build of a retrieval feature that has the filter from the start is RAG development. If the tables themselves are open, start with the Supabase RLS mistakes and bring both.
Bring the screenshot or the transcript, the time, and a way to read logs. If you have already turned the bot off, say so. We will not turn it on to watch it fail again. The trace can be done from the records you stored.
The fixed scope for taking a generated app to production is a page per tool: Lovable, Bolt, v0, and Replit.
Questions
How can a chat show one customer another customer's data?
The model only repeats what the request put in front of it. That context came from a search index, a conversation store, or a tool. If any of those returned another tenant's rows, the answer will contain them. Login on the page does not filter the query.
Is this the same problem as a missing Supabase policy?
Sometimes the database policy is the hole. Often the assistant never asks the database as the user. It asks a shared index or an admin client, and the tenant id is a hope in the prompt. Fix the path the answer actually used.
What do we do the day a customer reports it?
Stop the feature for everyone, or for the tenants you cannot separate, until one traced query shows the filter holding. Preserve the request id, the retrieved ids, and the tool calls. Tell the customers whose data was in the answer. Rotating a model key does not remove a row that was already returned.
What should we bring if we want this traced?
The conversation the customer saw, the time it happened, and read access to the index and the tool logs. A screenshot of the bad answer is enough to start. The trace tells you which store crossed the boundary.