C43 Updated 2026-06-20
Pillar 4 - Troubleshooting

My RAG Leaks Docs to the Wrong Users

RAG leaks happen when retrieval ignores tenant, library, visibility, or user ACLs before candidate documents enter the model context.

RAG leaks docs to the wrong users when retrieval returns out-of-scope candidates before permissions are applied. Fix it by enforcing tenant, library, visibility, and user scope in the candidate query itself, then enriching and answering only from allowed source artifacts.

Last updated: June 20, 2026.

Why is post-answer filtering too late?

If a restricted source enters the model prompt, the leak already occurred. The final answer might be filtered, but the model still had access to text the user should not see. Permissions must shape the candidate set before context assembly.

The NIST AI Risk Management Framework is a useful governance reference: trusted systems need controls that reduce risk before harm occurs. The retrieval layer is one of those controls.

Where does oversharing happen?

Oversharing can happen at several points:

Failure pointExample bug
Vector searchSearch runs across all tenants before filtering
Library scopeA project library is ignored during retrieval
VisibilityPrivate content is enriched for a non-owner
SharesShare joins omit tenant boundary
LogsOut-of-scope snippets are stored in traces
Prompt assemblyCandidate list includes restricted documents

Answer Engine’s tenant-isolation implementation pattern, described in Permission-aware retrieval, binds tenant_id and library scope before content enrichment and answers. That is the pattern to demand from any memory or RAG system.

How do you inspect an ACL leak?

Trace the request:

  1. Who is the authenticated actor?
  2. Which tenant and library scope were selected?
  3. Which visibility rules apply?
  4. Which content ids were eligible before vector search?
  5. Which ids returned from search?
  6. Which ids were enriched?
  7. Which snippets entered the prompt?
  8. Which citations appeared in the answer?

If you cannot see this trace, you cannot prove the leak is fixed.

How do you fix it?

Apply permissions before retrieval. For full-text search, put scope in the SQL WHERE clause before ranking. For vector search, pass filters into the vector function or prefilter allowed ids and post-filter only inside that allowed candidate pool. For joins, match tenant ids across content, tags, shares, and library membership.

Then add negative tests. A user from Tenant A should not retrieve Tenant B’s unique phrase. A user without private access should not retrieve a private source by exact title. A library-scoped query should not return content outside the library.

How does deletion relate?

Deleted or disabled sources are also permission failures if they still retrieve. The GDPR right to erasure is one external reason deletion matters, but the product reason is simpler: unavailable sources should not enter candidate memory.

What should a negative test look like?

Use unique phrases that exist in one restricted source and nowhere else. Then test from an actor that should not have access:

TestExpected result
Tenant B asks for Tenant A’s unique phraseNo active source returned
Non-owner asks for private document titleNo snippet, citation, or summary returned
Library-scoped query asks for out-of-library sourceCandidate excluded before ranking
Deleted document exact phrase searchDeleted source unavailable

These tests should inspect retrieval candidates, not only the final answer. A final answer can be empty while restricted snippets still reached the model.

What should you log?

Log the authorization boundary without leaking restricted content: tenant id, library id, actor id, allowed candidate count, rejected candidate count, source ids that entered the prompt, and citation ids returned. Do not log full restricted snippets into a broadly visible debug stream.

For high-risk workflows, keep a trace that an auditor can replay with the same actor and scope. That is how you prove that a leak fix works rather than merely changing the wording of the answer.

Read Permission-aware retrieval, RAG returns wrong results, and the Memory Failure-Mode Catalog. Use the Memory Leaderboard to compare permission controls across systems.

Sources

Fig. 9 FAQPage schema / visible answers
FIG. 9

FAQ

Why does RAG leak docs to the wrong users?

The retrieval layer is probably returning candidates before tenant, library, visibility, or user permissions are applied.

Is post-answer filtering enough?

No. Filtering after the model sees restricted text is too late. Permission checks must constrain candidates before retrieval or enrichment.

How do I inspect an ACL leak?

Trace tenant_id, library scope, visibility filters, share joins, candidate ids, and the final prompt evidence.

How do I fix RAG oversharing?

Apply ACL filters before vector or hybrid search, join with tenant boundaries, and add negative cross-tenant tests.

NEXT

Build memory you can inspect.

Answer Engine gives agents a persistent, tenant-isolated memory layer via MCP, with source-aware recall and roadmap-labeled inspection work.