← Deep dives

Deep dives · 2026-11-25 · Advanced · By bombong

Canary tokens: tracing data flows inside AI by planting unique markers

Canary tokens are a technique that plants a unique string, found nowhere else, in data and then infers where the data went by watching where the string appears. Recent research uses the technique to identify scrapers that collect LLM training data, trace the stages of prompt injection, and detect leaks from RAG knowledge bases.

Contents
Key points
  • The core of a canary token is a 'one-of-a-kind marker.' If the marker shows up in an output, that is evidence the output passed through that data.
  • The same principle, with only the planting and observation points changed, is used for scraper identification (2605.13706), injection-stage tracing (2603.28013) and RAG leak detection (2604.10717).
  • Instead of a single 'did it succeed' number, injection research records how far an attack got across four stages (exposed → persisted → relayed → executed), showing where it was stopped.
  • Not seeing a canary does not mean there was no exposure. A trace is strong evidence, but its absence is weak evidence.
  • In data governance discussions, canary tokens are also proposed as a policy tool that lets data producers detect unauthorized use (2412.03824).

Why it was needed: you cannot see where data goes inside AI

LLMs keep taking in external data, from pretraining through the stage where they search the web when asked a question. But from the outside it is hard to see which data went into which model. The scraper identification study paper points out that even website operators who want to block crawling for LLMs first need to know which scrapers supply data to which LLMs. It argues that the methods available today (voluntary disclosure by companies, one-off experiments by researchers, crowdsourced reports) are neither reliable nor scalable.

Security faces a similar situation. Kill-Chain Canaries paper notes that in multi-agent systems that read documents, web pages and tool results on a user's behalf, resistance to prompt injection (attacks that steer a model with instructions hidden in external data) is usually reported as a single number: 'did the attack succeed.' A single number cannot show at which stage an attack was stopped or which component did the defending.

In RAG (retrieval-augmented generation), the problem is knowledge base leakage, where adversarial prompts make a model regurgitate internal documents it retrieved. CanaryRAG paper points out that these attacks have evolved into adaptive forms that repeat with varied queries, while effective countermeasures are lacking. The three problems share one thing: there is no marker to confirm where data ended up after passing through a black box.

Core idea: send data out carrying a one-of-a-kind marker

A canary token is a unique string (a random combination of characters or an invented proper noun) that could not appear anywhere else, even by chance. You plant it in data and later watch where the string appears. The name comes from the canaries that once gave early warning of toxic gas in coal mines, and CanaryRAG paper says it was inspired by stack canaries in software security (values planted to detect memory overwrites).

An analogy is banknotes with recorded serial numbers. If a bank records the serial numbers, then seeing which shop's safe a note came from shows the path the money took. The note looks ordinary, but its number is unique, so it serves as evidence. Likewise, what matters about a canary token is its uniqueness, not its meaning.

The trade-off this design aims for is clear. It infers from inputs and outputs alone, without access to model internals (weights, training data lists, logs). So even an unauthorized third party can use it paper. What you get in return is probabilistic evidence. A marker that appears is strong evidence, but one that does not appear cannot confirm the data was never passed through.

How it works: plant, pass through, observe, judge

First, generate a unique token for each target. What you want to distinguish determines the token unit. To distinguish scrapers, create a different token for each visiting scraper paper; to distinguish attacks, put a different token in each injected payload paper. In RAG, tokens go into retrieved chunks (document fragments) paper.

Second, send the tokens through the data path. The scraper study runs a dynamic website that shows different content to each visitor, so each scraper takes away its own token. The injection study plants token-carrying payloads in attack surfaces such as documents, web pages and tool results.

Third, observe the exit. The scraper study asks LLMs about the site and checks whether the token appears in the answer. The injection study checks how far the token reaches: tool call results, shared memory writes, messages passed to other agents, or actual executed actions. CanaryRAG monitors in real time, during generation, whether the canary behaves as expected.

Fourth, judge. The scraper study's criterion is 'consistency.' If an LLM steadily outputs a token given only to a particular scraper, that is taken as evidence the LLM was exposed to that scraper's data. This guards against treating a single chance match as evidence.

Basic flow of canary tokensGenerate unique tokens → Plant in data; Plant in data → Pass through AI system; Pass through AI system → Observe exit; Observe exit → Judge; Generate unique tokens → Issuance record(Record); Issuance record → Judge(Match)Generate uniquetokensOne per targetPlant in dataWeb pages · payloads ·chunksPass through AIsystemTraining · agents ·RAGObserve exitResponses · memory ·actionsIssuance recordToken ↔ target mapJudgeConsistent appearance= exposureRecordMatch
Basic flow of canary tokens Plant a unique token per target in the data, then, after the data passes through the AI system, judge by whether the token appears at the exit. The three studies differ in where they plant and where they observe.

One principle, three uses

Scraper identification paper is a provenance-tracing approach that asks 'did this data go into this model.' Experimenting on 22 production LLM systems, it reports reliably determining which scrapers supply data to which LLMs, including several links the companies had not disclosed. Website operators can use the results to decide what to block with access controls such as the Robots Exclusion Protocol (robots.txt).

Kill-Chain Canaries paper is a propagation-tracing approach that asks 'how far did the attack spread inside the system.' It records the farthest stage a payload's token reached in four stages: Exposed, Persisted, Relayed and Executed. It ran 950 times across 5 production LLMs, 6 attack surfaces and 5 defense conditions. In runs that called tools, exposure was 100%, and the differences emerged at the later stages. Claude Haiku 4.5 and Claude Sonnet 4.5 executed none of 164 text-surface attacks, and in text relay experiments the canary never entered a memory write (0/40). GPT-4o-mini, by contrast, executed 53% of attacks. A result that a single number would have summed up as 'blocked' instead shows where the chain broke, such as 'read but not persisted.'

CanaryRAG paper is a real-time defense approach that asks 'is a leak happening right now.' It plants canaries in retrieved chunks and redefines leak detection as a 'dual-path execution integrity game.' If the canary behaves unexpectedly on either the target path, which produces the actual response, or the oracle path, which serves as the reference, it flags a leak. The authors say it detects leaks even under adaptive suppression and obfuscation, where attackers try to hide canaries by deleting or distorting them. They report much lower chunk recovery rates than existing techniques, with almost no effect on task performance or inference latency. They also stress that it can be plugged into existing RAG pipelines without retraining or architectural changes.

The three studies do not build on one another; they applied the same principle to different questions around the same time. The differences lie in where tokens are planted and observed, and whether the goal is after-the-fact auditing or real-time blocking.

Three uses of canary tokens

Scraper identificationProvenance tracing

  • A different token per scraper
  • Ask LLMs, check outputs
  • Tested on 22 production LLMs
  • After-the-fact audit

Kill-Chain CanariesPropagation tracing

  • A different token per payload
  • Record farthest stage reached
  • 950 runs
  • Diagnose where to defend

CanaryRAGReal-time defense

  • Canaries in retrieved chunks
  • Monitor target and oracle paths
  • Plug in without retraining
  • Real-time leak detection

공통 Infers data flow from whether a unique marker appears, without access to model internals

The same principle answers different questions. Compare where tokens are planted and observed, and whether the use is after-the-fact auditing or real-time defense.

Where it is heading: from research tool to governance tool

Canary tokens are discussed not only as an experimental technique but also as a policy tool. A study on frontier AI data governance paper proposes viewing data not only as a source of harms such as privacy violations or copyright infringement, but as a governance tool for monitoring and reducing the risks of high-capability models. It lays out 15 mechanisms organized by actor in the data supply chain (producers, collectors and processors, model developers, data sellers) and focuses on five less-explored ones. The first is developing canary tokens so data producers can detect unauthorized use.

The study also notes the difficulties. Data is not used up when many parties use it at once, it is hard to keep others from using it, it is easy to copy, and it can increasingly be produced synthetically. Canary tokens turn one of these properties, 'easy to copy,' to their advantage, because the marker travels with the copied data.

The 2026 studies can be seen as turning this direction into something actually measurable. The scraper study paper showed a way for an unauthorized third party to infer which data flowed into which model, and Kill-Chain Canaries paper and CanaryRAG paper extended the scope to auditing data flows inside agent and RAG systems with markers.

Limitations, open issues and practical guidelines

First, the evidence is strong in only one direction. A unique token appearing in output is strong evidence of exposure, but if it does not appear, you cannot tell whether the data was never passed through, the model did not memorize it, or a filter removed it. This is also why the scraper study paper counts only cases where the token appears 'consistently.' So an audit report should not state 'no canary detected = no unauthorized use.'

Second, experimental designs are easily confounded. Kill-Chain Canaries paper adds several caveats itself. The result suggesting that memory written by Claude protects readers using other models comes from only one combination (n = 3); other combinations were not tested. Claude models executed none of the 40 pre-planted original injections, but Claude Haiku 4.5 executed 2 of 3 injections relayed by GPT-4o-mini. Whether relayed injections are harder to refuse than originals is left as an open question. DeepSeek Chat went from 0/24 on pre-planted memory to 8/8 on tool results, but the two scenarios also differed in task and payload format. White-text PDF payloads, invisible on the rendered screen, worked as often as visible ones, which shows that the assumption 'if people cannot see it, it is safe' is wrong.

Third, attackers know about canaries too. Countering adaptive attacks that delete or rewrite markers is why CanaryRAG paper chose a dual-path design. Designs should assume that plain single-token string matching can be easily bypassed.

Practical guidelines are as follows. Use canaries when the goal is after-the-fact auditing and provenance tracing. If blocking is needed, though, combine them with access controls or guardrails. Create a separate token for each target and keep an issuance record so you can later trace back who leaked it. Report injection evaluations as per-stage reach rates rather than a single success rate, so you can decide where to place defenses. Do not test only the screen people read; include hidden text and tool results in the tested path.

Four stages of the injection kill chain

  1. 1
    ExposedRead by the model as a tool result
  2. 2
    PersistedWritten to shared memory
  3. 3
    RelayedPassed to another agent
  4. 4
    ExecutedFollowed the injected instruction
These are the stages Kill-Chain Canaries records as the point a canary token reached. Where the chain broke determines where to place defenses.

Further study

For the most intuitive view of the principle, start with the scraper identification study paper. Its structure ('give each visitor a different token, then ask the model to check') is simple, which makes it a good way to understand the judgment logic of canary tokens, especially the consistency criterion.

If you work on agent security, Kill-Chain Canaries paper comes next. Reading its four-stage kill chain definition, its results by model and attack surface, and the authors' own caveats about sample sizes and confounders together helps build a feel for evaluation design.

If you run a RAG service, look at why CanaryRAG paper separates the target and oracle paths and how it handles adaptive suppression. If you are interested in policy and governance, see in the frontier data governance study paper how canary tokens sit alongside the other 14 mechanisms.

Related terms

Prompt injection Indirect prompt injection RAG Data exfiltration Data governance Training data extraction Multi-agent Guardrails

References

Foundational papers

Recent research

Written by AI from the listed references and reviewed. Please check the original sources for details.