Adversarial Techniques Against RAG Systems in Enterprise AI
Each RAG pipeline stage has its own attack class, and fixes don't transfer.

Retrieval-Augmented Generation has become standard infrastructure for enterprise AI: it wires large language models into corporate knowledge repositories and customer support systems through vector similarity search. That wiring is now production-critical, not a lab experiment. Every flaw in it carries operational weight. The embedding space that makes RAG useful, the thing that lets a model find a relevant paragraph among millions, is itself a surface that most security teams have not yet learned to watch. If you add tool-use to the mix (web browsing, code execution, API calls), a successful attack on retrieval no longer just produces wrong answers; it produces wrong actions against live systems. Building a real defense starts with knowing exactly where each attack class lives in the pipeline, which is the work the rest of this piece does.
Adversarial Entry Points in the RAG Pipeline
RAG is four distinct components strung together, and an attacker who has figured out how to beat one of them has learned nothing about beating the others.
The first stage is knowledge base ingestion, where documents arrive from Confluence pages, partner APIs, email attachments, and public documentation sites, often with no security check applied before the content is trusted. The second is the embedding and vector index, where that content gets converted into high-dimensional vectors and stored for lookup. Both the embedding model and the index structure can be manipulated here. The third stage is retrieval itself: a top-k nearest-neighbor search decides which documents make it into the model's context window, and the ranking logic behind that search is a target in its own right. The fourth is generation, where the LLM receives a concatenated block of retrieved chunks plus the user's query, and anything hiding in that block, instructions included, can bend the output.
Keep that four-stage map in view. Every attack class discussed below names its stage, and the point of laying out the architecture first is that a fix built for one stage will not touch the others.
Adversarial hubness: engineering a "gravity well" in the vector index
In high-dimensional vector spaces, certain points become hubs: disproportionately popular nearest neighbors that recur across a wide range of unrelated queries. That is a known geometric property of the space itself, and it can be engineered on purpose. An attacker who understands the embedding model can craft a single document positioned to act as a gravity well, pulling in query after query regardless of topic, and the result is a kind of zero-click poisoning where no user ever has to open a malicious link for the damage to start. Cisco's research found that one crafted hub could dominate the top result for more than 84% of test queries.
The incidents on record are not hypothetical. The GeminiJack attack used a single shared Google Doc, calendar invite, or email with hidden instructions to get Google's Gemini to exfiltrate private emails and documents. Researchers demonstrated that one poisoned document reliably misled a production Microsoft 365 Copilot deployment into stating false facts with confidence. A separate line of research, dubbed the Promptware Kill Chain, used adversarial hubs as the entry point for AI-native malware, moving from initial access through data exfiltration to persistence, the same progression security teams recognize from conventional intrusion chains.
Standard similarity normalization does not catch this, because an adaptive adversary can confine the attack to one semantic domain, financial advice, say, and so stay under detection thresholds tuned to the index as a whole. Cisco's Adversarial Hubness Detector was built around that gap, using four signals in combination: hubness detection based on median and MAD z-scores rather than mean-and-variance scoring (which stops working once the index is already compromised), cluster spread analysis using normalized Shannon entropy to flag documents that surface across suspiciously diverse query clusters, stability testing to catch hubs that stay glued to query vectors under perturbation when legitimate documents would drift, and domain- and modality-aware scoring that catches threats hiding inside one category and multimodal attacks exploiting the seam between text and image embeddings. The tool works across FAISS, Pinecone, Qdrant, and Weaviate, and handles hybrid search and custom reranking setups, which matters because most enterprise deployments are not running a single vanilla vector store. Defending against adversarial hubness takes active scanning. A vector index left to run on passive trust in its own contents is exactly the condition the 84% figure describes.
If adaptive adversaries can confine an attack to a narrow semantic slice to dodge global thresholds, real-time anomaly detection paired with access policies tied to identity and role, built into the retrieval layer rather than added after the fact, is what stops them. That is the kind of capability an enterprise AI control plane like Speakeasy is built to provide, letting security teams restrict which users or systems can even trigger retrieval from an index that may already be compromised.
RAG poisoning through the knowledge base ingestion pipeline
Adversarial hubness manipulates the geometry of the embedding space. RAG poisoning is a different animal: it targets the knowledge base directly, corrupting what gets ingested so the model retrieves and repeats attacker-written content with the same confidence it would give real internal documentation.
The opening is trust itself. Shared Confluence pages, public documentation sites, partner API feeds, and email attachments processed automatically by indexing bots all accept content before anyone checks it, and every one of them is a door for an attacker who has no direct access to the vector store. Academic work has shown how little effort this takes. PoisonedRAG, the first documented knowledge-corruption attack against RAG systems, hit a 90% attack success rate by injecting a handful of malicious texts per target question. HijackRAG pushed the number down further: it showed that a single poisoned document is enough to hijack responses to a targeted query. A newer framework called ReGENT uses reinforcement learning to generate perturbations to existing documents that are imperceptible to a human reader, engineered to satisfy three conditions at once: the altered document is in the top-k retrieved set, it shapes what the model generates, and it reads naturally enough to slip past both content filters and anyone skimming the corpus for anomalies. None of this plays out in a sealed lab. Enterprise ingestion pipelines pull documents from semi-trusted external sources on a schedule, automatically, at volume, and that is exactly the condition these attacks are built to exploit.
Securing the knowledge base means treating ingestion as an access control problem, not a content filter problem. Documents coming in from Confluence, partner APIs, and email need to be authenticated and tagged with provenance before they ever get indexed. If a platform governs how outside systems and data sources connect into an AI stack, enforcing identity and policy right at the ingestion boundary, it keeps unauthorized sources from ever contributing to the knowledge base at all, so it closes off one of the earliest points of entry before poisoning becomes a retrieval-stage problem.
Indirect prompt injection through retrieved content
Prompt injection in a RAG system does not start with what the user types. It starts with any document sitting in the vector database, because an attacker who can insert or edit even one of those documents can bury instructions inside it that will later get retrieved, chunked, and dropped straight into the model's context window alongside the real query.
Agentic RAG makes this worse because the model has no built-in way to tell retrieved content apart from its own system instructions. Both arrive as text in the same context block, so an injected line can override behavioral limits, leak the system prompt, twist the output, or trigger a tool call the user never asked for, and none of it requires the user to do anything but ask an ordinary question. Payloads do not stay in plain text either. Variants use Unicode substitution, Base64 encoding, or instructions split across several retrieved documents and reassembled only once they are in context, so they can slip past filters built to catch obvious strings.
Once retrieved text and system instructions are concatenated into one block, the model has no native way to tell them apart, and prompt-level safeguards alone cannot fix that structural problem. Research on a policy-aware IoBT RAG framework found that a single injected rule produced 85% LLM context corruption at a very low poisoning rate, enough to corrupt the policy decisions the system was built to get right. That single number is the clearest argument for pushing controls upstream of generation rather than trusting the model to police its own context.
Out-of-domain queries as a retrieval-layer attack vector
Every attack so far has worked by planting something malicious in the corpus. There is a second way in that needs no poisoned document at all: the query itself. Dense retrieval is brittle once a query falls outside the domain the knowledge base was built for. The retriever still returns something, usually something weakly related, and the generator turns that thin material into a fluent, confident, wrong answer. That failure mode costs money and trust precisely because it does not look like a failure.
Researchers from NYU, the University of Pennsylvania, and Microsoft tested out-of-domain detection across 16 domains, including high-stakes COVID-19 and substance-use knowledge bases, and stress-tested it against both LLM-generated attacks and an in-the-wild 4chan attack dataset<sup>1</sup><sup>4</sup><sup>2</sup><sup>3</sup>. Out-of-domain queries mainly degrade the relevance of what the system produces, which is a different failure mode than the factual corruption caused by poisoning, and the two problems need different defenses. Standard safety guardrails are built to catch toxic or unsafe content, not domain irrelevance, so a query that is benign in tone but unanswerable in scope sails right through them.
LLM-based judges can flag out-of-domain queries, but running a second model call on every incoming question adds latency and API cost that make the approach impractical as an always-on gate. A lighter method applies PCA to the knowledge base's own embeddings and scores incoming queries in that compact subspace, which the research found competitive with LLM-based judges while running faster, cheaper, and in a way that is easier to audit.
Out-of-domain detection belongs in the security conversation, not just the quality one, because it functions as a gate on what the system is even allowed to attempt to answer. The research frames this as two separate axes that get conflated too often: KB answerability, whether the fixed knowledge base actually supports a grounded answer, and intent or policy risk, whether the request should be honored at all regardless of what the knowledge base contains. Treating those as one problem produces a defense that handles neither well. A system can be fully capable of answering a question and still be the wrong system to ask it of.
The authorization gap at retrieval time enables privilege escalation
The most dangerous structural property of RAG is a quiet one: retrieval usually runs without any check against the permissions of the person who asked the question. A document surfaced for one user's query might contain information that user has no business seeing, and the model includes it in the answer because the retrieval step never checks permissions.
Most RAG architectures were not built with this risk in view, and the common patch, telling the model in its prompt to withhold sensitive information, has been shown to fail against injection attacks that override exactly that kind of instruction. Agentic RAG compounds the problem: a successful injection can produce instruction override, system prompt leakage, manipulated output, or unauthorized tool calls, and in longer chains the identity of the original requester can simply disappear by the time one tool invokes another tool on its behalf. Call it the delegation-chain identity gap: permission checked once at the start of a chain is not the same as permission enforced at every step of it.
The SD-RAG framework, developed at the University of Pavia, tackles this by moving disclosure control out of the generation step. Sanitization and access checks run during retrieval, before any document gets concatenated into the model's context, rather than hoping the model polices itself after the fact. That design produced up to a 58% improvement in privacy score, and it held up well against prompt injection attempts. The enterprise implication follows directly: in regulated industries, where who is allowed to see what is a legal requirement, retrieval design and compliance design are the same design problem. Enforcing role-based access control at the retrieval layer, tied to an organization's existing identity provider, so documents outside a user's permission scope never make it into the context window in the first place, is precisely the gap a governed AI control plane is built to close, rather than leaving enforcement to a prompt-level instruction an attacker can talk the model out of.
What a defense-in-depth architecture covers across the RAG pipeline
No single tool closes the RAG attack surface, because the attack classes above target structurally different parts of the pipeline. A scanner built to catch adversarial hubs cannot tell you anything about injected instructions hiding in a legitimate-looking document. Prompt-level guardrails catch some injection variants but have no visibility into authorization failures happening at retrieval. Out-of-domain detection catches manipulated queries but has no way to see a poisoned corpus. Each defense covers its own stage and stops there. The fix has to match the four-stage map laid out earlier, one control per stage, not one control hoping to cover all four.
At ingestion, that means provenance tracking and integrity checks on every document entering the knowledge base, plus explicit policy on which sources the ingestion pipeline is willing to trust. At the vector index, it means active scanning for adversarial hubs using the same statistical signals described earlier (median and MAD z-scores, cluster entropy, stability testing, domain-aware scoring), replacing passive trust in the index with an ongoing check, a necessity given that a single crafted hub was able to dominate the top result for over 84% of test queries in the adversarial hubness research. At retrieval, you need to run KB-aligned out-of-domain detection as a standing gate before context gets assembled, combined with role-based access control enforced at the same layer, so documents outside a user's permission scope get filtered before the model ever sees them. At generation, apply sanitization and disclosure controls during retrieval instead of leaning on prompt instructions an attacker can override, and back that with real-time detection of injected content before it enters the context window.
Four stages, four distinct failure modes, four separate controls. Enterprise RAG was built on the assumption that retrieval is a plumbing problem. The research above says otherwise: it is an access control problem wearing plumbing's clothes, and the organizations that treat it that way are the ones whose RAG deployments will still be trustworthy once someone goes looking for the cracks.
Sources
- Your Model's Memory Has Been Compromised: Adversarial Hubness in RAG Systems - Cisco Blogs
- Knowing When Not to Answer: Lightweight KB-Aligned OOD Detection for Safe RAG
- Knowledge Base Poisoning Attacks and Defense for Policy-Aware LLM-RAG Framework
- The Silent Saboteur: Imperceptible Adversarial Attacks against Black-Box Retrieval-Augmented Generation Systems
- Securing Retrieval-Augmented Generation: A Taxonomy of Attacks, Defenses, and Future Directions


