BlackNesherAgentic AI Security Assessment
← All articles

RAG Poisoning: How Retrieval-Augmented Generation Gets Exploited

Retrieval-augmented generation — giving an LLM access to a curated set of documents it can search and pull context from at query time, rather than relying purely on what it learned during training — has become the default architecture for enterprise AI applications that need current, proprietary, or domain-specific knowledge. It's a genuinely effective technique for reducing hallucination and grounding responses in real, verifiable source material. It also introduces a new, often under-scrutinized attack surface: the retrieval pipeline itself, and the vector store or document index it draws from, both of which sit upstream of the model's actual reasoning and can be manipulated by anyone who can get content into that index.

The core mechanism: poisoning the source, not the model

RAG poisoning doesn't require any access to the model itself, and it doesn't require the sophisticated optimization techniques something like a GCG attack needs. It requires getting adversarial content into whatever document store the RAG pipeline retrieves from — a wiki page, a support ticket archive, an uploaded PDF, a shared drive, a public webpage the system indexes — such that when a legitimate, unrelated user query triggers retrieval of that poisoned document, the injected content gets pulled into the model's context and treated as trusted, ground-truth information rather than the untrusted external content it actually is.

This is a specific, high-impact instance of indirect prompt injection, but it's worth treating as its own category because RAG architectures create a uniquely favorable environment for the attack: the retrieved content is, by design, meant to be trusted and incorporated into the model's response, which is the entire point of building a RAG system in the first place. The system's own core design goal — treat retrieved documents as authoritative — is exactly the property an attacker exploits.

Who can actually poison the index

The realistic threat model varies enormously depending on how the document store is populated and secured, and this variance is one of the most important things to establish early in any RAG security assessment. A fully closed system where only vetted internal staff can add documents to the index has a much narrower poisoning surface than a system that ingests content from public or semi-public sources — customer support tickets submitted by anyone, public web pages crawled automatically, documents uploaded by external partners, or a knowledge base with loose internal contribution permissions.

The most exposed configurations are systems that automatically ingest user-generated or externally sourced content into the retrieval index with no review step. A support system that indexes past customer tickets to help answer future questions, for example, creates a direct pathway: an attacker submits a ticket containing carefully crafted injected instructions, and if that ticket later gets retrieved as "relevant context" for a different customer's unrelated query, the injected instructions ride along into that customer's interaction with the AI system, fully invisible to the second customer and often to the support team as well.

What a successful RAG poisoning attack can actually achieve

Once poisoned content is retrieved and incorporated into the model's context, the consequences track closely with what any indirect prompt injection can achieve, but with an added dimension of false authority — content retrieved from what's supposed to be a trusted internal knowledge base carries more implicit weight, both to the model and often to the end user reading the response, than an obviously external or unverified source would. Documented and plausible impacts include the model asserting false information as if it were verified fact from the knowledge base, the model being redirected to recommend a competitor's product or a fraudulent link injected into a poisoned document, and — for RAG-backed agents with tool access — the poisoned context containing hidden instructions that get the agent to invoke tools or take actions the legitimate user never requested.

There's also a reputational dimension specific to this attack that's easy to underweight: because RAG systems are frequently marketed and understood internally as more trustworthy and less hallucination-prone than a raw model, a poisoning attack that succeeds tends to produce output that's taken more seriously and acted on with less skepticism than an obviously hallucinated response would be, precisely because it's coming from what everyone involved believes is a verified, grounded source.

Embedding-level attacks: a subtler variant

Beyond directly poisoning document content, a more subtle attack targets the retrieval mechanism itself rather than the content that gets retrieved. Because RAG systems retrieve documents based on embedding similarity — finding stored content whose vector representation is mathematically close to the query's vector representation — an attacker with an understanding of the embedding model in use can craft content specifically engineered to score as highly relevant to a broad range of queries, regardless of whether it's actually relevant, effectively gaming the retrieval ranking to ensure poisoned content gets surfaced far more often than a legitimate document with genuinely relevant but less specifically-crafted content would.

This is a more technically sophisticated variant than simply writing a plausible-looking poisoned document and hoping it gets retrieved for the right queries, and it's a good illustration of why RAG security can't be reduced purely to "review what gets added to the knowledge base" — the retrieval ranking mechanism itself is part of the attack surface, not just the content being ranked.

Multi-tenant access control failures: a distinct but related risk

A separate but closely related category of RAG-specific risk involves access control failures rather than content poisoning: a multi-tenant RAG application — one serving multiple customers or business units from a shared underlying infrastructure — that doesn't properly scope which documents a given user's queries are allowed to retrieve from can leak one tenant's private data into another tenant's responses, entirely without any malicious poisoning at all. This isn't technically a poisoning attack, but it belongs in the same conversation because it stems from the identical root cause: RAG pipelines often receive far less rigorous access-control scrutiny than the application layer around them, because the vector store is frequently treated as an internal implementation detail rather than a security-relevant data boundary that needs the same access controls as a direct database query would.

Why this attack surface gets less scrutiny than it deserves

RAG is frequently bolted onto an existing LLM application specifically to reduce hallucination and add proprietary knowledge — often treated by engineering teams as a data and relevance problem rather than a security problem, evaluated on retrieval accuracy and answer quality rather than on adversarial resistance. The vector database itself is often a newer, less mature piece of infrastructure than the rest of the application stack, with less established security tooling and fewer battle-tested best practices than, say, a traditional relational database has accumulated over decades of scrutiny. The combination — a genuinely new attack surface, treated as a data-quality concern rather than a security concern, sitting on immature infrastructure — is exactly the profile that tends to produce under-tested, exploitable systems in production.

What real testing for this looks like

A thorough RAG security assessment needs to test the full pipeline, not just the model's behavior in isolation. That means attempting to actually inject content into the retrieval index through every available ingestion pathway (document uploads, ticket submissions, any user-generated content that gets indexed), verifying whether injected content that contains adversarial instructions actually gets retrieved and incorporated into responses to unrelated queries, and — for multi-tenant systems — specifically testing whether access controls on retrieval are actually enforced or merely assumed to be enforced by the application logic surrounding the vector store.

It also means testing the downstream consequences specifically, not just whether poisoning is theoretically possible: does injected content in a retrieved document actually change the agent's behavior, redirect its recommendations, or — for agentic systems with tool access — get treated as an instruction the agent should act on? A finding that poisoned content can be retrieved but produces no meaningful behavioral change is a real but lower-severity issue than one where poisoned retrieval reliably redirects the agent's actions.

Mitigations that actually address the root cause

Effective defense against RAG poisoning mirrors the general principle for indirect prompt injection: treat retrieved content as untrusted input, not as verified ground truth, regardless of how much the system's own design treats it as authoritative. Practically, this means content moderation and review on what gets ingested into the index, especially for any pathway that accepts external or user-generated content without human review; access controls on retrieval that are actually tested and enforced, not just assumed; and — at the model interaction layer — structuring prompts so retrieved content is clearly delineated as reference material to evaluate critically rather than instructions to follow directly, reducing (though not eliminating) the chance that injected instructions hidden in a retrieved document get executed as if they came from the legitimate system prompt.

Provenance tracking as an underused mitigation

One mitigation that's less commonly discussed but genuinely effective is maintaining clear provenance metadata for every document in the retrieval index — who or what added it, when, through which ingestion pathway, and whether it's been through any review process — and surfacing that provenance information to the model itself as part of the retrieved context, not just keeping it in an internal admin log nobody consults during normal operation. A model that knows a given piece of retrieved context came from an unreviewed, externally-submitted support ticket rather than a vetted internal knowledge base article has at least the possibility of weighting that content's trustworthiness accordingly, the same way a careful human researcher would treat an anonymous online claim differently than a peer-reviewed source.

This isn't a complete solution on its own — a sufficiently capable model can still be manipulated regardless of provenance labeling, and the labeling itself needs to be tamper-resistant against an attacker who might try to spoof a higher-trust provenance tag. But combined with the other mitigations covered here, provenance-aware retrieval meaningfully raises the bar compared to a system that treats every retrieved chunk as equally authoritative regardless of where it actually came from.

The specific danger of automated, unreviewed ingestion pipelines

It's worth calling out one design pattern as a particularly high-risk configuration, because it's also an increasingly common one: fully automated pipelines that continuously ingest new content into a RAG index with zero human review at any stage — automatically indexing every new support ticket, every new document uploaded to a shared drive, every page from a periodic website crawl, the moment it appears. These pipelines are attractive precisely because they keep the knowledge base current with minimal operational overhead, but that same automation removes the single most effective natural checkpoint against poisoning: a human noticing that a piece of content looks off before it gets treated as trusted context for future queries.

Organizations running this kind of fully automated ingestion should treat it as a materially higher-risk configuration than a curated, reviewed pipeline, and should compensate with correspondingly stronger automated screening — content classification models specifically trained to flag suspicious or anomalous submissions, rate limiting on how much content any single source can contribute in a given window, and regular sampling-based audits of what's actually made it into the index, rather than assuming the ingestion pipeline's convenience comes with no corresponding security cost.

How RAG poisoning compounds with agentic tool access

The severity of RAG poisoning scales sharply for any system where the RAG-backed model isn't just generating a text response but is also an agent with tool access, because in that configuration, poisoned retrieved content isn't limited to influencing what the model says — it can influence what the agent does. A poisoned document retrieved as "relevant context" for an otherwise ordinary query can contain instructions that get the agent to invoke a tool, and because the poisoned instruction arrived disguised as trusted retrieved content rather than as an obviously external user message, it may receive less scrutiny from whatever injection defenses the system has in place for direct user input.

This is a direct, specific instance of the broader pattern covered in this series where multiple technique categories compound: RAG poisoning as the delivery mechanism, tool-use exploitation as the ultimate impact. An assessment that tests RAG poisoning purely for its effect on text output, without also testing whether poisoned retrieval can reach and influence an agent's tool-calling behavior, is measuring only part of the actual risk for any RAG-backed agentic system.

Vector database security as its own emerging discipline

The vector databases that power modern RAG systems — specialized infrastructure for storing and efficiently searching embedding representations — are still a relatively young category of database technology, and their security tooling and best practices lag noticeably behind the decades of accumulated hardening that traditional relational and document databases have benefited from. Basic protections that are simply assumed and automatically enforced in a mature relational database deployment — row-level access control, comprehensive audit logging of every read and write, encryption of data at rest with proper key management — are inconsistently implemented across the vector database ecosystem, and it's genuinely common to find production RAG deployments where the vector store has received far less security configuration attention than the primary application database sitting right next to it.

This gap is closing as the technology matures and as more security-conscious organizations adopt RAG at scale, but it hasn't closed yet, and any organization running a RAG pipeline in production should treat their vector database with the same security rigor they'd apply to any other data store holding sensitive information — proper access controls, audit logging, encryption, and regular security review — rather than assuming that because it's a newer, more specialized piece of infrastructure, it's somehow exempt from the baseline data security practices that apply to every other system holding data an organization cares about protecting.

Part of the reason this gap persists is organizational rather than purely technical: vector databases are frequently owned and configured by data science or machine learning engineering teams focused on retrieval quality and relevance metrics, rather than by the security or platform engineering teams who would normally own data-store hardening for other systems. Closing this gap often requires an explicit organizational decision to bring the vector store under the same security ownership and review process as every other production data store, rather than letting it remain an unowned security gap between two teams who each assume the other is handling it.

Summary: what a defensible RAG security posture actually requires

Pulling this together into a practical checklist: know and control every pathway by which content enters the retrieval index, apply human review or automated screening to any pathway that accepts external or user-generated content, enforce and actually test access controls on multi-tenant retrieval, maintain provenance metadata and surface it to the model where feasible, treat the vector database with the same security rigor as any other production data store, and test the full pipeline end-to-end rather than assuming that testing the model's behavior in isolation covers the retrieval layer sitting in front of it. None of these individually eliminates the risk entirely, but together they represent the difference between a RAG system that was built purely for retrieval quality and one that was built with an accurate understanding of the trust boundary it actually introduces.

As RAG adoption keeps growing across nearly every category of enterprise AI application, the organizations that treat their retrieval pipeline as a first-class part of their security perimeter from the outset — rather than retrofitting these controls after a poisoning incident or a failed audit — are the ones that get to keep the genuine hallucination-reduction benefits of RAG without absorbing the attack surface it quietly introduces alongside them.

Want to know whether your own agent holds up against techniques like these?

Run a Free Mini Assessment