Shipping RAG without leaking customer data
Tenancy, retrieval filters, and redaction so search stays useful without becoming an exfiltration path
Retrieval-augmented generation is useful until it becomes a polite way to cross tenant boundaries. The hard part is not chunking—it is proving that every retrieved fragment was allowed for this caller, in this context, right now.
Tenancy is a filter, not a footnote
Every document in the index needs a tenant (and ideally a visibility) attribute. Every query must filter on those attributes before similarity ranking. Application-layer “we will remember to pass orgId” is not enough—encode it in the retrieval API.
Tenant-scoped retrieval
Loading code…Minimize what leaves the boundary
Prefer providers and modes that keep embeddings and prompts in a contract you understand. Redact secrets and direct identifiers before chunking. Do not paste production dumps into a personal playground “just to test.”
If a document is too sensitive to retrieve into a prompt, it does not belong in the RAG corpus—use a dedicated workflow with stronger controls.
Before it enters the corpus
- Tenant (and visibility) attributes exist on every document
- Secrets and direct identifiers are redacted or excluded
- Provider contract for embeddings/prompts is understood—not assumed
- Documents too sensitive for prompts use a separate, stricter workflow
Cite, bound, and refuse
Return citations with answers. Cap context window size so a single query cannot vacuum an entire tenant. When retrieval is empty, say so—do not let the model invent a helpful-sounding void.
Answer only from retrieved context
Loading code…Audit the path
Log tenant id, query hash, hit ids, and model version—not raw customer text in shared logs if you can avoid it. Retention should match your security policy. Leaks are often found in logs long before they are found in the model.
Final thoughts
RAG is a data-access feature wearing a language model. Filter by tenancy first, minimize exfiltration surfaces, cite sources, refuse empty context, and audit the path. Usefulness without those controls is just a slow breach.
Related Articles
AI for small businesses: useful automations vs expensive demos
Inbox triage, quoting, and CRM sync—when to use an LLM and when rules win
Cost control for LLM features in production
Budgets, caching, and model tiers so AI remains a product cost—not a surprise invoice
Ready to build something this considered?