How does your AI governance program compare?

    See where your program has gaps in less than 2 minutes.

    Take the assessment
    Implementation Guide

    Prompt Injection Canary Testing

    Prompt injection canary testing embeds unique marker tokens into a system prompt, context window, or tool response, then monitors model outputs and tool-call behavior to detect when those markers are leaked, altered, or omitted, providing a repeatable signal that prompt injection defenses have been bypassed.

    Prompt Injection Canary Testing at a Glance

    A short summary of what canary tokens are, where they run, and how findings connect to broader agent governance.

    Canary Markers

    Unique strings embedded in trusted context to detect tampering or leakage.

    Detection Signals

    Marker leakage, omission, unexpected repetition, or unauthorized tool invocation.

    Runtime Placement

    System prompts, retrieved documents, and tool responses across the agent pipeline.

    Governance Fit

    Feeds into least-privilege enforcement and audit logging under existing AI risk frameworks.

    What Is Prompt Injection Canary Testing

    Prompt injection canary testing is a security testing technique that places a unique marker string, or canary token, inside a system prompt, retrieved document, or tool response, then checks whether that marker survives unaltered through model processing. If adversarial input causes the marker to be revealed, echoed out of context, modified, or dropped where it should persist, the test indicates that injected instructions influenced the model's behavior. Neither OWASP, NIST, nor MITRE formally define canary testing as a named methodology. It builds on documented concepts such as delimiter-based spotlighting, which separates trusted instructions from untrusted content, and on adversarial testing lifecycles described in NIST's AI Risk Management Framework and OWASP's LLM Top 10. Canary testing narrows those broader concepts into a specific, repeatable check: a defined marker, a defined expected behavior, and an observable pass or fail outcome.

    How Canary Tokens Are Constructed and Embedded

    A canary token is typically a distinct string placed where an attacker's injected content should not be able to reach or manipulate it, such as within a protected section of a system prompt. The test establishes an expected behavior baseline first: under normal operation, the marker should never appear in output, should never be repeated back verbatim, or should always appear in a specific unaltered form, depending on what the test is designed to verify. Because indirect injection can originate from retrieved documents, third-party API responses, or tool outputs rather than direct user input, markers should be tested across each of these context sources independently rather than only in the primary system prompt. Static, unrotated markers are a known weakness. If the same string is reused across many tests, an adversary who observes it once can learn to avoid triggering detection, so markers should be varied or rotated as part of the testing cycle rather than treated as a fixed constant.

    Signals That Indicate a Successful Injection

    A canary test produces a small set of observable signals. Token leakage occurs when the marker appears in output where it should have remained protected, suggesting the model disclosed instructions it should not have surfaced. Output anomaly occurs when the marker is altered, truncated, or repeated in a way inconsistent with the established baseline, suggesting the model's handling of trusted context was disrupted. Unauthorized tool invocation is a separate but related signal specific to agent architectures: injected instructions may not affect visible text at all but instead cause the model to call a function, access a resource, or pass parameters it was not authorized to use. MITRE's ATLAS framework and NIST's adversarial taxonomy both treat tool and agent systems as an expanded attack surface, which means canary testing in agentic environments needs to check tool-call behavior alongside text output, not text output alone.

    Integrating Canary Testing With Governance and Least-Privilege Controls

    Canary testing is a detection technique, not a containment control, so its value depends on what happens after a marker is flagged. Least-privilege permissioning for agent tool access limits the practical impact of a confirmed injection by restricting what actions an agent can take even if its instructions are compromised, which is why NIST and MITRE guidance treats tool permissioning and adversarial testing as complementary rather than substitutable controls. Runtime governance platforms that provide agent permission management, tool approval workflows, and audit logging give canary detection a place to route findings rather than leaving them as isolated test output. Trussed AI's runtime governance and monitoring capabilities are built around this pairing: enforcing least-privilege access for agent tool calls and maintaining audit logs that security teams can use to investigate flagged canary results and unauthorized tool invocations. No regulatory framework currently mandates canary testing specifically. It should be positioned as one control supporting broader AI risk management processes such as NIST's AI RMF, documented alongside other testing activities rather than treated as a standalone compliance requirement.

    Runtime Architecture for Continuous Canary Testing

    Implementation Considerations

    Practical guidance for teams building or operating canary-based detection in agent pipelines.

    • Establish a documented baseline of expected model behavior before introducing canary markers, so anomalies can be distinguished from normal output variability.
    • Test canary markers across all context sources an agent processes, including system prompts, retrieved documents, and tool or API responses, not just direct user input.
    • Log all canary test results centrally to support the audit trails expected under AI governance and internal review practices.
    • Rotate or vary canary markers over time to reduce the risk that adversaries learn to recognize and evade a static detection string.
    • Correlate canary detection alerts with tool-call authorization logs so text-level and action-level injection signals are reviewed together.

    Verify Your Agent Pipelines Against Prompt Injection

    Canary testing identifies where injection defenses fail. Runtime governance determines what happens next, from tool-level containment to audit-ready logging.

    Explore Runtime Governance