TKOResearch
Menu
Back to insights
RAG SecurityRAG SecurityTechnical guide

RAG Authorization Anti-Patterns: When Vector Search Bypasses Access Control

Common RAG authorization failures, tenant-isolation gaps, vector-store access-control mistakes, source attribution issues, and safer retrieval design.

By Kevin O'Connor

Published Last reviewed 8 min read

A search result can be relevant to a question and still belong to another customer's private workspace. That is the authorization problem a RAG pipeline has to solve before returning content to the user or a model provider.

I would start by tracing one document's permissions from the source system through ingestion, retrieval, context assembly, citations and caches. Each copy creates a place where the access rule can drift. OWASP's 2025 vector and embedding risk guidance identifies inadequate access controls and cross-context leakage as RAG concerns.

The anti-patterns below describe implementation failures. They do not depend on the model following a malicious instruction; ordinary questions can expose a broken retrieval boundary.

Why RAG Authorization Is Easy To Get Wrong

A typical RAG pipeline looks straightforward:

User query
  -> embed query
  -> search vector store
  -> retrieve similar chunks
  -> inject chunks into LLM context
  -> generate answer

The problem is that similarity search does not know what a user is authorized to see unless authorization metadata is enforced at retrieval time.

A chunk can be semantically relevant and still unauthorized. That is the core failure mode.

Anti-Pattern 1: Prompt-Based Authorization

Bad pattern:

Retrieve all relevant chunks.
Insert chunks into prompt.
Tell model: "Only answer using information this user is allowed to see."

Why this fails:

ProblemExplanation
Model is not policy engineThe LLM is probabilistic and can be manipulated or confused.
Unauthorized data already entered contextOnce sensitive data is in context, the exposure boundary has already been crossed.
Prompt injection can bypass intentMalicious or ambiguous instructions may override expected behavior.
Artifacts are weakYou may not be able to prove what content influenced the response.

Better pattern:

Authenticate user.
Resolve tenant, role, resource, and document permissions.
Apply authorization filter server-side.
Retrieve only authorized chunks.
Generate answer with source attribution.
Log retrieval decision.

Anti-Pattern 2: Metadata Filters That Are Optional

Many RAG implementations rely on metadata filters such as:

{
  "tenant_id": "tenant_123",
  "classification": "internal",
  "allowed_roles": ["support_admin"]
}

That is fine only if the backend makes those filters mandatory.

Risky patterns include:

Risky PatternWhy It Fails
Client supplies tenant filterUser-controlled filter can be omitted or modified.
Filter exists only in promptModel may ignore or misapply policy.
Filter defaults to broad searchMissing metadata creates accidental over-retrieval.
Metadata is user-editableAttackers can mislabel documents.
Filter logic differs by endpointSome workflows become bypass paths.

Authorization filters should be constructed by trusted server-side code, not by the user, model, browser, or prompt.

Anti-Pattern 3: Shared Vector Index With Weak Partitioning

A shared index can work, but it increases the cost of correctness.

DesignRisk
One index for all tenantsMetadata bugs can create cross-tenant leakage.
One index per environmentInternal/test/prod separation may blur.
One index for public and private docsLow-trust data may contaminate high-trust answers.
One index for all rolesPrivileged content may be retrieved for low-privilege users.

A stronger design uses:

ControlPurpose
Physical index separationAdditional isolation when credentials and routing enforce the separation.
Logical partitioningTenant/role/resource scoping.
Mandatory server-side filtersPrevents filter omission.
ACL-aware chunk metadataCarries source permissions into retrieval.
Retrieval policy testsValidates negative cases.
Source attributionPreserves artifact trail.

Anti-Pattern 4: Authorization Checked At Upload, Not Retrieval

A common mistake is assuming that if a document was valid when indexed, it remains valid forever.

Access changes. Documents are deleted, reclassified, reassigned, transferred, archived, superseded, or restricted.

EventRequired Behavior
User loses access to source documentRetrieval should stop immediately or after defined policy delay.
Document is deletedAssociated chunks should be removed or made inaccessible.
Tenant is offboardedChunks should be deleted or isolated.
Classification changesRetrieval policy should update.
Document owner changesAccess metadata should be recomputed.
Legal hold beginsDeletion/retrieval behavior should follow policy.

RAG authorization must be evaluated at retrieval time, not only ingestion time.

Anti-Pattern 5: No Chunk Lineage

A chunk without lineage is a security liability.

Every retrieved chunk should preserve:

FieldWhy It Matters
Chunk IDExact retrieved unit.
Source document IDParent source.
Tenant IDBoundary enforcement.
OwnerAccountability.
ClassificationSensitivity.
ACL hash/versionPermission state.
Ingestion timestampFreshness and response support.
Source versionPrevents stale material ambiguity.
Trust levelDistinguishes approved docs from untrusted uploads.

Without chunk lineage, you cannot confidently prove whether a response was generated from authorized, current, trusted content.

Anti-Pattern 6: Treating Embeddings As Non-Sensitive

Embeddings are sometimes treated as harmless because they are not the original text.

That assumption is weak.

QuestionWhy It Matters
Are embeddings stored with tenant and ACL metadata?Needed for retrieval enforcement.
Can embeddings be exported?May expose proprietary or sensitive semantic information.
Can an attacker query repeatedly?May infer sensitive content.
Are indexes encrypted and access-controlled?Vector store is still sensitive infrastructure.
Are deleted records removed from embeddings?Prevents stale retrieval exposure.

Treat the vector store as a sensitive data system.

Anti-Pattern 7: No Negative Tests

Positive tests exercise permitted retrieval. Negative tests exercise the requests that must be denied. Passing a finite suite supports a scoped conclusion; it does not prove that no bypass exists.

TestExpected Result
Tenant A asks for Tenant B's documentNo retrieval.
Low-privilege user asks for admin-only contentNo retrieval.
User asks for "similar customers"Only authorized aggregation.
User asks for source text from restricted docRefusal or no retrieval.
Metadata filter omittedBackend rejects or inserts required filter.
Deleted document queriedNo retrieval.
Reclassified document queriedNew policy enforced.
Poisoned document retrievedContent treated as untrusted data.

A RAG system without negative tests is not production-ready.

Secure RAG Authorization Model

Use this design pattern:

User identity
  -> tenant / role / resource policy resolution
  -> server-side retrieval filter construction
  -> vector search over authorized scope only
  -> source attribution and chunk lineage
  -> LLM generation
  -> output policy check
  -> retrieval + generation audit log

Key rule:

The model should never see content the user is not authorized to retrieve.

RAG Authorization Checklist

AreaReview QuestionGood Answer
IdentityIs the user authenticated before retrieval?Yes.
Tenant isolationIs tenant scope mandatory?Yes.
Role accessAre roles enforced server-side?Yes.
Resource ACLsAre document-level permissions preserved?Yes.
Metadata integrityCan users or documents spoof ACL metadata?No.
Vector partitioningAre high-risk data classes separated?Yes.
DeletionAre revoked/deleted documents removed from retrieval?Yes.
Source attributionCan every answer be traced to authorized chunks?Yes.
Negative testsAre unauthorized retrieval attempts tested?Yes.
LogsAre retrieval filters and chunk IDs recorded?Yes.

What A RAG Authorization Review Should Leave Behind

The review should show where retrieval permissions are enforced and which denied paths were actually exercised before model context was assembled.

DeliverableDescription
RAG Data-Flow MapShows ingestion, chunking, embedding, retrieval, generation, and logging.
Authorization Boundary ReviewIdentifies where tenant, role, and document permissions are enforced.
Vector Store Permission ReviewEvaluates partitioning, filters, metadata integrity, and deletion behavior.
Negative Test ReportShows whether unauthorized retrieval attempts fail closed.
Chunk Lineage AssessmentConfirms source attribution and artifact preservation.
Remediation RoadmapPrioritizes pre-launch fixes and longer-term hardening.

Test stale permissions, not only the first query

Run a permitted search, revoke the document ACL, and try to reuse the result through the context builder, citation renderer and any answer cache. The version that passes the first search but returns a stale citation after revocation still has a gap.

A trusted retrieval service may rank candidate IDs before a final authorization check, provided unauthorized content and metadata never escape its protected boundary. If an external reranker or model sees the chunks, authorization must already have happened. The local two-tenant walkthrough makes that distinction explicit.

Sources