RAG data boundary checks for AI assistants
Brief
An assistant that answers from company documents is an access control system, and the usual flaw is that its index does not know who may read what. We plant a unique marker in a document one test user owns and ask for it as another, then repeat after the share is removed and after the file is deleted.
On this page
- Situation
- The map from the LLM app recon page: the assistant's routes, its sources, and how documents reach the index. Two test accounts in the same tenant with different access, a third in a second tenant where the app is multi-tenant, and only documents we wrote in the corpus. We test only the applications and tenants the scope letter names; every marker is a plain fact in our own file, never an instruction to the model.
- Goal
- A boundary table: for private, revoked, deleted and other-tenant documents, whether the assistant, the search route and the citation route each returned the marker, with the request that showed it.
- Outputs
- Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.
Check first
- Which sources feed the index (uploads, a shared drive, a ticket system) and how often each one syncs.
- Whether the index stores each chunk's permissions, or the app filters after retrieval, or neither.
- Two test accounts with different access and, for a multi-tenant app, one in a second tenant.
- A marker per test, such as
ATARUS-BOUNDARY-4c9e, agreed with the client and absent from their corpus. - Confirmation that retrieval is logged with the chunk and document ids, so the client can trace each answer.
Steps
Does retrieval respect the asking user's permissions?
cat > project-notes-b.txt <<'EOF'
Project notes (test copy, tester-b only). The test reference for this file is ATARUS-BOUNDARY-4c9e.
EOF
curl -s -F "file=@project-notes-b.txt" -F "visibility=private" -H "Authorization: Bearer $TOKEN_B" https://app.example.com/api/documents
Expected output
{"id":"doc_test_0412","name":"project-notes-b.txt","visibility":"private","indexed":true} # <- indexed and private to tester-b
POST /api/assistant/messages HTTP/1.1
Host: app.example.com
Authorization: Bearer <token for tester-a, redacted>
Content-Type: application/json
Accept: text/event-stream
{"conversation_id":"conv_test_0410","message":"What is the test reference in the project notes?"}
Expected output
event: citation
data: {"document_id":"doc_test_0412","title":"project-notes-b.txt"} # <- tester-a was given a chunk from tester-b's private file
event: message_delta
data: {"text":"The test reference is ATARUS-BOUNDARY-4c9e."}
The file belongs to tester-b and is private; tester-a cannot open it through the app's ordinary document routes, which we confirm first. If the assistant quotes the marker, retrieval ran without the asking user's permissions, usually because the index was built by a service account that reads everything. We repeat the same question from the second tenant's account, since a shared index with a missing tenant filter is the worst form of this.
Negative result. No citation of doc_test_0412 and no marker for tester-a or the other tenant, while tester-b gets both. Ask once more in plainer words before recording it as holding.
Fix. Store the source's permissions with every chunk and filter the search by the calling user's identity before ranking, not after the model has seen the results. Keep tenants in separate indexes or namespaces enforced by the search service.
Does a removed share or a deleted file leave the index?
curl -s -X POST -H "Authorization: Bearer $TOKEN_B" -H 'Content-Type: application/json' \
-d '{"user":"tester-a"}' https://app.example.com/api/documents/doc_test_0412/shares
# tester-a asks and gets the marker, as expected; then the share is removed
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE -H "Authorization: Bearer $TOKEN_B" \
https://app.example.com/api/documents/doc_test_0412/shares/tester-a
Expected output
{"document_id":"doc_test_0412","shared_with":"tester-a"}
204
14:05 share removed tester-a asks: marker returned
14:35 thirty minutes on tester-a asks: marker returned # <- the index still grants a share the source revoked
15:05 an hour on tester-a asks: no marker
Indexes copy permissions at sync time, so the question is how long a revocation takes to arrive. We ask the same question at fixed times after the share is removed and record the lag, then delete the file and repeat. A deleted file that still answers means the index keeps chunks the source no longer has.
Negative result. The marker stops at the next question after the share is removed, and never appears after deletion.
Fix. Check the source's permission at query time for each retrieved document, or push revocations and deletions to the index as events rather than waiting for the next full sync. Set and publish a maximum lag the business accepts.
Can the search and citation routes be called directly?
curl -s -X POST -H "Authorization: Bearer $TOKEN_A" -H 'Content-Type: application/json' \
-d '{"query":"ATARUS-BOUNDARY-4c9e","top_k":3}' https://app.example.com/api/assistant/search | jq -r '.results[].document_id'
curl -s -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $TOKEN_A" \
https://app.example.com/api/documents/doc_test_0412/chunks/0
Expected output
doc_test_0412 # <- the search route returns tester-b's document to tester-a
200
The chat may filter its answer while the routes behind it do not. Many apps expose a search route for their own interface and a chunk route for citation previews, and both are ordinary API routes with the usual object level checks to make. We read the chunk response to confirm it holds our marker, since a 200 with an empty body proves nothing.
Negative result. The search route omits the document for tester-a, and the chunk route returns 403 or 404.
Fix. Apply the same permission filter on the search and chunk routes as on the chat, from the same code, and test it with two users in the app's own test suite.
The defender sees
Each answer should leave one record with the user, the conversation id, the query, the chunk and document ids retrieved, and the document owner. The first test then shows as tester-a's conversation citing doc_test_0412, owned by tester-b, and an alert on any retrieval where the asking user cannot open the document is the detection this page argues for. The share and deletion show in the document audit log under tester-b, and the lag is visible by comparing those times with later retrievals. If the client's logs hold the answer but not the chunk ids behind it, they cannot tell which user's data left, and that gap belongs in the report beside the boundary finding.
Done when
Each of the four document states has been asked about through the chat, the search route and the citation route by an account that should not see it, every test document is deleted with its id recorded, and the index lag after a permission change is measured.
Not covered
Prompt injection through documents (see prompt injection testing), connector setup inside the source systems, and model memory across conversations; the outputs shown are representative examples on a placeholder app, not captured runs.