AI document search that shows one customer’s files to another (RAG and vector store leaks)

Last updated November 15, 2026
Steps
- Find where your embeddings live (for example a pgvector table in Supabase or Postgres, or a hosted vector database) and confirm every row or vector carries the owner or tenant ID of the document it came from.
- Read the retrieval code. The similarity search must filter by the owner or tenant taken from the server-side session, not from a value the browser sends. A plain “top 5 most similar chunks” query across everyone’s data is the leak.
- If you use Postgres, enable row-level security on the embeddings table with an ownership policy. Check that the similarity-search function runs with the caller’s permissions: a SECURITY DEFINER function, or a connection as the table owner or a role that bypasses RLS, skips those policies.
- With a hosted vector database, keep each customer in a separate namespace or index, or add a mandatory metadata filter in your server code on every query. Never let the client choose the namespace.
- Treat embeddings as being as sensitive as the documents: keep vector database keys on the server, and don’t return raw vectors to the browser.
- When a user deletes a document or closes their account, delete its chunks and vectors too.
- Before indexing uploads, extract plain text and look for hidden content (white-on-white text, tiny fonts) that could steer the AI, and treat retrieved text as untrusted input.
- Retest with two test accounts: upload a document with a unique made-up phrase as account A, then ask about that phrase as account B. Account B should get nothing.
- Log which chunks each query retrieved, for which user, so you can spot and investigate cross-account hits.
Why it matters
OWASP describes a multi-tenant scenario where groups share one vector database and embeddings from one group are retrieved for another group’s questions, leaking sensitive business information; its mitigation is a permission-aware vector store with strict logical partitioning. It also describes a résumé with hidden white-on-white instructions that a RAG screening system followed, and recommends validating documents before they enter the knowledge base and keeping retrieval logs. PostgreSQL’s documentation notes that superusers, roles with BYPASSRLS and, normally, table owners bypass row security, which is why the connection and function your search runs under matter. This page is for checking and fixing your own app.
Sources
OWASP Gen AI Security Project: LLM08:2025 Vector and Embedding Weaknesses — https://genai.owasp.org/llmrisk/llm082025-vector-and-embedding-weaknesses/
PostgreSQL Documentation: Row Security Policies — https://www.postgresql.org/docs/current/ddl-rowsecurity.html
Checked at the source on November 15, 2026.
Related patterns
- RLS or auth present, but no ownership check (IDOR)
- Supabase SECURITY DEFINER functions any visitor can call
- Prompt injection in your app's AI chatbot or AI features
- Secrets and access rules hidden in your AI system prompt (system prompt leakage)
- Third-party secret keys (OpenAI, Stripe, Resend) in client JS
- File uploads with no type, size or name checks
FAQ
I only have one customer’s data per user. Am I safe?
Only if the search itself is filtered. If every user’s chunks sit in one table and the query doesn’t filter by owner, the most similar chunk can belong to anyone.
Is filtering the AI’s answer enough?
No. Filter what gets retrieved, before it reaches the model. Once another customer’s text is in the prompt, you’re relying on the model not to repeat it.
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.