Guide

RAG over your customers' data

Draft, not yet reviewed

What you are building

You retrieve customer content and put selected chunks into a model's context so it can answer a question. The retrieval query decides which data the model receives before it writes that answer.

Where untrusted text gets in

  • Uploaded files and pages that customers or other users can edit.
  • Retrieved chunks, including text hidden in a source document's styling.
  • Search and tool results added alongside the user's question.
  • Previous content that remains in a retrieval store after a visible message is deleted.

What it can do if it goes wrong

  • Put another tenant's chunks into the current user's model context.
  • Treat instructions in a document as authority over the answer or available tools.
  • Disclose prompt secrets or cause a network request through an answer's rendered image or link.
  • Recall deleted content from a derived copy that the delete path did not remove.

Know the limit

A tenant filter does not make the retrieved text trustworthy. The model can still follow an instruction from a document that the user is allowed to read. If retrieval happens inside a tool-calling agent, use the tool and approval controls too, and assert on the actions it actually attempts.

Minimum controls

  1. Treat retrieved and uploaded content as data, not instructions

    30 min

    Outside text is labeled as untrusted, hidden document text is checked, and tools that send data or change state are removed or gated.

  2. Isolate tenants in retrieval

    45 min

    Retrieval uses the session's tenant ID in the datastore query, and cross-tenant canaries never appear in retrieved chunks.

  3. Render model output as untrusted

    30 min

    Model output cannot inject active HTML or load images and links from unapproved hosts, and model-written URLs are never fetched automatically.

  4. Assume your system prompt will leak

    10 min

    System prompts contain no keys, internal URLs or credentials, and security rules are enforced in code.

  5. Make delete mean the model can no longer recall it

    45 min

    Deletion reaches every documented copy of user content, or the product explicitly identifies retained copies and their limits.

  6. Run injection tests on every change

    45 min

    A fixed pack of attacks and benign controls checks tool calls and arguments in CI when prompts, models or tools change.