Why securing a RAG system doesn’t follow the same playbook as securing a traditional application
A RAG (Retrieval-Augmented Generation) architecture introduces risks that don’t exist in a traditional application: prompt injection through retrieved documents, information leakage between users or clients when the vector index doesn’t enforce permissions strictly, and sensitive data flowing out to third-party APIs on every embedding or inference call.
Deploying the system in a private or hybrid cloud environment, with real data isolation at the retrieval layer and components the organization can actually control and audit, reduces both risks at once: the security risk and the risk of dependency on a closed vendor.
A RAG system isn’t secure because the model can be trusted. It’s secure when it’s structurally impossible to retrieve a document the user doesn’t have permission for, no matter what happens in the prompt.
The pattern shows up in a lot of enterprise RAG pilots: the demo works perfectly with twenty test documents, all at the same confidentiality level. The problem appears when it scales to production, once the index holds thousands of documents pulled from different systems (Drive, Confluence, SharePoint, the HR intranet), each with its own permissions model, and someone on the support team stumbles onto the fact that the internal chatbot can answer questions about the executive committee’s compensation document.
A traditional application has a reasonably well-understood attack surface: the authentication layer, the authorization layer, and database queries. A RAG system adds new surface in three places:
A RAG architecture connects a language model to a proprietary knowledge base through a multi-stage process: ingesting and chunking documents, generating embeddings, storing them in a vector database, retrieving the most relevant chunks for a given query, and finally generating a response from the model based on those chunks.
Each stage is a potential risk point:
The most common and most dangerous design mistake is retrieving first and filtering afterward: the system searches the entire index for the chunks most similar to the query, and only then discards the ones the user shouldn’t see. This pattern fails for two reasons: it’s probabilistic in a system that needs deterministic guarantees, and it can also skew or thin out the relevant results, since the chunks discarded for permission reasons have already taken up space among the top matches.
The correct pattern reverses the order: first resolve the user’s identity and permission context, then restrict the vector search space to what that identity is allowed to see, and only then run the similarity search and reranking. The search never “sees” a chunk outside the authorized scope, instead of seeing it and discarding it afterward.
If your RAG system’s security depends on instructing the model to “only use documents from the right department,” you don’t have security: you have a polite request to a probabilistic system.
The embedding model, vector database, and inference model are all deployed inside the organization’s network perimeter, typically using self-hosted, open-weight models. This is the option with the most control and the smallest external exposure surface, suited to highly sensitive data or heavily regulated industries, in exchange for taking on the operational burden of the inference infrastructure.
The vector index and the data stay on the organization’s own infrastructure, while inference runs against a commercial model exposed through a private endpoint, inside a cloud provider’s VPC or virtual network, without going out over the public internet. This is a common middle ground: it keeps the data under control while still taking advantage of higher-performing commercial models.
When the prompt, the orchestration layer, and the embedding format all depend entirely on a single vendor’s proprietary conventions, migrating to another option later means rewriting a large part of the system, not just changing a configuration variable. This risk grows the more critical the use case is and the faster the commercial model market keeps evolving (and changing its pricing or terms).
These risks, particularly around prompt injection and weaknesses in embedding use, are covered more broadly in the OWASP Top 10 for LLM Applications, a useful checklist when designing or auditing any RAG system headed for production.
Is your RAG system relying on the prompt to respect permissions that should be enforced before the search even runs?
At Galde, we design RAG architectures with real data isolation, code control, and deployment in private or hybrid environments matched to each organization’s sensitivity level.
Through generative AI, we design and build RAG systems and agents with permission-aware retrieval from the initial design, avoiding the retrieve-then-filter pattern.
Through data platforms, we build the deployment infrastructure (private, hybrid, or in a dedicated VPC) and select the right open-source or self-hosted components to minimize vendor lock-in risk without sacrificing performance.
And through data governance, we make sure the RAG system’s permissions always stay in sync with the source systems, instead of living as an independent rules layer that drifts out of date over time.
Securing a RAG architecture isn’t about adding instructions to the prompt and hoping the model behaves: it’s about designing the system so it’s structurally impossible to retrieve what a user shouldn’t see, and deploying every component (embeddings, vector index, inference) in an environment whose level of control and sovereignty matches the actual sensitivity of the data. The alternative to closed commercial models isn’t always building everything from scratch: it’s understanding exactly what you’re giving up in exchange for the convenience of an API, and deciding that consciously instead of by default.
It can be, if you apply strict metadata filtering by tenant inside the search engine itself, before the similarity search runs, rather than as a filtering step afterward. For highly sensitive data, a physically separate index per client remains the safer option.
It’s the manipulation of a model’s behavior through hidden instructions embedded in a document that the system retrieves and adds to the prompt, without the user having written those instructions directly. It’s one of the risks covered by the OWASP framework for LLM applications.
Not necessarily. A commercial model exposed through a private endpoint inside a VPC can be a reasonable choice in a hybrid deployment. What matters is that the data and the index stay under the organization’s control and that vendor coupling is minimized across the rest of the architecture.
By syncing deletions and permission changes from the source system to the vector index through a continuous update process, so the corresponding embedding is deleted or marked as non-retrievable at the same moment the document stops being available or accessible at the source.
It lets you keep the most sensitive data and the vector index under the organization’s direct control, while still taking advantage of high-performing commercial models for generation, reducing both the risk of data leakage and total dependency on a single vendor.