EcoSafeRAG: Efficient Security through Context Analysis in Retrieval-Augmented Generation

Ruobing Yao, Yifei Zhang, Shuang Song, Neng Gao, Chenyang Tu
5/16/2025
cs.CLcs.AI

No confident code implementation found for this paper.

Abstract

Retrieval-Augmented Generation (RAG) compensates for the static knowledge limitations of Large Language Models (LLMs) by integrating external knowledge, producing responses with enhanced factual correctness and query-specific contextualization. However, it also introduces new attack surfaces such as corpus poisoning at the same time. Most of the existing defense methods rely on the internal knowledge of the model, which conflicts with the design concept of RAG. To bridge the gap, EcoSafeRAG uses sentence-level processing and bait-guided context diversity detection to identify malicious content by analyzing the context diversity of candidate documents without relying on LLM internal knowledge. Experiments show EcoSafeRAG delivers state-of-the-art security with plug-and-play deployment, simultaneously improving clean-scenario RAG performance while maintaining practical operational costs (relatively 1.2$\times$ latency, 48\%-80\% token reduction versus Vanilla RAG).

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yao2025ecosaferag,
  title  = {EcoSafeRAG: Efficient Security through Context Analysis in Retrieval-Augmented Generation},
  author = {Ruobing Yao and Yifei Zhang and Shuang Song and Neng Gao and Chenyang Tu},
  year   = {2025},
  eprint = {2505.13506},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.13506v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.13506.svg)](https://codeofpaper.com/paper/2505.13506)

Discussion