Home / patterns

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

A young developer at a home-office desk at night studying two monitors, one with a blurred chat-style app and one with a list of document rows with several flagged in red, a coffee mug and desk lamp nearby, no brand logos
Quick answer: “Chat with your documents” features in vibe-coded apps usually split every uploaded file into chunks, turn them into embeddings, and store them all in one vector table or index. The app then retrieves whatever chunks are most similar to the question. If that search doesn’t also filter by the signed-in user or company, the AI can quote another customer’s contract, invoice or notes. OWASP’s Top 10 for LLM applications lists this under Vector and Embedding Weaknesses (LLM08:2025), along with poisoned documents and embeddings that can be inverted to recover the original text. The fix is ordinary access control, applied to retrieval.

Last updated November 15, 2026

Steps

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. When a user deletes a document or closes their account, delete its chunks and vectors too.
  7. 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.
  8. 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.
  9. 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

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 StorenTech

Vibe 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.