# The index remembers what the source forgot: permission drift in RAG

> A RAG index that copies permissions at ingest keeps serving files after access is revoked. A lab run leaked 15 to 20 percent of chunks. The query-time fix.

- Canonical URL: https://webofmike.com/the-index-remembers-what-the-source-forgot/
- Author: Mike Moore (https://webofmike.com/about/)
- Published: 2026-12-03
- Last modified: 2026-11-30
- Tags: AI Agents, Security, AI Gateways, MCP
- Cite as: Mike Moore, "The Index Remembers What the Source Forgot", Web of Mike (webofmike.com), 2026-12-03. https://webofmike.com/the-index-remembers-what-the-source-forgot/


A RAG index that copies permissions at ingestion time is a second, older copy of who may read what. When the source changes and the index does not, the model summarizes files the user can no longer open. In my synthetic lab, one round of reorg-style changes made a stale index return chunks the caller could not read in 15.5 to 19.6 percent of results (mean 17.5 over ten random draws), and in 53 to 64 percent of queries at least one returned chunk was unreadable. Rechecking each hit against the source's live permissions at query time cut that to zero across all ten draws.

The trigger for this post was an essay in The AI Collective's newsletter, "The Governance Layer Nobody Regulates," by Karthik Chandrasekaran, who works on a large enterprise retrieval stack. His premise: enterprise AI safety is decided at retrieval, before the model writes a word. I am using that premise and nothing else from it. Every measurement below is from my own lab, and the sources I checked are listed at the end.

*The gateway tests here use the open source agentgateway standalone binary only.*

## What is permission drift in a RAG index?

A retrieval index has to answer "may this person read this chunk?" thousands of times a second, so most designs answer it from a copy. At ingestion, the pipeline reads the source's access list and stores it next to the vector. There are two common shapes of that copy:

- **Materialized users.** The index stores the resolved list of people who could read the document on ingest day.
- **Stored groups, live caller.** The index stores the document's group IDs, and the caller's current groups come from the identity provider on each query.

The second shape is the one Microsoft documents for Azure AI Search in its [security filter pattern](https://learn.microsoft.com/en-us/azure/search/search-security-trimming-for-azure-search): a filterable `group_ids` field on each document and a `search.in` filter built from the caller's groups. The same page says the service "doesn't provide APIs or features for populating the security field", so keeping that field in step with the source is your job. (The page also points to built-in ACL support for sources that have it. I did not test either route.) Membership changes are live in that shape. Changes to the document's own access list are not, until something rewrites the field.

That is the drift. It does not need an attacker. A reorg moves a team, a manager tightens a folder, a contractor leaves, and the source system forgets. The index does not.

## How much does a stale index leak?

I built a small lab so the answer would be a measurement and not an adjective. It is synthetic from end to end: 240 generated documents across 24 topics, 12 users with group memberships, and 72 questions. Each topic has 3 all-staff documents, 3 department documents and 4 restricted documents that share vocabulary, which is why a relevance ranker pulls restricted records into the top five for ordinary questions (98 of the 360 unfiltered top-five slots, 27%). Embeddings are BAAI/bge-small-en-v1.5 through fastembed, and search is exact cosine over numpy, so there is no approximate-search noise in the numbers.

The drift in the lab is one round of the ordinary kind:

- 4 users each lose one restricted group (offboarding and reorgs).
- 12 all-staff documents get tightened to one department.
- 12 department documents get moved to the restricted group.

Then every one of the 12 users asks every one of the 72 questions, 864 asks in all, and I count returned chunks the source would no longer let that user read. Top 5 each time.

| Design | Chunks returned that the caller can no longer read | Queries with at least one |
|---|---|---|
| Index copy of who may read, built at ingest (materialized users) | 16.85% | 60.0% |
| Index copy of document groups, live caller groups | 14.75% | 55.7% |
| Index copy as a pre-filter, then live recheck of each hit | 0% | 0% |

Before the drift, all three designs leaked 0%. After it, I repeated the drift with ten different random choices of which documents get re-permissioned. The first design leaked 15.49% to 19.56% of chunks (mean 17.51%) and 53.2% to 63.7% of queries. The second leaked 13.19% to 17.41% (mean 15.30%). The recheck design leaked 0% in all ten draws.

Here is one real ask from the run. A user who just lost the restricted HR group asks "How do I report a workplace concern?":

```text
index copy only
  ok   hr-workplace-complaint-intake-open-1        acl_now=['all']
  ok   hr-workplace-complaint-intake-open-0        acl_now=['hr']
  ok   hr-workplace-complaint-intake-open-2        acl_now=['all']
  LEAK hr-workplace-complaint-intake-restricted-2  acl_now=['hr-cases']
  LEAK hr-workplace-complaint-intake-dept-2        acl_now=['hr-cases']

index copy plus live recheck
  ok   hr-workplace-complaint-intake-open-1        acl_now=['all']
  ok   hr-workplace-complaint-intake-open-0        acl_now=['hr']
  ok   hr-workplace-complaint-intake-open-2        acl_now=['all']
  ok   hr-workplace-complaint-intake-dept-0        acl_now=['hr']
  ok   hr-workplace-complaint-intake-dept-1        acl_now=['hr']
```

The most useful row in the full output is the boring one. The stale design's relevance score (NDCG@5 against topical judgments) is 0.691 before the drift and 0.691 after it, while it goes from leaking nothing to leaking one chunk in six. Nothing on a relevance dashboard moves. I come back to that in the next post, "Relevance Is Not Authorization," which is about what to measure instead.

These percentages come from my corpus. A real corpus will have a different share of restricted material and different drift. The ordering is the finding: a copy leaks after the source changes, a live recheck does not.

## Should RAG enforce permissions at ingest or at query time?

Both, with different roles. The ingest copy is a performance hint: it lets the index pre-filter so most queries never touch the source system. The query-time check is the authority: before any chunk is placed in the model's context, ask the source whether this caller may read it now.

The recheck has one design wrinkle. If you retrieve exactly the top five and then drop the ones that fail, you hand the user fewer than five. So over-fetch, recheck, then truncate. In pseudocode, this is what the lab's recheck design does:

```python
def retrieve(query_vec, user, k=5, overfetch=20):
    candidates = index.search(query_vec, prefilter=index_acl(user), top=overfetch)
    allowed = source.can_read_batch(user, [c.doc_id for c in candidates])   # live
    return [c for c in candidates if allowed[c.doc_id]][:k]
```

In the lab this design returned an average of 5.0 chunks per query with no leaks. If your source can answer in a batch ("which of these 20 may this user read right now?"), the extra cost is one round trip per query, not one per chunk. I did not measure that round trip. In my lab the "source" is a dictionary, so the lab says nothing about the latency of a real identity or document system. Measure the p95 of your own batch permission call before you decide the over-fetch size.

Two failure modes to design around. If the source system is down, fail closed and return nothing from restricted collections. And log what you dropped: a rising drop rate is the earliest signal that your index copy is drifting. The same log answers the audit question, [what did this agent read and on whose authority](/agent-audit-log-integrity/).

## What can an AI gateway enforce on a retrieval tool?

Tool-level access, on the caller's live token, and nothing finer. I ran open source agentgateway 1.7.0 in front of a small MCP server with two tools, one over the all-staff collection and one over the restricted HR collection. The server has no auth code. The gateway validates the JWT, then applies an allow list:

```yaml
mcp:
  port: 3000
  policies:
    mcpAuthentication:
      issuer: https://idp.lab.test
      audiences: ["http://127.0.0.1:3000/mcp"]
      jwks: {file: ./keys/idp.jwks.json}
      resourceMetadata:
        resource: http://127.0.0.1:3000/mcp
        scopesSupported: [read:all]
        bearerMethodsSupported: [header]
    mcpAuthorization:
      rules:
      - 'mcp.tool.name == "search_open_docs"'
      - 'mcp.tool.name == "search_hr_cases" && "hr-cases" in jwt.groups'
  targets:
  - name: docs
    mcp: {host: http://127.0.0.1:18081/mcp}
```

These are allow rules, so a tool no rule matches is refused, and refused tools are filtered out of `tools/list`. That is the same fail-closed shape as in [the standalone demo](/agentgateway-standalone-demo/), and the reason I keep writing [allow rules and not deny rules](/agentgateway-cel-authorization-gotchas/). Here is what I saw when I revoked a user in the stand-in identity provider:

| Step | tools/list | search_hr_cases |
|---|---|---|
| Fresh token, before the revoke | both tools | works |
| Same token, after the revoke (it expires in 15 minutes) | both tools | works |
| New token issued after the revoke | search_open_docs only | HTTP 400, JSON-RPC error -32602 "unknown resource" |

So the gateway is exactly as live as the token. The old token kept working because nothing told the gateway otherwise. That is a window you control with token lifetime, and it is the same trade-off I covered for [token exchange](/agentgateway-token-exchange/).

Then I tested what happens at expiry. I minted a token with a 3 second lifetime and sent it on every request, the way MCP clients send a bearer token, then tried again as it aged:

| Token age | Seconds past its exp | New connection | Call on the old session |
|---|---|---|---|
| 0 s | none | 200 | not tried |
| 20 s | 17 | 200 | 200 |
| 50 s | 47 | 200 | 200 |
| 70 s | 67 | 401 | 401 |

An expired token was accepted for at least 47 seconds and rejected by 67. [RFC 7519](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4) allows a small leeway on `exp` for clock skew, "usually no more than a few minutes", so a window like this is within the standard. I did not find agentgateway's value documented, and I did not pin the exact cutoff between 47 and 67 seconds. For design purposes, treat revocation through a token as taking a few minutes.

This is also where the gateway stops. It can see `jwt.groups`. It cannot see that document 4182 was moved to a different folder an hour ago. Document-level answers have to come from the retrieval service asking the source. The gateway still earns its place: it keeps the retrieval tools from being reachable at all by callers who have no business with that collection, [filters what the agent can even discover](/what-is-an-mcp-gateway/), and gives you one place to [gate the call itself](/tool-call-guardrails/).

## What should I do about this on Monday?

1. **Find where the access list is copied.** Name the field, the job that fills it, and how often it runs. If nobody can answer, that is the finding.
2. **Measure your drift.** Sample a few hundred chunks. For each, compare the index copy to the source's answer for three real users. The disagreement rate is your leak rate before any attacker shows up.
3. **Add the live recheck with over-fetch.** One batched permission call per query, fail closed.
4. **Use the gateway for the coarse rule.** Allow rules per tool on live claims, and short token lifetimes.
5. **Log every drop.** The drop rate is your drift alarm and your audit trail.
6. **Put a revoked-user query in CI.** Revoke a test user, ask a question that used to reach a restricted chunk, and fail the build if it comes back. [Agent action verification](/agent-action-verification/) uses the same binary-check idea on the call path.

## Do the AI regulations cover the retrieval layer?

Partly, and the framing "regulation only looks at the model" is not quite right. What I checked:

- **OWASP Top 10 for LLM Applications 2025.** Prompt Injection is LLM01 and Sensitive Information Disclosure is LLM02, as the essay says. LLM08, [Vector and Embedding Weaknesses](https://genai.owasp.org/llmrisk/llm082025-vector-and-embedding-weaknesses/), is the one that matches this post: it lists "Unauthorized Access & Data Leakage" and cross-context leaks in shared vector databases, and recommends "permission-aware vector and embedding stores" plus "detailed immutable logs of retrieval activities".
- **NIST AI 600-1** (July 2024), the Generative AI Profile of the AI RMF, which is for voluntary use. It defines the Data Privacy risk as leakage and unauthorized disclosure of sensitive data, lists grounding and retrieval-augmented generation among the data-source factors to consider (MP-1.1-001), and suggests testing data and content flows inside the system (MP-2.1-002). It does not tell you where to put an access check. See the [profile](https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf).
- **EU AI Act** (Regulation (EU) 2024/1689). It regulates AI systems by intended use and risk tier, and general-purpose models separately, so it is not model-only. For high-risk systems, [Article 10](https://artificialintelligenceact.eu/article/10/) covers data governance and [Article 15](https://artificialintelligenceact.eu/article/15/) covers robustness and cybersecurity, including resilience against unauthorized third parties altering a system's use or outputs. The Digital Omnibus on AI, Regulation (EU) 2026/1744, moved the high-risk dates to 2 December 2027 for the Annex III list and 2 August 2028 for Annex I products ([Parliament's legislative train](https://www.europarl.europa.eu/legislative-train/package-digital-package/file-digital-omnibus-on-ai)). I read Articles 10 and 15 and the timeline, not the whole Act, and I did not find a requirement that names retrieval-time access checks.

So the essay is right that nothing binding tells you to build the recheck. It is wrong, or at least loose, that the law only looks at the model. The gap is specificity, not scope.

## What did I not test?

- **A real corpus.** Everything is synthetic, with one embedding model and exact search. Approximate indexes add their own recall noise on top of this.
- **A networked source of truth.** The recheck's cost against a real identity provider or document store is unmeasured.
- **Row-level features of any specific vector database.** The Azure AI Search pattern is cited from its documentation, not run.
- **Commercial gateway features.** Only open source agentgateway 1.7.0 ran, and only tool-level rules.
- **Prompt injection through retrieved text.** Different problem, covered in [MCP tool-call guardrails](/tool-call-guardrails/) and the [MCP tool poisoning post](/mcp-tool-poisoning-pin-definitions/).

## Run it yourself

The lab is under [`/lab/rag-authz/`](/lab/rag-authz/README.md): the corpus generator, the evaluation, the ten-draw drift script, the gateway config, the MCP server, the token minter, and the captured output, including [`evidence/eval_output.txt`](/lab/rag-authz/evidence/eval_output.txt) and [`evidence/probe2_output.txt`](/lab/rag-authz/evidence/probe2_output.txt). The gateway runs were on 2026-11-17 against the open source binary, version 1.7.0, git revision `26f5aebe99a36a037fe54f8080a608aca5547e15`.

```bash
python corpus.py && python rag_eval.py && python drift_seeds.py
```

If your numbers differ from mine on your own data, that is the interesting part. Send me the shape of the difference.

## Sources

- Karthik Chandrasekaran, ["The Governance Layer Nobody Regulates"](https://newsletter.aicollective.com/p/governance-layer-nobody-regulates-the-byte), The AI Collective Newsletter, 17 November 2026 (premise only).
- OWASP GenAI Security Project, [LLM Top 10 for 2025](https://genai.owasp.org/llm-top-10/) and [LLM08:2025](https://genai.owasp.org/llmrisk/llm082025-vector-and-embedding-weaknesses/).
- NIST, [AI 600-1, Generative AI Profile](https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf), July 2024.
- European Union, AI Act [Article 10](https://artificialintelligenceact.eu/article/10/) and [Article 15](https://artificialintelligenceact.eu/article/15/); European Parliament, [Digital Omnibus on AI](https://www.europarl.europa.eu/legislative-train/package-digital-package/file-digital-omnibus-on-ai).
- Microsoft Learn, [Security filter pattern for Azure AI Search](https://learn.microsoft.com/en-us/azure/search/search-security-trimming-for-azure-search).
- agentgateway docs, [MCP authorization](https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/mcp-authz.md) and [MCP authentication](https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/mcp-authn.md).
- IETF, [RFC 7519, JSON Web Token](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4).

