Skip to main content
Enterprise AI Analysis: Addressing Corpus Knowledge Poisoning Attacks on RAG Using Sparse Attention

Enterprise AI Analysis

Addressing Corpus Knowledge Poisoning Attacks on RAG Using Sparse Attention

Authored By: Sagie Dekel, Moshe Tennenholtz, Oren Kurland

Retrieval Augmented Generation (RAG) is a highly effective paradigm for keeping LLM-based responses up-to-date and reducing the likelihood of hallucinations. Yet, RAG was recently shown to be quite vulnerable to corpus knowledge poisoning: an attacker injects misleading documents to the corpus to steer an LLM's output to an undesired response. We argue that the standard causal attention mechanism in LLMs enables harmful cross-document interactions, specifically in cases of attacks. Accordingly, we introduce a novel defense approach for RAG: Sparse Document Attention RAG (SDAG). This is a block-sparse attention mechanism that disallows cross-attention between retrieved documents. SDAG requires a minimal inference-time change to the attention mask; furthermore, no fine-tuning or additional architectural changes are needed. We present an empirical evaluation of LLM-based question answering (QA) with a variety of attack strategies on RAG. We show that our SDAG method substantially outperforms the standard causal attention mechanism in terms of attack success rate. We further demonstrate the clear merits of integrating SDAG with state-of-the-art RAG defense methods. Specifically, the integration results in performance that is statistically significantly better than the state-of-the-art.

Executive Impact & Strategic Implications

Key Findings for Enterprise Leaders

This research introduces Sparse Document Attention RAG (SDAG), a novel defense mechanism designed to robustly protect Retrieval Augmented Generation (RAG) systems from sophisticated knowledge poisoning attacks. By intelligently restricting cross-document attention, SDAG significantly enhances the reliability and trustworthiness of AI-generated content, crucial for maintaining data integrity in enterprise AI deployments.

Reduction in Attack Success Rate
Improvement in QA Accuracy
Fine-tuning Required

Deep Analysis & Enterprise Applications

Select a topic to dive deeper, then explore the specific findings from the research, rebuilt as interactive, enterprise-focused modules.

The Hidden Flaw in RAG: Causal Attention's Blind Spot

Traditional decoder-only LLMs in RAG pipelines utilize a causal attention mechanism. While effective for continuous text generation, this mechanism becomes a critical vulnerability in RAG when multiple retrieved documents are involved. Causal attention allows tokens in one retrieved document to attend to, and thus be influenced by, tokens from other retrieved documents. In an adversarial setting where conflicting information (benign vs. poisoned) exists, this cross-document attention can lead to the LLM being steered towards undesired outputs by malicious content, even from a single injected document. This research highlights this fundamental vulnerability as a key target for defense.

SDAG: A Block-Sparse Attention Defense Mechanism

User Query & Corpus
Retriever fetches Documents
SDAG Applies Block-Sparse Attention Mask
Tokens attend ONLY within Document Blocks
Generator Produces Answer

Sparse Document Attention RAG (SDAG) introduces a novel block-sparse attention mechanism that prevents tokens from different retrieved documents from attending to each other. This means cross-attention between distinct documents is explicitly disallowed. Crucially, SDAG is implemented as a minimal inference-time change to the attention mask, requiring no fine-tuning or architectural modifications. This makes it a practical and easily integrable defense against corpus knowledge poisoning attacks, preserving context within each document while isolating potentially malicious cross-document influence.

50%+ Reduction in Attack Success Rate (ASR) with SDAG

SDAG substantially reduces Attack Success Rate (ASR) by over 50% compared to standard Causal Attention RAG (CARG), particularly under 'Far' attack strategies (Table 2). This demonstrates its significant capability in mitigating the impact of knowledge poisoning.

SDAG's Superiority Against Adversarial Attacks

Defense Method Attack Type Key Advantage Impact (ACC / ASR)
SDAG (Proposed) Single & Multiple Adversarial Documents Eliminates cross-document attention; no fine-tuning required; easy integration. Statistically significantly higher ACC and lower ASR across various settings compared to CARG.
Causal Attention RAG (CARG) Single & Multiple Adversarial Documents Baseline RAG approach, full cross-document attention. Vulnerable to poisoning, leading to lower ACC and higher ASR.
RAGDefender (SOTA) Multiple Adversarial Documents Detects and filters adversarial documents post-retrieval. Outperformed by SDAG in single-document settings; SDAG-RAGDefender sets new SOTA for multiple-document attacks.
Discern&Answer (SOTA) Multiple Adversarial Documents Leverages LLM discrimination for reliable evidence. Outperformed by SDAG and SDAG-RAGDefender.

Empirical evaluation across various LLMs, retrievers, and datasets consistently shows SDAG outperforming the standard causal attention mechanism (CARG) in both accuracy and ASR. Notably, SDAG consistently outperforms state-of-the-art defense methods in single adversarial document settings. When integrated with existing SOTA defenses for multiple-document attacks (e.g., SDAG-RAGDefender), it establishes a new state-of-the-art, demonstrating its robust and complementary defensive capabilities.

Impact of Adversarial Document Positioning on Attack Effectiveness

Attack Strategy Adversarial Document Placement SDAG ASR (Llama-E5, NQ, k=5) CARG ASR (Llama-E5, NQ, k=5) SDAG ACC (Llama-E5, NQ, k=5) CARG ACC (Llama-E5, NQ, k=5)
Random Uniformly sampled from a pool. 0.17* 0.41 0.37 0.33
Near Closest to benign documents in embedding space. 0.23* 0.42 0.35 0.32
Far Farthest from benign documents in embedding space. 0.15* 0.39 0.38 0.34

The spatial positioning of adversarial documents significantly influences attack effectiveness. Adversarial documents that are geometrically closer to the centroid of benign documents in the embedding space ("Near" strategy) lead to more effective attacks than those that are geometrically distant ("Far" strategy). SDAG consistently achieves lower ASR and higher accuracy across all attack strategies, demonstrating its robustness irrespective of how the adversarial content is crafted or placed relative to benign documents. The "Far" strategy is generally less effective for attackers due to the increased distance, making it harder to influence the model.

Advanced ROI Calculator

Estimate the potential efficiency gains and cost savings for your enterprise by implementing robust AI defense mechanisms like SDAG.

Estimated Annual Savings
Total Hours Reclaimed Annually

Your AI Defense Implementation Roadmap

A phased approach to integrating advanced RAG defense mechanisms, ensuring a secure and efficient AI deployment.

Phase 1: Current State Assessment & Vulnerability Analysis

Evaluate existing RAG implementations for potential knowledge poisoning vulnerabilities. Identify key data sources and potential attack vectors. Define baseline metrics for ASR and ACC.

Phase 2: SDAG Integration & Pilot Deployment

Integrate SDAG by modifying the attention mask in your existing decoder-only LLMs. Conduct a pilot program with a subset of RAG applications and validate performance against defined security metrics.

Phase 3: Performance Validation & Optimization

Thoroughly test SDAG's effectiveness across various attack scenarios and data types. Optimize integration for specific enterprise needs, potentially combining with other state-of-the-art defense methods.

Phase 4: Full Enterprise Rollout & Continuous Monitoring

Deploy SDAG across all RAG-powered applications. Establish continuous monitoring protocols to detect new attack patterns and maintain robust defense, ensuring long-term data integrity and system reliability.

Ready to Secure Your Enterprise AI?

Don't let knowledge poisoning compromise your RAG systems. Speak with our experts to design a robust defense strategy tailored for your business.

Ready to Get Started?

Book Your Free Consultation.

Let's Discuss Your AI Strategy!

Lets Discuss Your Needs


AI Consultation Booking