STARA INSIGHTS · SEO
How to Connect AI to Internal Knowledge with Appropriate Access Controls
Design access to internal knowledge for AI: enforce permissions during retrieval, handle revocation, prompt injection and pre-production testing.
Connecting AI to internal knowledge requires access controls that apply when documents are retrieved, not just when they are indexed. Verify the user's identity, filter out unauthorized documents before they reach the model, and propagate permission changes to indexes and caches. This helps companies use documents as context without making the model the primary guardian of confidentiality.
StaraBridge is Stara Labs R&D exploring connections between LLMs, tools, APIs, MCP and databases. This article proposes an implementation design to evaluate; it does not claim that these features, integrations or test results already exist.
Why relevant search results are not necessarily safe
Retrieval-augmented generation (RAG) finds documents or document chunks and provides them to a model to compose an answer. Relevance asks whether text matches the question; authorization asks whether the user may read it. Each requires a separate check.
OWASP RAG Security recommends retaining document permissions when splitting content into chunks and enforcing them at retrieval. Asking a model to hide a document already present in its context is not an adequate access control.
Hypothetical illustration: a general procedure and a restricted budget plan both match an employee's question. If a shared index returns both without checking permissions, the model can receive the budget information even though the employee may not read it. This is not a StaraBridge incident or test result.
Design the access path from source to answer
1. Map identities and source policies
Identify the authenticated user, tenant, groups or other necessary attributes, and the owner of each source. Build a matrix of who may read each document, including exceptions and cross-team access. Do not accept identity or tenant solely from user-editable parameters; validate them through a trusted identity mechanism.
Keep documents without trustworthy permission information out of retrieval until their policy is clear. OWASP recommends denying by default and checking permissions on every request.
2. Preserve permissions during indexing
When processing documents into chunks and embeddings, retain the source-document relationship, tenant, version and necessary permission metadata on each chunk. Ensure content and permission updates do not change only the original while the index retains stale copies.
Keep metadata minimal, protect the index and limit service identities. Metadata does not enforce permissions by itself: retrieval must apply it. For example, Microsoft's document-level access control documentation describes security filters as one approach in that product. Verify feature availability and semantics for the chosen platform.
3. Enforce access before sending context
For each question, build filters server-side from verified identity. Apply the policy across every search path, including lexical, vector and hybrid retrieval and subsequent document fetches. Ensure unauthorized chunks do not reach an external reranker, model, log or user response. If a search engine has filtering or ranking limitations, test its specific behavior; filtering only after data has left the boundary is insufficient.
An unavailable authorization service, missing metadata or unverified synchronization should lead to denial or another safe path defined by business policy, not automatic broad access. This choice can reduce availability but limits exposure when permissions are uncertain.
4. Manage revocation, deletion and caches
Set a target for propagating permission changes and assign an owner. When access is revoked, invalidate related answer and retrieval caches; remove or update derived chunks and indexes according to policy. Consider checking permissions against the source at request time where synchronization delay is unacceptable.
A cache must account for identity or permission scope and policy version; a shared cache keyed only by the question can expose another user's answer. When a document is deleted or retention expires, handle derived copies and logs under applicable obligations. OWASP specifically highlights stale chunks and caches after source changes or deletion.
Treat document content as data, not instructions
Even an authorized document can contain malicious or accidental instructions that steer a model. OWASP's prompt injection guidance describes attacks through retrieved documents and notes that RAG does not fully eliminate this risk. Separate application instructions from source content, independently authorize tool actions and show relevant sources. These measures reduce risk but do not guarantee that injection is impossible.
For execution controls, see preventing unauthorized AI tool execution. Permission to read a document does not automatically authorize taking an action or sending its contents to another service.
Proposed pre-production test
Use synthetic documents with known permissions. Compare retrieval results and answers for authorized users, unauthorized users, users from another tenant and users whose access was just revoked. Test missing metadata, an unavailable policy service, a warm cache, group membership changes and orphaned chunks after deletion.
Inspect not only the final answer but also what reaches rerankers, models, logs and caches. Treat every unauthorized exposure as a critical failure; also measure authorized documents incorrectly denied, latency and permission propagation delay. Set acceptance thresholds and sample sizes appropriate to risk. Repeat tests after changes to connectors, indexes, policies or models.
This is a proposed method, not a completed test. Success on synthetic data does not prove all production scenarios safe; continue review and testing against the actual environment and policies.
Implementation checklist
- Map identities, tenants, sources and document-level access rules.
- Ensure every chunk retains the correct source reference and permission metadata.
- Enforce permission checks before content reaches downstream components.
- Design failure handling, permission synchronization, deletion and cache invalidation.
- Restrict log access and avoid retaining sensitive content without a legitimate need.
- Test cross-tenant access, revocation, caching, failures and prompt injection.
FAQ
Does a vector database automatically preserve source-document permissions?
Not always. Filter support and enforcement vary by product. Map, enforce, update and test permissions on the retrieval paths actually used.
Is an answer with citations necessarily safe and correct?
No. Citations aid traceability, but permissions, relevance, source versions and whether the answer matches the evidence still need checking.
What is the business benefit?
Teams may find relevant information faster while preserving designed access boundaries. Assess both value and risk through a pilot using approved data and policies.