Dataset Protection via Watermarked Canaries in Retrieval-Augmented LLMs

Yepeng Liu, Xuandong Zhao, Dawn Song, Yuheng Bu

TL;DR

The paper introduces CanaryTrace, a novel framework designed to protect proprietary text datasets from unauthorized use in Retrieval-Augmented Generation (RAG) systems. By injecting a small number of unique, watermarked synthetic "canary" documents into an IP dataset, data owners can reliably detect copyright infringement through simple black-box queries without altering a single word of their original data.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) allows Large Language Models (LLMs) to dynamically pull context from external knowledge bases. However, this creates a massive intellectual property loophole: malicious actors can easily index copyrighted or proprietary datasets into their RAG backend without authorization.

Detecting this form of data theft—known as Dataset Membership Inference for RAG (DMI-RAG)—is incredibly challenging. Existing protection methods fall short in several ways:

  1. Visible Watermarks: Inserting random character sequences into text is easily spotted and stripped out by adversaries.
  2. White-Box Constraints: Some methods require access to the model's internal token probabilities (logits), which is impossible when dealing with commercial, closed-source LLMs.
  3. Dataset Distortion: Techniques that paraphrase the original dataset to embed invisible watermarks alter the text's style and wording. This completely breaks down for low-entropy datasets like code or mathematical text, where precise phrasing is mandatory.

The authors of this paper tackle a fundamental question: Can we embed an imperceptible and effective watermark to reliably detect unauthorized usage while keeping the original data completely unchanged?

Methods

The authors propose CanaryTrace, a framework that operates in two main stages: Dataset Protection and Dataset Detection.

Figure 1: Overview of our CanaryTrace. In the dataset protection stage, we generate watermarked and synthetic canary documents based on the attributes of the documents from the IP dataset to form a protected dataset. A malicious RAG system may integrate an IP dataset into its base dataset without obtaining permission from the data owner. During the detection stage, the data owner can conduct black-box queries (without logits information) targeting these canary documents using specifically crafted questions and analyze the model responses to detect the presence of the watermark.

1. Canary Dataset Synthesis

Instead of modifying the original data, CanaryTrace generates and injects a tiny fraction of synthetic "canary documents" ($D_s$) into the IP dataset. The generation pipeline follows these steps:

  • Attributes Extraction: A real document is sampled from the IP dataset to extract its core attributes (Topic, Subtopic, Writing Style, and Word Count) using an LLM.
  • Entity & Description Synthesis: To ensure the canary document is entirely unique and won't semantically overlap with existing web data, the system swaps real-world entities with entirely fictional ones (e.g., creating fake product names like VitalityBoost or ExerciseShield).
  • Article Synthesis: A watermarked LLM ($M_w$) weaves these fictional entities and descriptions into a cohesive article matching the original dataset's style.
  • Canary Pre-filtering: To prevent the canaries from being easily caught by malicious RAG systems running automated fact-checkers, the canaries are screened by a state-of-the-art LLM (Gemini-2.5-Flash-Lite). Only the most realistic, fact-check-resistant canaries are kept.
Figure 2: Workflow of our canary dataset synthesis algorithm. The process begins by randomly sampling a document from the IP dataset as a reference. Key attributes are then extracted from the reference document. Using these attributes, descriptions and relationships between synthetic entities are created. Finally, the algorithm outputs the synthetic text and a corresponding query question.

2. Watermarking and Black-Box Detection

The canary documents are generated using a standard green-red list watermarking scheme, which subtly biases token selection during text generation.

To catch an unauthorized RAG system, the data owner sends a series of specifically designed probing questions ($N$ queries) that can only be answered by reading the unique canary documents. If the RAG system has stolen the dataset, its retriever will fetch the canary document, and the LLM will naturally reproduce the embedded watermark tokens in its response. The data owner concatenates the responses and runs a statistical z-test to confirm the watermark's presence.

Datasets

The authors evaluated CanaryTrace using the following datasets:

  • Base Knowledge Dataset (The Background): MS MARCO, a large-scale real-world web document corpus, used to simulate the RAG system's massive pre-existing database (scaled from 200,000 up to 2 million documents).
  • IP Datasets (To Protect):
  • NFCorpus: A biomedical information retrieval dataset.
  • CQADupStack-Mathematica: A technical, low-entropy math dataset used to test performance where paraphrasing typically fails.
  • Downstream Utility Datasets: Chinese-poem and the DROP benchmark (discrete reasoning over paragraphs) to ensure the injected canaries do not degrade the RAG system's normal performance.

Key Insights and Ideas

  • Fictionality Drives Retrieval Accuracy: By anchoring canary documents around entirely fictional entities, the semantic overlap with the rest of the RAG database drops to near zero. When queried about these fake entities, the RAG retriever is virtually guaranteed to pull the exact canary document.
  • Decoupling Protection from the Source Text: Traditional watermarking modifies the source text. By shifting the watermark entirely into injected synthetic data, the original dataset achieves a perfect preservation of utility—crucial for delicate text types like poetry, legal documents, or code.
  • Bypassing the Low-Entropy Trap: Low-entropy datasets (like mathematics) lack the linguistic redundancy needed for paraphrasing-based watermarks. Synthetic canaries sidestep this constraint because they are generated from scratch, allowing arbitrary watermark capacity regardless of how rigid the original dataset is.

Key Results

  • 100% Target Retrieval Accuracy: CanaryTrace achieved a perfect 100% retrieval rate for its canary documents on the NFCorpus dataset, significantly outperforming baseline methods like WWJ and Ward, which hovered around 89%.
Figure 4: Retrieval Accuracy for different methods. Our method achieves 100% Retrieval Accuracy.
  • High Query Efficiency: The framework achieved a 100% True Positive Rate (TPR) at a strict 1% False Positive Rate (FPR) using only 12 queries on NFCorpus and only 10 queries on the low-entropy Mathematica dataset.
  • Minimal Dataset Distortion: Because the original documents are untouched, CanaryTrace demonstrated near-perfect dataset integrity, scoring 0.997 on BLEU and 0.999 on MAUVE metrics.
  • Downstream Performance Preservation: Injected canaries caused zero degradation in downstream RAG tasks (DROP and Chinese-Poem), matching the exact correctness scores of the unmodified original datasets.

Limitations and Future Work

The primary limitation acknowledged by the authors is that CanaryTrace currently focuses exclusively on text-based RAG systems. As the industry shifts rapidly toward multimodal architectures, extending this canary synthesis and watermarking pipeline to handle multimodal datasets (such as generating and embedding traceable markers into synthetic image or audio canaries) remains an open and vital area for future research.

Summary updated

BibTeX
@inproceedings{liu2025dataset,
  author = {Yepeng Liu and Xuandong Zhao and Dawn Song and Yuheng Bu},
  title = {{Dataset Protection via Watermarked Canaries in Retrieval-Augmented LLMs}},
  booktitle = {R2-FM @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=sxdaF5I6rg},
}
Figure