Towards Whole-corpus Reconstruction of Heterogeneous RAG Knowledge Bases

Peiru Yang, Yi Luo, Zhenfeng Gao, Tong Ju, Haoran Zheng, Linjie Zhu, Hongke Fu, Qing Li, Shangguang Wang, Tao QiICML 2026

Introduction: The Privacy Risks of RAG Systems

Retrieval-Augmented Generation (RAG) has become the gold standard for granting Large Language Models (LLMs) access to private, proprietary, or up-to-date data. However, this architecture introduces a massive privacy surface: if an attacker can systematically query the system, they may be able to extract and reconstruct the entire underlying knowledge base.

Existing extraction attacks suffer from a major blind spot. They typically rely on local semantic similarity—finding a piece of data and iteratively querying for "similar" content. While effective for single-topic databases, real-world knowledge bases are inherently heterogeneous, containing diverse documents like medical records, legal contracts, and financial reports. These distinct domains form "semantic islands" separated by vast voids in the embedding space. Current attacks frequently get trapped on a single island (a local optimum) and fail to bridge the gap to discover the rest of the corpus.

The GeoEx Framework: A Geometric Approach to Extraction

To overcome the limitations of semantic similarity searches, researchers introduce GeoEx, a novel extraction framework that shifts the attack strategy from the discrete world of text to the continuous world of geometry. GeoEx navigates and reconstructs heterogeneous RAG knowledge bases without requiring prior knowledge of the target system's internal models.

The framework operates on three core pillars:

  1. Surrogate Embedding Space: Because the attacker does not know which specific embedding model the target RAG system uses, GeoEx employs a publicly available "surrogate" model (such as GTR-T5). This relies on the assumption that the "semantic topology"—the relative geometric relationship of concepts—is fundamentally similar across most modern embedding models.
  2. The Retrieve-Plan-Invert Loop:
  3. Retrieve: The attacker extracts an initial chunk of text from the RAG system.
  4. Plan: This text is mapped into the surrogate embedding space.
  5. Invert: GeoEx utilizes an embedding inversion module (based on BART) to translate a planned mathematical vector back into a natural language query that the target RAG system can execute.
  6. Composite Geometric Strategy: To ensure comprehensive coverage and avoid getting stuck, GeoEx utilizes two distinct movement modes in the latent space:
  7. Global Exploration (Orthogonal Jumps): Using a Gram-Schmidt process, the system calculates a vector that is mathematically orthogonal (90 degrees) to everything it has already discovered. This forces the search to leap across semantic gaps into entirely new domains.
  8. Local Densification: Once a new semantic island is discovered, the system applies small Gaussian perturbations (noise) to the vector. This "shakes out" related documents, allowing for dense extraction within that specific neighborhood.

Experimental Setup

To simulate a complex, real-world RAG environment, the researchers evaluated GeoEx using a custom-built heterogeneous corpus spanning eight diverse domains:

  • Bio: PubMedQA (Biomedical)
  • Finance: Bloomberg Financial News
  • Arxiv: Scientific literature
  • Law: LexGLUE (Legal)
  • Patent: BigPatent
  • Movie: IMDB reviews
  • Wiki: Wikipedia (General knowledge)
  • Science: ARC (Elementary science)

Key Findings and Results

GeoEx demonstrates that pure geometry—calculating orthogonal directions in latent space—is a far more reliable extraction method than traditional heuristic attacks that use LLMs to "guess" new topics.

  • Superior Coverage and Efficiency: GeoEx outperformed top-performing baselines (such as GAB and RAG-thief) by an average of 19.94% in extraction coverage. Furthermore, under a strict budget of 2,000 queries, GeoEx recovered significantly more unique data chunks than competitors, which typically plateaued early after getting trapped in a single domain.
  • Universal Semantic Topology: The attack remains highly effective even when the attacker's surrogate model is misaligned with the target's model. This suggests that current embedding models structure the world's information in a universally similar way.
  • The Query Length Sweet Spot: Researchers identified an inverted U-shape relationship between query length and extraction success. Queries of approximately 120 tokens were the most effective; shorter queries lacked necessary context, while longer queries introduced "semantic drift" that confused the retriever.
  • Robustness to Defenses: GeoEx maintained its efficacy even when the target system employed common defensive measures, including Reranking (via cross-encoders), Prompt Rewriting (using an LLM to sanitize queries), and Threshold Filtering (blocking low-similarity results).

Limitations and Future Directions

While highly efficient, reconstructing massive, multi-million document databases with GeoEx still requires a significant query budget, which could trigger rate-limiting or anomaly detection in production environments. Additionally, the attack assumes the target utilizes a standard embedding-based retriever; its performance against more exotic hybrid search systems or graph-based retrievers remains an open question.

Ultimately, the success of GeoEx highlights a critical vulnerability in modern RAG architectures. The authors suggest that future defensive research should focus on "geometric" defenses—such as intentionally warping the embedding space to disrupt the semantic topology, making it significantly harder for attackers to navigate using surrogate models.

Summary updated

BibTeX
@inproceedings{yang2026towards,
  author = {Peiru Yang and Yi Luo and Zhenfeng Gao and Tong Ju and Haoran Zheng and Linjie Zhu and Hongke Fu and Qing Li and Shangguang Wang and Tao Qi},
  title = {{Towards Whole-corpus Reconstruction of Heterogeneous RAG Knowledge Bases}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=x61zDYEZ91},
}
Figure