Skip to content

AI security / Retrieval

RAG security testing for retrieval and data boundaries.

Retrieval augmented generation puts a document store between the user and the model. FailSafe tests whether permissions, filters and index isolation keep one user's data out of another user's answer.

A RAG security assessment records what was retrieved, which identity asked, what reached the model context and what the application did with it. A model refusal alone does not show that restricted data stayed out of reach.

RAG scope is agreed separately. The Startup offer covers one authorized black-box run and 250 credits; a retrieval assessment usually needs test identities, synthetic documents and staging access.

Definition

What is RAG security testing?

RAG security testing is the authorized assessment of a retrieval augmented generation pipeline: ingestion, chunking, embedding, indexing, retrieval, context assembly, generation and the systems that read the answer. The question is whether each stage enforces the access rule the application claims.

Most failures are ordinary application failures. A filter is missing on one query path. A metadata field is set by the document instead of the platform. A shared namespace serves two tenants. A deleted document remains in a cache or summary. A retrieved instruction is treated as a tool request.

Data in

Sources, uploaders, parsers and metadata that decide what the index can contain.

Data out

Query paths, filters, namespaces, caches and the records a user can reach.

Evidence

The identity, result set, context, output and state change for each case.

Test areas

Where a retrieval pipeline loses control.

The table connects each boundary to the question it should answer and the record to keep. Agree the applicable rows and exclusions in writing before testing.

RAG assessment areas and the evidence each one should produce
BoundaryQuestionEvidence to record
Ingestion and parsingWhich sources are accepted, who can add them, and what the parser does with hidden text, archives and embedded instructions.Source, uploader role, parser version, extracted text and any instruction-like content that survived.
Chunking and metadataWhether tenant, owner and classification fields are set by the system and cannot be overwritten by the document or the user.The chunk record, metadata origin and the effect of a user-supplied field.
Embedding and index isolationWhether each tenant or permission scope has a separate namespace, filter or index, and which service credentials can read across them.Index or namespace name, query principal, returned identifiers and the service account used.
Retrieval and filtersWhether every query path applies the same access rule, including search, preview, re-rank, summarisation and admin tools.The rule expected, the filter actually applied, the result set and the path used to reach it.
Context assemblyWhat is placed in the model context, in what order, and whether untrusted content is labelled as data rather than instruction.Context reference, source labels, truncation behaviour and whether restricted text entered the context.
Output and downstream useWhether retrieved content can cause a link, tool call, rendered element or stored record that the user is not entitled to produce.Output, downstream call or state change, approval state and the control that allowed or blocked it.
Revocation, deletion and cacheWhether access changes and deletions propagate to the index, caches, summaries and generated answers within the stated window.The revoked identity or deleted source, the repeated query, the residual record and the observed time to removal.

Agree the target, test identities and stop rules first. The rules-of-engagement guide covers authorization, permitted effects and the events that pause a run.

How it runs

Four steps from scope to a retested fix.

01

Define the data boundary

Name the tenants, roles, document classes and actions the pipeline is supposed to enforce. Pick synthetic records that stand in for each class, and agree the stop conditions before any query runs.

02

Test each retrieval path

Exercise the user-facing search, any preview or re-rank endpoint, background summaries and support or admin tools. For each path, record the identity, the filter applied and the records returned.

03

Verify the consequence

A retrieval result is not yet a finding. Show what the user saw, what entered the model context and what the application or model did with it. Keep the permitted control case beside the denied one.

04

Retest after the fix

Repeat the original case and the control on the corrected build. A blocked prompt variant does not show that the access rule was fixed. Record the deployed index version and any path that could not be retested.

Synthetic example

One query, two workspaces.

A fictional support assistant answers questions from documents in Workspace A. A test user in Workspace A asks about a contract. The expected boundary is that retrieval returns only Workspace A records and the answer cites only those records.

The assessment creates one synthetic contract in each workspace, then repeats the query with the filter present, removed and altered. For each attempt it records the retrieval result with document identifiers, the assembled context, the answer, the cited source and the permission decision. A final answer that omits the other contract does not by itself show that the other contract was never retrieved.

This is a test design, not an executed customer assessment. No real document, credential or production endpoint is needed to describe the boundary.

What the record should let a reviewer check

  • The identity and role that issued the query, and the workspace it belonged to.
  • The filter or namespace the application applied, and whether the user could influence it.
  • The document identifiers returned before and after the model saw the context.
  • The output, citation or action, and whether any restricted content appeared in it.
  • The permitted control case, so a denied result can be distinguished from a broken query.
Illustrative case, control and retest record. This is a test design, not an executed result.
StageExample recordWhat it does not show
FindingReader A's query returns a synthetic contract from Workspace B before the answer is generated.Whether the same result is reachable through another query path or outside the test configuration.
ControlThe same query returns only the Workspace A contract when the filter is applied.That every other path applies the same filter.
FixThe object lookup is bound to the caller's workspace, and the tenant field is written by the platform rather than the document.That caches, summaries or generated answers were also corrected.
RetestThe original query is denied and the Workspace A control succeeds on the corrected build.That a future index change, a new query path or a different tenant is covered.

The MCP worked example follows the same pattern at the tool boundary. The synthetic finding and retest record shows how to keep the failure and the correction together.

Testing guides

Go deeper on each retrieval boundary.

Each guide covers one part of the pipeline and the evidence to retain. Use them to plan an assessment, or to check whether a proposal tests the paths your system actually uses.

Start a conversation

Bring the pipeline you need tested.

Tell us how documents enter, who can query them and which paths use retrieval. We will agree the boundary, the synthetic data and the evidence before the first run.

RAG scope is confirmed separately. The Startup offer covers one authorized black-box run and 250 credits.

Sources and scope

What supports this page

This page describes an assessment method and the records an engagement should produce. The workspace example is a test design, not an executed customer assessment. Coverage, access, synthetic data and retest terms are agreed per engagement, and a model response alone is not treated as proof that restricted data stayed out of reach.

By FailSafe Research. Editorial update: .

Cite this page: FailSafe Research, https://getfailsafe.com/rag-security-testing, updated .

Questions & answers

Frequently asked questions

RAG security testing scope, retrieval boundaries, evidence, deletion and retest.

RAG security testing is an authorized assessment of a retrieval augmented generation pipeline. It examines what is ingested, how chunks and metadata are indexed, which documents a query can return, what reaches the model context, and what happens when access changes or content is deleted.

A scoped assessment can cover document ingestion and parsing, chunking and metadata, embedding and index isolation, retrieval filters, context assembly, output handling, tool use after retrieval, permission revocation, deletion and cache invalidation. The agreed scope records which of these are tested.

Create synthetic records for at least two workspaces, query as a user from one workspace, and record whether any record from the other workspace appears in retrieval results, the assembled context or the final answer. Repeat with filters removed, renamed and replayed. The test needs the retrieval result, not only the model response.

Filters are application logic and can fail in ordinary ways: a filter applied to one query path and not another, a metadata field that is writable by the user, a namespace that is shared across tenants, or an administrative preview route with weaker checks. Testing compares the intended rule with the records actually returned on each path.

Retrieved content is untrusted input. A document can contain text that tries to change the answer, request a different tool call or direct the model toward another data source. Testing records whether that text influenced an action, and whether an application or server control stopped the effect.

Keep the test identity and role, the synthetic document or query, the retrieval result with identifiers, the filter or permission decision, the assembled context reference, the model or application output, and the resulting state. Record the deployed index version and any untested path or unavailable observation.

Revoke a test user's access or delete a synthetic document, then repeat the original query through every supported path, including caches, previews and background summaries. A removed source record does not establish that a cached embedding, chunk or generated answer was also removed.

The Startup offer covers one authorized black-box run with 250 credits. A RAG assessment usually needs test identities, synthetic documents and staging access, so scope is agreed separately. Confirm fit with the team before purchasing.