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.
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:
| Problem | Explanation |
|---|---|
| Model is not policy engine | The LLM is probabilistic and can be manipulated or confused. |
| Unauthorized data already entered context | Once sensitive data is in context, the exposure boundary has already been crossed. |
| Prompt injection can bypass intent | Malicious or ambiguous instructions may override expected behavior. |
| Artifacts are weak | You 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 Pattern | Why It Fails |
|---|---|
| Client supplies tenant filter | User-controlled filter can be omitted or modified. |
| Filter exists only in prompt | Model may ignore or misapply policy. |
| Filter defaults to broad search | Missing metadata creates accidental over-retrieval. |
| Metadata is user-editable | Attackers can mislabel documents. |
| Filter logic differs by endpoint | Some 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.
| Design | Risk |
|---|---|
| One index for all tenants | Metadata bugs can create cross-tenant leakage. |
| One index per environment | Internal/test/prod separation may blur. |
| One index for public and private docs | Low-trust data may contaminate high-trust answers. |
| One index for all roles | Privileged content may be retrieved for low-privilege users. |
A stronger design uses:
| Control | Purpose |
|---|---|
| Physical index separation | Additional isolation when credentials and routing enforce the separation. |
| Logical partitioning | Tenant/role/resource scoping. |
| Mandatory server-side filters | Prevents filter omission. |
| ACL-aware chunk metadata | Carries source permissions into retrieval. |
| Retrieval policy tests | Validates negative cases. |
| Source attribution | Preserves 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.
| Event | Required Behavior |
|---|---|
| User loses access to source document | Retrieval should stop immediately or after defined policy delay. |
| Document is deleted | Associated chunks should be removed or made inaccessible. |
| Tenant is offboarded | Chunks should be deleted or isolated. |
| Classification changes | Retrieval policy should update. |
| Document owner changes | Access metadata should be recomputed. |
| Legal hold begins | Deletion/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:
| Field | Why It Matters |
|---|---|
| Chunk ID | Exact retrieved unit. |
| Source document ID | Parent source. |
| Tenant ID | Boundary enforcement. |
| Owner | Accountability. |
| Classification | Sensitivity. |
| ACL hash/version | Permission state. |
| Ingestion timestamp | Freshness and response support. |
| Source version | Prevents stale material ambiguity. |
| Trust level | Distinguishes 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.
| Question | Why 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.
| Test | Expected Result |
|---|---|
| Tenant A asks for Tenant B's document | No retrieval. |
| Low-privilege user asks for admin-only content | No retrieval. |
| User asks for "similar customers" | Only authorized aggregation. |
| User asks for source text from restricted doc | Refusal or no retrieval. |
| Metadata filter omitted | Backend rejects or inserts required filter. |
| Deleted document queried | No retrieval. |
| Reclassified document queried | New policy enforced. |
| Poisoned document retrieved | Content 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
| Area | Review Question | Good Answer |
|---|---|---|
| Identity | Is the user authenticated before retrieval? | Yes. |
| Tenant isolation | Is tenant scope mandatory? | Yes. |
| Role access | Are roles enforced server-side? | Yes. |
| Resource ACLs | Are document-level permissions preserved? | Yes. |
| Metadata integrity | Can users or documents spoof ACL metadata? | No. |
| Vector partitioning | Are high-risk data classes separated? | Yes. |
| Deletion | Are revoked/deleted documents removed from retrieval? | Yes. |
| Source attribution | Can every answer be traced to authorized chunks? | Yes. |
| Negative tests | Are unauthorized retrieval attempts tested? | Yes. |
| Logs | Are 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.
| Deliverable | Description |
|---|---|
| RAG Data-Flow Map | Shows ingestion, chunking, embedding, retrieval, generation, and logging. |
| Authorization Boundary Review | Identifies where tenant, role, and document permissions are enforced. |
| Vector Store Permission Review | Evaluates partitioning, filters, metadata integrity, and deletion behavior. |
| Negative Test Report | Shows whether unauthorized retrieval attempts fail closed. |
| Chunk Lineage Assessment | Confirms source attribution and artifact preservation. |
| Remediation Roadmap | Prioritizes 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.