Multi-Tenant AI Agents: Keeping One Customer's Data Out of Another Customer's Answers
A multi-tenant agent leaks wherever a shared store answers without checking who is asking: the RAG index, agent memory, response and prompt caches, tool credentials and traces. Six controls close it: partition every store by tenant; filter retrieval before similarity search; take the tenant from the session, never the model; scope credentials per tenant; key every cache by tenant; test cross-tenant denial.
On this page
On 20 March 2023, some ChatGPT users saw the titles of other people's conversations in their history sidebar. OpenAI traced it to a bug in the redis-py library: cancelled requests could leave a connection returning another user's cached data. OpenAI said payment-related details of 1.2% of ChatGPT Plus subscribers may have been visible during a nine-hour window that day. Its fix included "redundant checks to ensure the data returned by our Redis cache matches the requesting user."
Nothing about that was a model failure. A shared store returned data without a check that it belonged to the person asking. An agent that serves many customers has far more shared stores than a chat history, and each one needs that check.
Where cross-tenant data leaks happen in an AI agent
OWASP's entry on vector and embedding weaknesses (LLM08:2025) names the core case: where several groups of users share one vector database, "embeddings from one group might be inadvertently retrieved in response to queries from another group's LLM". The same pattern repeats everywhere an agent reads shared state:
- Retrieval indexes. One index for every customer, separated only by a metadata field someone has to remember to filter on.
- Agent memory. Saved facts and summaries, keyed by user but sometimes shared across a customer's whole workspace, or across every workspace.
- Caches. Response caches, semantic caches that match similar questions, and the model provider's prompt cache.
- Tools. A CRM or ticketing tool authenticated with one service account that can see every tenant.
- Traces and evaluation sets. Full prompts and retrieved documents from every tenant, in one log store, readable by whoever debugs the agent. That is the subject of keeping PII out of agent traces.
Leaks also run in the other direction. If tenant A can put a document into an index that tenant B's agent retrieves, A can plant instructions as well as read data. That is indirect prompt injection delivered across the tenant boundary.
How to partition a RAG index by tenant
OWASP's RAG security cheat sheet is direct: chunks from tenant A must never be retrieved by queries from tenant B. Its guidance comes down to four rules.
- Separate the stores. Use separate namespaces, collections or indexes per tenant, rather than one flat namespace. Most vector databases support this.
- Filter before the search, not after. The cheat sheet warns against retrieving everything and then filtering, because pre-retrieval filtering "prevents the similarity scores of restricted documents from being observed".
- Check access at retrieval time. Store access metadata on every chunk, not only on the source document, and check it on every query. Permissions change after ingestion.
- Never leave it to the model. "Access control must be enforced before content reaches the model."
Deletion has to follow the same path. When a customer leaves or a document is removed, the chunks, embeddings and cached responses derived from it must go too. Embeddings are not anonymised data: Morris and colleagues showed text can be reconstructed from embeddings, recovering 92% of 32-token inputs exactly in their experiments.
If retrieval runs on a relational database, OWASP's multi-tenant security cheat sheet compares separate databases, separate schemas and shared tables with row-level security. If you use row-level security, check the agent's database role. PostgreSQL's documentation on row security policies states that superusers and roles with the BYPASSRLS attribute always bypass it, and table owners normally do too.
Why the model must never choose the tenant
The multi-tenant cheat sheet says to treat client-supplied tenant identifiers "as selectors only", and to bind tenant context to a server-verified identity.
Apply that to an agent. A tool with a tenant_id argument that the model fills in is a client-supplied selector, written by the component that reads untrusted text. One injected sentence can change it. The tenant should come from the authenticated session, set by the tool runtime, and never be visible to the model or settable by it.
Credentials follow the same rule. If every call to the CRM uses a service account that can read all customers, one hijacked session can read all customers. Give each call a credential scoped to the tenant it serves, ideally one that carries both the user and the agent, the delegation model described in AI agent identity.
Caches and memory: the shared stores teams forget
Caches are where the March 2023 incident happened, and agents add new kinds.
- Response and semantic caches. The RAG cheat sheet says to scope caches by user, tenant and permission level, and to invalidate entries when permissions change. A semantic cache needs the most care, because it returns a stored answer to a question that was merely similar. Key every entry by tenant, and by user where results depend on the user's rights. The multi-tenant cheat sheet adds that "cache-key separation does not replace authorization".
- Provider prompt caches. OpenAI's prompt caching documentation says caches are not shared across organisations. Anthropic's documentation says it separates caches by workspace on the Claude API, and by organisation on some partner platforms. Either way, the provider's boundary is your account, and all of your tenants sit inside it. Gu and colleagues' audit of prompt caching explains why that can matter: with a shared cache, response times can reveal what other users sent. If a tenant needs separation at that layer, it needs its own workspace or organisation.
- Memory. Partition memory by tenant and by user, with retrieval that can only see its own partition, as in the controls for agent memory.
Six controls for multi-tenant AI agents
| Control | What it means in practice |
|---|---|
| Partition every store | Index, memory, cache, files and traces each separated by tenant |
| Filter before retrieval | The tenant boundary applies before similarity search, not to its results |
| Tenant from the session | The runtime sets the tenant; the model never sees or chooses it |
| Tenant-scoped credentials | Each tool call can reach only the data of the tenant it serves |
| Tenant in every cache key | And authorisation checked before any cached value is returned |
| Test cross-tenant denial | Automated tests that try to cross the boundary, on every change |
How to test that tenants stay separate
The multi-tenant cheat sheet asks for tests that run through the same role, connection path and pooling mode the application uses, prove that cross-tenant operations are denied, and fail if the request role can bypass row security. It also asks for requests from two tenants over reused connections, to prove the second cannot see the first's context. A shared connection handing one user's data to the next was the March 2023 failure.
For an agent, add canaries. Seed each test tenant with a unique marker string in a document, a memory entry and a cached answer. Then run another tenant's agent with prompts written to fish for it. Any appearance of another tenant's marker, in a reply, a tool argument or a trace, is a failed build. Log every retrieval with the requester's identity and the access metadata of what came back, as the RAG cheat sheet recommends, so a leak in production can be traced to the store that caused it.
Where Syntrox fits
Nucleus, our judge, is a 4B-parameter open-weight model, small enough to run on hardware inside your own network, so the tenant data a check needs does not have to leave it. It returns "uncertain" rather than guessing when a grounded check has no context to check against. Syntrox records the score, confidence and judge version for each evaluated trace, outside the agent.