Manuscript Offprint

arXiv:2609.04767

Shadow Queries for Private Retrieval in Vector Databases

Xinguo Feng, Zhongkui Ma, Zihan Wang, Chuan Yan, Guowei Yang, Alsharif Abuadbba, Guangdong Bai

Xinguo Feng, Zhongkui Ma, Zihan Wang, Chuan Yan, Guowei Yang, Alsharif Abuadbbra, Guangdong Bai

Abstract—Large language models (LLMs) are increasingly embedded into modern applications, such as writing assistants, coding assistants, AI agents, and search engines. However, they often struggle to provide accurate domain-specific knowledge without costly re-training or fine-tuning. Systems built on information retrieval (IR), such as Retrieval-Augmented Generation (RAG), address this by combining dense retrievers with embedding models and cloud-based vector databases that store pre-computed embeddings in the cloud to integrate external knowledge at inference time at scale. Despite the technical advancements, these embeddings are vulnerable to embedding inversion attacks (EIAs), allowing adversaries to reconstruct the original text. While existing defenses attempt to mitigate this threat by modifying embeddings (e.g., adding noise or scaling), they often provide insufficient protection, either largely sacrificing utility or being easily bypassed.

In this work, we propose a novel semantic-decomposition and embedding-decoupling defense mechanism, SHAQ (shadow query generation), to mitigate EIAs in cloud-based vector databases. Unlike prior works, SHAQ introduces a shadow query generation pipeline that decouples the direct mapping between the stored embeddings and the original documents. SHAQ is built upon a key insight: EIAs fundamentally rely on the strong coupling between embeddings and their underlying textual content. SHAQ consists of two steps: a generation step and an indexing step. 1) In the generation step, a generative language model is employed to synthesize relevant shadow queries for each target document, which cover diverse aspects and semantic facets of the document content, achieving semantic decomposition. 2) In the indexing step, the generated shadow queries are encoded into embeddings, which then replace the original document embeddings in the vector database, achieving embedding decoupling. Evaluation across diverse IR datasets demonstrates the remarkable effectiveness of SHAQ in protecting privacy (as low as 0.2104 recovery rate, up to 19.50% more defended tokens than baseline defense) and preserving utility (up to 0.7967 in MAP@10, up to 5.53% improvement compared to baseline defense). SHAQ demonstrates a defense paradigm shift from modifying resulting embeddings to enabling semantic decomposition and embedding decoupling with shadow query generation to counteract EIAs.

Index Terms—Dense retrieval, embedding inversion attack, information retrieval, large language models, privacy-preserving retrieval, retrieval-augmented generation, vector database.

I. INTRODUCTION

Large language models (LLMs) [1], [43], [48], [44] are increasingly embedded into modern applications, such as writing assistants [10], coding assistants [31], [2], AI agents [37],

[32], and search engines [9], [22]. However, the underlying LLMs often struggle in delivering accurate and up-to-date knowledge in specialized domains without costly re-training or fine-tuning, given their vast parameter spaces. To address this limitation, solutions built on information retrieval (IR) [40], such as Retrieval-Augmented Generation (RAG), emerge as a powerful paradigm that integrates external knowledge sources into LLMs at inference time. By retrieving relevant information from domain-specific corpora, RAG enables LLMs to ground their responses in factual and domain-specific knowledge, significantly improving adaptability and reliability. The core of RAG is dense retrievers [14], [26], which leverage embedding models [5], [19] to encode both queries and documents into a shared vector space, allowing semantically similar texts to be effectively matched. To further support large-scale deployment, vector databases [11] have become standard infrastructure in RAG. By storing pre-computed embeddings of the documents, it enables efficient similarity search at retrieval time. In practice, commercial cloud-based solutions for vector databases, such as Pinecone [34] and Milvus [23], are often employed to host and serve the embeddings in the cloud, as they offer specialized optimizations, elastic scalability, and managed infrastructure.

Despite these technical advancements, a critical vulnerability remains: embeddings themselves may leak information on the encoded data. Recent studies [41], [24], [17] show that embeddings can be exploited through embedding inversion attacks (EIAs), which allow adversaries to reconstruct the original text from its embedding, posing a significant threat to data privacy in RAG. Such attacks are rooted in the strong semantic coupling between the embedding and its underlying text, which induces an invertible mapping from the embedding to the original text that EIAs can effectively exploit. An adversary who gains access to the stored embeddings (e.g., through data breaches or insider threats on the cloud-based data host) can recover private documents by leveraging the rich semantics encoded in the embeddings. As RAG increasingly relies on vector databases, the need to understand and mitigate the EIA risks grows even more urgent.

Several defense strategies are proposed for EIAs, including adding random noise [24], or applying a secret scaling factor [60], to the embeddings. However, these methods exhibit notable limitations. In the case of embedding noise, only minimal perturbations can be applied to the embeddings to preserve reasonable retrieval utility, struggling to achieve a utility-privacy balance. For secret scaling, it multiplies both query and document embeddings with a secret scalar known only to the user. Unfortunately, such scaling can be nullified

Xinguo Feng, Zhongkui Ma, Zihan Wang, and Guowei Yang are with The University of Queensland, Brisbane, Australia. E-mail: {s.feng, zhongkui.ma, zihan.wang, guowei.yang}@uq.edu.au.

Alsharif Abuadbbra is with CSIRO's Data 61, Sydney, Australia. E-mail: {Sharif.Abuadbbra}@data61.csiro.au.

Chuan Yan and Guangdong Bai are with City University of Hong Kong, Hong Kong. E-mail: {c.yan, g.bai}@cityu.edu.hk.

by simple vector normalization on the embeddings, causing the defense to have no effect in practice. These shortcomings reveal a fundamental tension between retrieval effectiveness preservation and privacy protection, highlighting the need for a robust and practical defense against EIAIs. This urgent need motivates our exploration for a novel defense mechanism that safeguards document privacy while balancing retrieval performance.

Our work. We propose a novel semantic-decomposition and embedding-decoupling defense mechanism, SHAQ (shadow query generation), to mitigate EIAIs in vector databases. Unlike previous methods that directly modify document embeddings to obscure encoded semantic information, SHAQ introduces a shadow query generation pipeline that breaks the direct mapping between embeddings and underlying documents. This design is motivated by a key insight: EIAIs fundamentally rely on the strong coupling between embeddings and their underlying texts. To disrupt this dependency, we leverage a generative language model to synthesize a set of shadow queries that cover diverse semantic facets of the original documents. These shadow queries are formulated from a user-query perspective, whose embeddings are then used to replace the document embeddings in the vector database. This substitution is effective in two ways: 1) By breaking down the overall semantics of the document into diverse facets, this enables a semantic decomposition. A successful retrieval is achieved if the user query is semantically close to one of the shadow queries. 2) By replacing the document embeddings with the shadow query embeddings that only capture semantic aspects of the document, it enables an embedding decoupling between the stored embeddings and the original documents. This significantly reduces the risk of document reconstruction while maintaining effective retrieval, as the stored embeddings no longer encode the entire document but only a semantic characteristic of it.

SHAQ operates in two stages: a generation step and an indexing step. 1) In the generation step, a generative language model is employed to synthesize relevant shadow queries for each target document. These shadow queries resemble plausible user queries that may retrieve the document, which cover diverse aspects and semantic facets of the document content. This is accomplished through a crafted prompt that guides the language model to explore different query perspectives, and a K-Means clustering algorithm to ensure diverse outputs. 2) In the indexing step, the generated shadow queries are encoded into embeddings, which then replace the document embeddings in the vector database. These embeddings are indexed into the vector database in randomized order, which can be mapped back to the corresponding documents during retrieval time. By combining the two steps, SHAQ ensures that the stored embeddings cover important semantic characteristics of the documents while disrupting their direct semantic links, thereby protecting document privacy against EIAIs while balancing retrieval effectiveness.

We comprehensively evaluate SHAQ from two perspectives: its defense effectiveness against EIAIs and its retrieval utility preservation. Experiments are conducted on widely used IR benchmark datasets spanning diverse domains. For defense evaluation, we assess the attack success rate using a state-of-the-art EIA method [24], considering both standard and adaptive adversarial scenarios. SHAQ consistently outperforms existing countermeasures, resulting in a recovery rate of 0.2710 on average and as low as 0.2104 measured in ROUGE-1, reducing the number of recovered tokens by 12.43% on average and up to 19.50% compared to prior defenses. Furthermore, in a challenging adaptive attack setting where the attacker has full knowledge of the defense mechanism and hyperparameters, SHAQ remains highly effective with a recovery rate of 0.3376 on average and as low as 0.2083 measured in ROUGE-1, demonstrating strong resilience to adaptive attack strategies. For utility evaluation, SHAQ achieves a remarkable balance between privacy and utility among all compared methods. It maintains retrieval performance on par with an undefended system, achieving an NDCG up to 0.8524. This confirms SHAQ's capability in defending against EIAIs while balancing retrieval performance. Ablation studies on variable-length documents and a different embedding model show that SHAQ is a generic and model-agnostic defense, which can be directly integrated into modern dense retrievers.

Contributions. Our contributions are summarized as follows:

  • A novel defense mechanism for vector databases privacy via semantic decomposition and embedding decoupling. We propose SHAQ, a novel framework that mitigates EIAIs in vector databases. Instead of modifying document embeddings, SHAQ replaces them with embeddings of shadow queries that cover diverse aspects and semantic facets of the documents. This shifts the defense paradigm from direct embedding perturbation to decoupling the inherent links between embeddings and documents.

  • A generic and model-agnostic approach. SHAQ adopts a two-stage pipeline, shadow query generation and indexing, which is easy to adopt and compatible with existing dense retriever architectures. It works seamlessly with variable-length documents and various embedding models, facilitating a one-time offline process that occurs before retrieval time.

  • An extensive empirical validation. We evaluate SHAQ on widely used IR benchmark datasets spanning diverse domains. Experiments show that SHAQ outperforms existing countermeasures on defense efficacy, while maintaining retrieval performance on par with undefended systems, achieving a strong privacy-utility balance. SHAQ remains effective and robust in challenging adaptive scenarios, where the adversary has significantly enhanced capabilities and knowledge.

Availability. Our code is publicly available at: https://github.com/shanefeng123/SHAQ.

References (45)