Every enterprise AI strategy in 2026 includes some variation of the same architecture: take a large language model, connect it to your internal knowledge base through a retrieval layer, and let employees ask questions about company data in natural language. This pattern has a name, Retrieval-Augmented Generation, and it has become the default approach for deploying LLMs in production. Gartner estimates that by 2026, more than 80% of enterprises will have deployed RAG-based applications in some capacity.

The problem is that almost nobody is talking about the security implications. While organizations rush to connect their most sensitive documents, codebases, customer records, and internal communications to LLMs through vector databases, the attack surface of these systems remains poorly understood, undertested, and largely undefended. The 2025 OWASP Top 10 for LLM Applications recognized this gap by introducing an entirely new entry: LLM08 - Vector and Embedding Weaknesses.

This article breaks down the attack surface of RAG systems and vector databases, the specific attack vectors that adversaries are exploiting today, and the defensive measures your organization needs to implement before connecting an LLM to your most valuable data.

What RAG Is and Why Enterprises Are Betting on It


Retrieval-Augmented Generation solves one of the fundamental limitations of large language models: they only know what they were trained on. An LLM trained on public internet data can answer general questions, but it knows nothing about your company's internal policies, your product documentation, your customer contracts, or your engineering runbooks. Fine-tuning the model on your data is expensive, slow, and creates its own security problems. RAG offers a different approach.

In a RAG architecture, your documents are first processed through an embedding model that converts text into high-dimensional numerical vectors, mathematical representations of the semantic meaning of each chunk of text. These vectors are stored in a vector database such as Pinecone, Weaviate, Chroma, Milvus, or Qdrant. When a user submits a query, the system converts that query into a vector, performs a similarity search against the database to find the most semantically relevant document chunks, and then passes those chunks as context to the LLM alongside the user's question. The LLM generates its answer based on the retrieved context rather than relying solely on its training data.

This architecture is powerful because it gives the LLM access to current, proprietary information without retraining. It reduces hallucinations because the model can cite actual documents. And it allows organizations to maintain control over their data, since the documents stay in their own infrastructure rather than being sent to a model provider for fine-tuning.

But every component of this pipeline, the document ingestion layer, the embedding model, the vector database, the retrieval mechanism, and the LLM itself, introduces security vulnerabilities that most organizations have not even begun to assess.

OWASP LLM08: Vector and Embedding Weaknesses


The 2025 update to the OWASP Top 10 for LLM Applications introduced LLM08: Vector and Embedding Weaknesses as an entirely new category. This was not a rename or a consolidation of previous entries. It reflects a recognition by the security community that the retrieval layer in AI systems represents a distinct and critical attack surface that had been overlooked in the 2023 version of the list.

LLM08 covers several categories of risk:

The inclusion of this category in the OWASP Top 10 signals that these are not theoretical risks. They are being observed in production systems and are expected to become more prevalent as RAG adoption accelerates.

Critical gap: Most organizations deploying RAG systems have completed zero security testing of their vector database layer. Standard penetration testing methodologies do not cover embedding manipulation, retrieval boundary testing, or cross-tenant vector isolation. This is a blind spot that adversaries are beginning to exploit.

Attack Vector: Poisoned Embeddings and Malicious Document Injection


The most accessible attack against a RAG system targets the document ingestion pipeline. If an attacker can introduce a malicious document into the knowledge base, they can influence every subsequent query that retrieves content from that document. The attack works because RAG systems are fundamentally designed to trust the content they retrieve, treating it as authoritative context for the LLM to reference.

Knowledge Base Poisoning

Consider a RAG system that ingests documents from a shared drive, a wiki, a ticketing system, or a customer support platform. If an attacker gains write access to any of these sources, whether through a compromised account, a supply chain attack, or simply because the ingestion source has weak access controls, they can plant documents that contain:

Embedding Manipulation

A more sophisticated attack targets the embeddings themselves rather than the source documents. Research has demonstrated that adversarial perturbations to embedding vectors can manipulate which documents are retrieved for a given query without modifying the underlying text content. An attacker with write access to the vector database can:

These attacks are particularly dangerous because they are invisible to anyone inspecting the source documents. The text looks normal. Only the numerical vector representation has been altered, and most organizations have no monitoring or integrity checking on their embedding stores.

Data Exfiltration Through RAG Queries


One of the most underappreciated risks of RAG systems is that they provide a natural language interface for querying your most sensitive data. If the retrieval mechanism does not enforce fine-grained access controls, an attacker, or even an authorized user exceeding their access scope, can extract information they should never see.

Semantic Search as Data Exfiltration

Traditional databases enforce access controls at the query layer. A user either has permission to run a SQL query against a table or they do not. Vector databases operate differently. A semantic similarity search does not check whether the requesting user has permission to view the documents that are semantically closest to their query. It simply returns the nearest vectors.

An attacker can craft queries designed to surface specific types of sensitive content:

The RAG system faithfully retrieves the most relevant documents and passes them to the LLM, which incorporates them into its response. The user receives a polished, natural language summary of documents they were never authorized to access. There is no SQL injection, no privilege escalation, no technical exploit. The system is working exactly as designed. The vulnerability is the design itself.

Cross-Tenant Data Leakage in Multi-Tenant RAG Systems


SaaS platforms that offer AI-powered features to multiple customers face a particularly acute version of this problem. When multiple tenants share a vector database, even with namespace or collection-level separation, the risk of cross-tenant data leakage is significant.

How Cross-Tenant Leakage Occurs

In a multi-tenant RAG deployment, each customer's documents are embedded and stored in the vector database, typically in separate namespaces or collections. The expectation is that Tenant A's queries will only retrieve Tenant A's documents. But several failure modes can break this isolation:

Real-world impact: In a multi-tenant RAG system serving a legal tech platform, a failure in namespace filtering during a vector database migration allowed queries from one law firm's users to retrieve privileged attorney-client communications belonging to another firm. The vulnerability existed for 11 days before detection. Incidents like this demonstrate that cross-tenant isolation in vector databases requires the same rigor as database-level tenant isolation in traditional SaaS architectures.

Vector Database Misconfigurations


Vector databases are a relatively new category of infrastructure, and the operational security practices around them lag far behind those for traditional databases like PostgreSQL or MySQL. Security teams know how to harden a relational database. Most have never audited a vector database.

Common Misconfigurations by Platform

Pinecone: API keys with overly broad permissions are the most common issue. Pinecone's access model is key-based, and many deployments use a single API key with full read-write access across all namespaces. If this key is leaked through client-side code, environment variables committed to version control, or a compromised CI/CD pipeline, the attacker gains unrestricted access to every embedding in the database. Pinecone's free tier does not support namespace-level access control, and many organizations that started on the free tier never implemented proper access controls when they upgraded.

Weaviate: Self-hosted Weaviate instances frequently run without authentication enabled. The default configuration does not require API keys, and the REST API is accessible to anyone who can reach the network endpoint. In containerized deployments, Weaviate's API port is often exposed through load balancers or ingress controllers without TLS termination, allowing embedding data to transit in cleartext.

Chroma: As the most popular vector database for prototyping and smaller deployments, Chroma is often deployed with its default in-memory or local persistence settings in environments that eventually grow into production use. The transition from development to production frequently happens without a security review, leaving instances with no authentication, no encryption, and no access logging.

Milvus: Milvus supports role-based access control, but it is disabled by default. Self-hosted Milvus deployments also require securing the underlying etcd and MinIO dependencies, which introduces additional attack surface that is often overlooked. Default credentials on these supporting services are a common finding in penetration tests.

Indirect Prompt Injection via Poisoned Retrieved Context


Indirect prompt injection is arguably the most dangerous attack vector against RAG systems because it weaponizes the core value proposition of RAG itself: the ability to augment LLM responses with retrieved context.

How the Attack Works

In a standard prompt injection attack, the user directly submits malicious instructions to the LLM. Most modern LLMs have guardrails against this. Indirect prompt injection is different. The malicious instructions are embedded in a document that gets ingested into the knowledge base. The attacker does not interact with the LLM at all. They simply plant the payload and wait.

When a legitimate user submits a query that triggers the retrieval of the poisoned document, the LLM receives the user's question alongside the malicious context. Because the LLM has no reliable mechanism to distinguish between trusted system instructions and untrusted retrieved content, the injected instructions can:

Why RAG Makes Prompt Injection Worse

RAG systems amplify the prompt injection threat compared to standalone LLMs for three reasons. First, the attack surface for injecting payloads is vastly larger. Instead of needing to interact directly with the LLM, an attacker can plant payloads in any document source that feeds the knowledge base: wikis, document repositories, email archives, support tickets, code comments, or even customer-submitted forms. Second, the injected content carries implicit trust because it was retrieved by the system as "relevant context," making the LLM more likely to follow its instructions. Third, the attack is persistent. Once a poisoned document is embedded in the vector database, it will continue to be retrieved and to influence responses until it is detected and removed.

Attack scenario: An attacker submits a support ticket containing hidden prompt injection instructions (using Unicode characters, whitespace encoding, or invisible text formatting). The ticket is automatically ingested into the RAG knowledge base. When a support agent later queries the AI assistant about similar issues, the poisoned ticket is retrieved, and the hidden instructions cause the LLM to include a link to a phishing page in its response to the agent.

Embedding Inversion: Recovering Data from Vectors


A persistent misconception about RAG systems is that converting documents into embeddings provides some level of data protection, that the original text cannot be recovered from the numerical vectors. This is false. Research published in 2023 and refined throughout 2024-2025 has demonstrated that text embeddings can be inverted to recover the original input with high fidelity.

The Vec2Text attack and subsequent improvements showed that given an embedding vector, an attacker can iteratively reconstruct the original text that produced it. The accuracy improves with access to the same embedding model used to generate the vectors, which is often a publicly available model like OpenAI's text-embedding-ada-002 or an open-source model from Hugging Face. For 32-token text sequences, inversion attacks can recover the original text with over 90% accuracy.

This has direct security implications for RAG deployments:

Testing Methodology for RAG Security


Security testing of RAG systems requires a methodology that addresses each component of the pipeline. Traditional application penetration testing does not cover these areas. Organizations need specialized assessments that include the following testing categories.

Document Injection Testing

Test the document ingestion pipeline by attempting to submit documents containing prompt injection payloads, factually manipulated content, and adversarial text designed to influence embedding placement. Verify that input validation, content scanning, and approval workflows prevent malicious documents from entering the knowledge base. Test with various encoding techniques (Unicode manipulation, whitespace injection, HTML/markdown formatting tricks) that might bypass content filters.

Access Control Validation

Systematically verify that the retrieval layer enforces access controls consistent with the source document permissions. Submit queries as users with different access levels and confirm that retrieved documents respect authorization boundaries. In multi-tenant systems, perform cross-tenant retrieval attempts using queries crafted to maximize semantic similarity with other tenants' content. Test for namespace filtering bypasses, caching-related leakage, and API-level access control gaps.

Embedding Manipulation Testing

If the testing scope includes write access to the vector database, test whether modifying embedding vectors can bias retrieval results. Verify that integrity checking mechanisms detect unauthorized modifications to stored embeddings. Test whether adversarial queries can exploit the geometry of the embedding space to retrieve documents outside the intended scope.

Retrieval Boundary Testing

Probe the boundaries of what the retrieval system will return. Test whether similarity thresholds are enforced (do queries with no relevant matches still return results?). Check whether the system properly handles edge cases like empty collections, deleted documents, or corrupted embeddings. Verify that metadata filters cannot be bypassed through API manipulation.

Output Validation Testing

Test whether the LLM properly handles potentially malicious content in retrieved documents. Submit queries that trigger retrieval of documents containing injection payloads and verify that the output does not include exfiltration attempts, unauthorized instructions, or manipulated content. Test the system's behavior when retrieved context contradicts the system prompt.

Defensive Measures for RAG Systems


Securing a RAG system requires defense in depth across every component of the pipeline. No single control is sufficient.

Input Sanitization for Document Ingestion

Every document entering the knowledge base should pass through a security pipeline before embedding:

Access Control at the Embedding Level

Implement access controls that travel with the embedding, not just at the application layer:

Monitoring Retrieval Patterns

Implement monitoring that can detect anomalous retrieval behavior:

Vector Database Hardening

Apply the same rigor to vector database security that you apply to any other production data store:


Secure Your AI Infrastructure Before Attackers Find the Gaps

Our AI security assessments cover the full RAG pipeline: document ingestion, embedding integrity, vector database hardening, retrieval access controls, and prompt injection resilience. Find the vulnerabilities before your adversaries do.

Book an AI Security Assessment View Security Packages
-- views
Link copied!
Lorikeet Security

Lorikeet Security Team

Penetration Testing & Cybersecurity Consulting

We've completed 170+ security engagements across web apps, APIs, cloud infrastructure, and AI-generated codebases. Everything we publish here comes from patterns we see in real client work.