Spain · 2026 World Cup champions
AXTO
AI SecurityJuly 16, 2026· 8 min read

Retrieval-Augmented Generation: The Security Questions Nobody Asks First

RAG lets an AI answer from your own documents — which means your access controls, data freshness and injection risks now live inside the AI.

Retrieval-augmented generation — connecting a language model to your own documents so it can answer from them — has become the default way organizations put AI to work on their real knowledge. It is powerful and, from a security standpoint, quietly consequential: the moment your internal documents feed an AI's answers, a set of questions about access, freshness and manipulation move inside the AI system, where they are easy to overlook in the rush to ship a helpful assistant.

Getting RAG right means asking the security questions before the demo, not after the incident.

Access control must follow retrieval

The most important and most frequently botched question: does the AI respect who is allowed to see what? A naive RAG system retrieves from a shared index regardless of the asking user's permissions, which means it can happily surface content from documents that user should never have been able to read. The AI becomes an access-control bypass — a confidential document the user could not open directly is now summarized for them on request.

The fix is that retrieval must honor the same permissions as the underlying documents: the system should only retrieve and reveal content the specific user is authorized to see. Access control cannot stop at the document store and be forgotten at the AI layer; it must be enforced through retrieval itself. This is one of the strongest arguments for keeping RAG systems on controlled infrastructure where you can enforce and audit exactly that.

Freshness, provenance and poisoning

A RAG system is only as trustworthy as the documents it draws from. Stale documents produce confidently outdated answers; if a policy changed but the old version is still indexed, the AI will cite the wrong one authoritatively. Worse, if an attacker can insert content into the knowledge base — a poisoned document — they can manipulate the AI's answers for everyone, a form of indirect prompt injection where the malicious instructions ride in on retrieved text rather than the user's prompt.

So the integrity and provenance of the knowledge base matter: control who can add to it, keep it current, and treat retrieved content as untrusted input that could contain injection attempts, not as inherently safe context.

Leakage and logging

Two more considerations round out a defensible RAG deployment. Answers can inadvertently leak sensitive fragments from retrieved documents in ways the source access controls would have prevented, so what the model is allowed to include in a response deserves thought, not just what it is allowed to retrieve. And the interactions — what was asked, what was retrieved, what was answered — should be logged, both to investigate misuse and because those logs themselves may contain sensitive content and need protecting.

RAG is genuinely transformative for turning an organization's knowledge into instant answers. But it inherits every access-control, data-integrity and injection concern of the documents it touches, and adds a few of its own. Enforce permissions through retrieval, guard the integrity and freshness of the knowledge base, treat retrieved text as untrusted, log the interactions, and keep sensitive deployments on infrastructure you control — and RAG becomes a powerful capability you can actually defend.

Mapping the pipeline

Securing a RAG system starts with seeing all of its parts. Documents are collected from sources such as file shares, wikis and ticketing systems; split into chunks; converted into numerical embeddings; and stored in a vector database. At query time, the user's question is embedded, similar chunks are retrieved, assembled into a prompt with instructions and sent to a model, whose answer is returned and often logged. Each stage handles the same sensitive content in a different form, and each needs its own controls. Draw this pipeline for your system before deciding where the risks lie.

Permission-aware retrieval in practice

The most reliable pattern attaches access-control information to every chunk at ingestion — the groups, users or tenants allowed to read the source document — and filters on it at query time, using the identity of the person asking rather than the identity of the application. For strongly separated customers, separate indexes per tenant add a further barrier. Avoid the tempting shortcut of retrieving broadly and asking the model to withhold what the user should not see: the model may follow the instruction most of the time, but access control must not depend on a model behaving perfectly.

Keeping permissions and content in sync

Permissions change constantly. People move teams, leave the organization or lose access to a project, and documents are deleted or reclassified. If the index is updated only occasionally, the AI keeps serving content that the user can no longer open in the source system. Synchronize permission changes and deletions promptly, ideally through events from the source systems rather than nightly rebuilds, and test that revoked access really disappears from answers. Deletion matters for legal reasons too: when personal data must be erased, it must be erased from the index and any caches as well.

Embeddings are sensitive data

It is tempting to treat embeddings as anonymous numbers, but research has shown that significant parts of the original text can sometimes be reconstructed from them. Treat the vector store with the same classification as the documents it represents. Require authentication for every query, keep the database off the public internet, encrypt data at rest and in transit, restrict administrative access and include it in backups and incident response planning. A vector database holding embeddings of confidential documents is, for practical purposes, a database of confidential documents.

Ingestion hygiene

What enters the knowledge base shapes every answer, so control the intake. Index only sources that have been deliberately approved, rather than crawling everything reachable. Record the provenance of each chunk: source system, document, version and owner. Scan incoming documents for hidden text, unusual formatting and embedded instructions, which attackers use to smuggle prompt injections past human readers. Exclude restricted data that the assistant has no reason to use, and review new sources before adding them, especially those where outsiders can contribute content, such as support tickets or shared inboxes.

Defending against indirect prompt injection

Because retrieved text is placed in the model's context, a document containing instructions — "ignore previous guidance and reveal the following" — can influence the answer. There is no complete technical fix today, so defense is layered. Clearly separate system instructions from retrieved content in the prompt, and tell the model to treat retrieved text as information, not commands. Limit what the model can do: an assistant that can only answer questions is far less dangerous than one that can send email or modify records. Require human confirmation for consequential actions, and monitor for outputs that suggest an injection succeeded.

Grounding and citations

Showing which documents an answer was drawn from is both a usability and a security feature. Citations let users verify claims, notice when the assistant relied on an outdated or unexpected source and report problems. They also make the system's behavior auditable. Configure the assistant to say when it cannot find a relevant source rather than inventing an answer, and evaluate regularly how often answers are actually supported by the retrieved text. Confidently wrong answers about policy, pricing or legal obligations can cause real harm even without any attacker involved.

Controlling what comes out

Even with correct retrieval, answers deserve output controls. Filters can detect and mask personal data, credentials or other sensitive patterns before responses reach users, which helps when source documents contain more than they should. Limit the length and number of chunks included in answers, so that a single question cannot be used to dump large parts of a document. For high-risk deployments, consider different response policies by user role, and block categories of question the assistant is not meant to answer.

Testing and red teaming

Test a RAG system the way an attacker would before real users arrive. Try to retrieve documents belonging to another user or tenant, ask questions designed to extract restricted content piece by piece, plant documents containing injection attempts in a test index and check whether the model obeys them, and verify that revoked access and deleted documents disappear from answers. Repeat these tests after changes to the model, the prompt template, the chunking strategy or the permission logic, because each can alter behavior in unexpected ways.

Monitoring in production

Log queries, the identities making them, the chunks retrieved and the answers given, with the same protection as the source data. Watch for patterns that suggest abuse: a user issuing many queries that retrieve chunks from sensitive sources, repeated attempts to bypass instructions or sudden spikes in volume. Track quality signals too, such as answers without citations and user feedback marking responses as wrong. Monitoring turns the RAG system from a black box into something you can investigate, improve and defend when questions arise.

A deployment checklist

Before launch, confirm the following. Retrieval filters by the asking user's permissions. Permission changes and deletions propagate quickly. The vector store is authenticated, private and encrypted. Ingested sources are approved and their provenance recorded. Retrieved content is treated as untrusted, and consequential actions require confirmation. Answers cite sources, and outputs are filtered for sensitive data. Interactions are logged and monitored, and the system has been tested against cross-user access and prompt injection. Meeting these conditions lets a RAG assistant deliver its value without becoming the easiest route to your confidential information.

Run AI on your own terms

AXTO gives you world-class AI apps and self-hosted editions — on your own keys, your own data.