Manuscript Offprint

arXiv:2610.21464

Poisoning the Neighborhood: A Topology-Aware Topic-Level Attack on Large-Scale HNSW-based RAG Systems

Yufei Chen, Yao Wang, Haibin Zhang

Yufei Chen

Xidian University

24151111267@stu.xidian.edu.cn

Yao Wang ∗^{*}

Xidian University

wangyao@xidian.edu.cn

Haibin Zhang

Xidian University

hbzhang@mail.xidian.edu.cn

Abstract—Retrieval-augmented generation (RAG) mitigates hallucinations and knowledge staleness in large language models using external knowledge. However, ingestion from public and third-party sources exposes RAG systems to poisoning attacks. Existing attacks are designed and evaluated under exact retrieval, where poisoned documents participate in global ranking. Deployment-scale systems instead rely on approximate nearest-neighbor (ANN) indexes such as hierarchical navigable small world (HNSW), where limited search budgets, graph-search reachability, and local benign-document competition invalidate this assumption and degrade existing attacks. We present a topology-aware topic-level poisoning attack against large-scale HNSW-RAG that generalizes to unseen topic queries. We organize poisoned documents into a Hub–Satellite structure: Satellites provide competitive entry points across semantic regions, while Hubs strengthen local cohesion and facilitate cascading retrieval. For generation, we propose an entity–claim promotion attack combining evidence anchoring and entity–claim coupling to promote the target entity via a target claim across different query regions. On 2M-document Wikipedia, our attack maintains over 72% retrieval success and reaches 31.29% attack success, substantially outperforming baselines; domain-specific experiments further support its effectiveness. Structural analyses show that the Hub–Satellite topology forms in HNSW, indicating that graph structure contributes to improved poisoned-document retrieval. Existing poisoning defenses cannot mitigate the attack, exposing graph-structural risks in HNSW-RAG systems.

1. Introduction

RAG [1] supplements large language models (LLMs) with dynamically updated external knowledge, helping mitigate hallucinations and knowledge staleness [2], [3], [4]. RAG has been adopted in systems such as Microsoft 365 Copilot [5], GitHub Copilot [6], and Amazon Bedrock [7]. However, maintaining knowledge freshness and coverage requires RAG systems to continually ingest content from the public web and third-party sources, creating a new attack surface. Adversaries may introduce poisoned documents during data collection or index updates. Once retrieved,

Figure

Figure 1. Overview and HNSW performance comparison of existing and proposed poisoning attacks.

these documents can steer model outputs toward attacker-specified content, undermining the trustworthiness of deployed RAG systems.

Most existing RAG poisoning attacks are designed and evaluated under exact retrieval and rely on an assumption: each query is compared with every document in the knowledge base, and the top-k results are selected according to a global ranking. Attackers therefore need only maximize the semantic similarity between target queries and poisoned documents to place them in the retrieval results. Accordingly, early methods optimize poisoned documents for a single query or a predefined query set [8], [9], [10], [11], [12]. Topic-FlipRAG [13] and DiscourseFlip [14] exploit semantic or structural features shared across topic-related queries to extend poisoning to the topic level. However, they still construct poisoned documents from attack-time topic queries and are primarily evaluated under exact retrieval. Thus, their attack construction remains dependent on known query sets and assumes that poisoned documents participate in global similarity ranking.

As RAG systems increasingly rely on larger and continuously updated knowledge bases [15], the global-ranking assumption becomes increasingly unrealistic. The cost of exhaustive similarity computation drives practical systems to adopt ANN indexes [16], such as HNSW [17]. Under HNSW, poisoning attacks face three challenges: (1) limited

∗^{*}Corresponding author: Yao Wang.

search budget: HNSW explores only a subset of graph nodes, so poisoned documents are no longer guaranteed to be visited and participate in candidate comparisons; (2) graph-search reachability: under a limited search budget, whether a poisoned document is visited further depends on the search paths from the entry node through the local adjacency structure; and (3) intensified local competition: as the knowledge base grows, more benign documents enter neighborhoods, competing for the search budget and occupying candidate-set slots.

These challenges are particularly consequential for topic-level poisoning. Unlike attacks optimized for a single known query, a topic-level attack must use a limited set of poisoned documents to cover queries with diverse semantic intents and formulations. Such broader coverage reduces each document's specificity and ranking advantage for individual queries, compounding the retrieval constraints imposed by HNSW. This raises a central question: can an attacker mount an effective topic-level poisoning attack against large-scale HNSW-RAG while generalizing to unseen topic queries?

To this end, we propose a topology-aware topic-level poisoning attack against HNSW-RAG. Our key insight is that HNSW graph connectivity is influenced by embedding-space proximity and heuristic neighbor selection, while retrieval proceeds through graph traversal under a limited search budget. This property allows attackers to indirectly induce favorable graph neighborhoods by coordinating the semantic relationships among injected documents, thereby improving their reachability during graph search. On the retrieval side, we organize independently competing poisoned documents into a role-differentiated Hub–Satellite structure. Satellites target distinct semantic regions, maintaining local ranking competitiveness and providing multiple retrieval entry points for diverse unseen queries. Hubs aggregate semantics shared across these regions, serving as common anchors that encourage local cohesion among dispersed Satellites. This semantics-induced, “multiple-entry, locally cohesive” structure enables set-level cooperation: once a search reaches one poisoned document, neighbor expansion may expose additional poisoned documents, improving reachability and retrieval stability under limited budgets.

On the generation side, we introduce entity–claim promotion for diverse unseen queries within the target topic. Advice-seeking, comparison, and applicability queries differ in form but share a common decision-oriented goal: evaluating whether or which solution to recommend. We therefore make all poisoned documents support the same target entity and a shared claim about its benefits across different decision contexts. Evidence anchoring presents the claim as a conclusion supported by background, mechanism, conditions, and outcome evidence, while entity–claim coupling ties the mechanism and outcome to the target entity, encouraging the model to preserve this association and recommend the entity in its response. Finally, two-level candidate optimization balances document-level retrieval and generation utility with set-level coverage complementarity and topological cooperation.

Experiments show that our method maintains stable attack performance across datasets and knowledge-base sizes, achieves an attack success rate of up to 31.29%, substantially outperforms existing baselines, and generalizes to diverse unseen topic queries. Structural analysis confirms that the Hub–Satellite cooperative structure forms in the target HNSW index and significantly improves poisoned-document retrieval. Defense experiments show that existing methods cannot effectively mitigate the attack, revealing practical security risks in large-scale HNSW-RAG systems.

Contributions. To the best of our knowledge, we present the first RAG poisoning attack designed for large-scale HNSW indexes and capable of generalizing to unseen topic queries. Our contributions are as follows:

(1) We characterize and empirically quantify the impact of HNSW search on existing RAG poisoning attacks. (2) We propose a topology-aware Hub–Satellite poisoning method that improves unseen-query coverage and HNSW graph-search reachability through distributed query access and semantically induced local cohesion.

(3) We introduce an entity–claim promotion mechanism that combines evidence anchoring with entity–claim coupling to manipulate diverse unseen topic queries.

(4) We extensively evaluate the attack across datasets, knowledge-base sizes, and system settings, validating its effectiveness and key design choices while showing that existing defenses remain insufficient against this threat.

References (52)