AI Agent Security

Prompt Injection Canary: Definition and Setup Guide

A prompt injection canary is a unique, monitored value embedded in a prompt, system message, or tool output that reveals whether an AI agent has processed or acted on untrusted instructions it should not have. When the canary appears in unexpected model output or triggers an unexpected action, it signals a likely prompt injection attempt, giving security teams a detection point before the agent completes a harmful action.

What a Prompt Injection Canary Actually Is

A prompt injection canary works by planting a distinctive marker somewhere in the trust boundary of an AI agent, then watching for that marker to surface in a place it should never appear. If the canary shows up in a response, a tool call, or a log entry it was not meant to reach, that outcome indicates the agent followed instructions from untrusted content rather than its intended system directives.

The technique borrows directly from security concepts like canary tokens and honeytokens used in traditional infrastructure monitoring, adapted for the specific failure mode of large language model agents: instructions hidden in retrieved documents, tool outputs, or user-supplied content that attempt to hijack the model's behavior.

Why This Matters for Enterprise Agent Deployments

As agents gain access to tools, internal data, and the ability to take action on behalf of users, the consequences of a successful prompt injection grow accordingly. A canary does not prevent an injection attempt from occurring, but it gives security teams a reliable, low-noise signal that something bypassed expected boundaries, often before the agent completes an irreversible action.

Implementation Considerations

Effective canary deployment depends on where the value is placed, how it is generated, and how consistently it is monitored across the agent's execution path. The sections below cover placement, evaluation criteria, and the pipeline stages where a canary provides the most coverage.

Canaries as One Layer, Not a Complete Control

A canary is a detection mechanism, not a preventive one. It confirms that an injection attempt succeeded in influencing the agent, but it does not stop the agent from acting on that instruction unless it is paired with enforcement controls that can intercept the action before it completes.

Where Canaries Fit in Agent Architecture

Canary placement should align with the specific injection vectors present in the agent's architecture. Coverage generally requires attention at three points across the pipeline, outlined below.

  1. 1

    Where Canaries Fit in Agent Architecture

    Canary placement should align with the specific injection vectors present in the agent's architecture. Coverage generally requires attention at three points.

System Prompt Layer

Detects direct attempts to override or exfiltrate system instructions.

Tool-Call Boundary

Detects indirect injection carried in tool responses before execution.

Output Generation

Detects canary triggering after processing but before action commitment.

Evaluation Checklist Before Deploying a Canary

  • Identify every ingestion point where untrusted content reaches the agent, including retrieved documents, tool responses, and third-party APIs
  • Confirm canary values are generated per session and not reused across requests
  • Verify monitoring can inspect intermediate tool-call payloads in real time, not only final output
  • Define a validation process for canary triggers to reduce false positive escalations
  • Confirm alerting integrates with existing security operations and incident response workflows
  • Document the canary mechanism as part of the AI system risk assessment for audit purposes

Move From Detection to Enforcement

A canary tells you something went wrong. Runtime governance determines what happens next. See how policy enforcement, tool-call permissioning, and audit logging work together to contain prompt injection attempts before they result in unauthorized action.

Explore Runtime Governance