Preventing Cross-Member Data Leakage in a Health Plan LlamaIndex Member Services Bot
To prevent cross-member data leakage in a LlamaIndex member services bot, treat leakage as five separate failure points: ingestion, retrieval, memory, tool calls and response. Bind an authenticated member identity to every one of them, partition indexes where practical, scope memory and tool credentials per member or session, and check output before it leaves. Enforcing policy at runtime, in the execution path, adds a control that does not depend on application code being correct, and it produces evidence for audit controls under 164.312(b).
The five leakage points and the control for each
- 1
Ingestion
Attach a member identifier to every document or node at write time, and reject records that lack one. Retrieval filters cannot isolate data that was never labeled.
- 2
Index and retrieval
Partition indexes or namespaces where the vector store supports it, and apply a member filter on every query. Derive the filter from the authenticated session, never from the user's message.
- 3
Chat memory
Key memory and any response or embedding caches to member and session. Do not share a memory object across sessions.
- 4
Tool calls
Issue credentials per member or per session with read scopes limited to that member. Reject tool arguments that name a different member.
- 5
Prompt context
Assemble context only from results already filtered to the member. Treat retrieved text as untrusted input.
- 6
Response
Check output for identifiers or PHI that do not belong to the session member, then allow, redact or block.
Verify isolation and define the evidence an auditor needs
- Run negative tests: authenticate as member A and attempt to retrieve member B's claims, benefits and call notes through direct questions, indirect phrasing and injected instructions.
- Confirm queries with no verified identity return nothing instead of an unfiltered result.
- Test memory and cache boundaries by running two sessions in parallel and checking for any shared state.
- Attempt tool calls with another member's identifier and confirm the credential scope and argument validation both reject them.
- Record, for each allow, redact or block decision, the policy applied, the member session, the action and the time.
- Retain the evidence under a defined retention period, and re-run the negative tests whenever indexes, prompts or tools change.
Why leakage is a pipeline problem, not a model problem
A health plan member services bot typically retrieves from claims, eligibility, benefits and call notes covering many members. The model does not decide whose data is in scope. The pipeline does, through the index it queries, the filters it applies, the memory it loads, the credentials its tools use and the checks on what it returns. A failure at any one of these can place another member's PHI in a session.
The Security Rule covers electronic PHI created, received, used or maintained by a covered entity or business associate, so a leak in the bot is a leak of regulated data. OWASP's LLM02:2025 entry on sensitive information disclosure points the same way: limit access on a least-privilege basis, restrict the data sources a model can reach, and keep runtime data orchestration securely managed. Applied here, that means scoping every step to the authenticated member rather than to the whole index or a shared service account.
Bind identity to retrieval, and partition where you can
The central design decision is where the member identity comes from. It should come from your authentication layer, be attached to the request server-side, and be translated into a metadata filter by code the user and the model cannot influence. If the model or the prompt supplies the member ID, prompt injection can change the retrieval scope by asking for a different one.
Metadata filtering on a shared index is the weakest form of isolation, because one missing or mis-specified filter returns every member's records. Separate indexes or namespaces per member or per member cohort reduce the blast radius of that mistake, at the cost of more indexes to build, update and retire. Choose based on member volume, update frequency and what your vector store supports. Whichever you choose, fail closed: if no verified identity is present, the query engine should return nothing rather than fall back to an unfiltered search.
Do not rely on system-prompt instructions such as 'only discuss the current member.' OWASP lists prompt-level restrictions as a possible mitigation alongside others, not as a complete control, and they cannot be verified the way a filter or a credential scope can.
Scope memory and tools to the same identity
Memory is the quietest leak path. If a chat memory buffer, session store or cache is shared or keyed too coarsely, one member's earlier turns can be loaded into another's context. Key every memory and cache entry to the authenticated member and session, set expiry, and clear state when a session ends or when an agent hands off to a human.
Tools need the same treatment. An agent that calls a claims lookup or eligibility API with a shared service credential can retrieve any member's data if its arguments are manipulated, and the downstream system will see only a trusted caller. Issue short-lived credentials limited to the member in session, and validate tool arguments against the session identity before the call executes. Least privilege applied to connectors is usually the most effective single change, because it limits what a compromised prompt can reach.
Call notes and free-text fields deserve extra attention. They often mention family members, other plan members or third parties, so a correctly filtered retrieval can still carry names or details that should not be returned.
Application controls and runtime enforcement are different layers
Everything above is built in the application: filters, partitions, memory keys and credential scopes. These controls matter, but they are hard to verify from the outside. A reviewer has to read code and configuration to confirm that every query path applies the filter, and a later change can quietly remove it. Application logs can show what the code did, but they do not demonstrate that a policy was enforced.
Runtime policy enforcement adds a second layer in the execution path. Policy is evaluated on each interaction and tool call as it happens, with the outcomes allow, redact or block, so a request or response that violates member-level scope is stopped regardless of which code path produced it. This is enforced at runtime, not reviewed after the fact. Trussed provides this kind of enforcement for individual interactions and tool calls, and it generates audit-ready evidence from each decision, mapped to HIPAA, including audit controls under 164.312(b). Trussed runs in production with healthcare and pharma organizations.
The two layers answer different questions. Application controls reduce the chance of a leak. Runtime enforcement limits the damage when one fails and records what was permitted and what was not. The Security Rule allows covered entities to weigh factors such as cost and available technology when choosing reasonable and appropriate measures, so document your rationale for each layer.
Where one member's PHI can reach another member's session
Ingestion
Records written without a member identifier
Retrieval
Shared index, missing or unenforced filter
Memory
Chat history or cache shared across sessions
Tool calls
Credentials broader than the member in session
Response
Another member's data in the final answer
Review isolation at the points where it can fail
Talk to an expert about enforcing policy on interactions and tool calls in your member services bot, and about the audit-ready evidence that enforcement produces.
Talk to an Expert