Skip to content

CAITLYN: Can LLM agents autonomously synthesize defenses against emerging injection attacks?CAITLYN: Can LLM Agents Autonomously Synthesize Defenses against Emerging Injection Attacks?

arXiv· arXiv:2608.27990· Zi Liang, Xiaoyu Xu, Yanyun Wang, Minxin Du, Qingqing Ye, Haibo HuThe Hong Kong Polytechnic University; The Chinese University of Hong KongIndexed by this site · 23 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose the defense middleware CAITLYN: System I performs two-layer detection of known injections, and System II synthesizes new skills using counterexamples; the authors claim that on the Emerging benchmark they reduce the ASR of three agents from 77.0%–79.5% to 38.5%–39.5%.

Threat modelTool-augmented LLM agents perform open-ended tasks for benign users; user prompts are trusted, while external content such as web pages, files, APIs, and MCP tool outputs is untrusted. External attackers write arbitrary text into untrusted data sources, with the goal of confidentiality/integrity violations; they have black-box query access and know the tool interfaces and parameter schemas, but cannot modify system prompts, model weights, or API credentials.

Questions
LLM agents ingest content through untrusted channels such as web pages, files, APIs, and MCP tool outputs, making them vulnerable to indirect prompt injection; the authors argue that existing defenses face a trilemma among runtime efficiency, context precision, and post-deployment adaptability that is difficult to balance.
Methods
CAITLYN is an agent-agnostic defense middleware: System I performs real-time blocking with Tier-0 rule scripts plus Tier-1 merged two-call LLM detection; System II draws on CEGIS, treating missed attacks as counterexamples, with an LLM generator producing candidate defense skills and a deterministic verifier filtering them by a dual specification before writing them back to the skill library.
Experiments and results
On standard benchmarks, the authors state that CAITLYN's detection is on par with SOTA and its token overhead is lower than LLM-as-a-judge; on the new benchmark Emerging, static defenses have an ASR of 72.5%–80.0%, and after System II synthesizes 4 skills, the ASR of three agents drops to 38.5%–39.5%; adaptive attacks can evade 38/113, and after one more synthesis round all are blocked again.
Limitations and future work
The authors point out that the evolved skill representation is precise and easy to evade through rewriting, and that robust and confidential skill representations are an open direction; end-to-end poisoning against the human curation process is also unsolved. On Emerging, four families including Freshness Framing remain largely compromised, and the post-evolution ASR is still 38.5%–39.5%.
Experimental setupDeepSeek-V4-Flash、Qwen3.8-Max et al. · AgentDojo、ASPI et al. · Action ASR、FPR et al.
Evaluated models
DeepSeek-V4-FlashQwen3.8-MaxGLM-5.3Kimi-K3MiniMax-M3Claude-Opus-4.6Claude-Fable-5GPT-5.6-SolGemini-3.7-Flash
Benchmarks
AgentDojoASPISafeClawBenchAgentDefenseEmerging
Metrics
Action ASRFPRTPRPrecisionRecallUtilityLatencyCost
AI summaryCAITLYN is a prompt injection defense middleware for LLM agents, whose System II can autonomously synthesize defenses against emerging injection attacks. System I performs real-time detection with rule scripts and LLM reasoning, matching state-of-the-art defenses in detection on standard benchmarks with lower token overhead than LLM-as-a-judge baselines. On Emerging, a new benchmark proposed by the authors, static baselines and System I alone remain vulnerable, while System II substantially reduces attack success rates in three agent environments.

CAITLYN is a prompt injection defense middleware for LLM agents, whose System II can autonomously synthesize defenses against emerging injection attacks. System I performs real-time detection with rule scripts and LLM reasoning, matching state-of-the-art defenses in detection on standard benchmarks with lower token overhead than LLM-as-a-judge baselines. On Emerging, a new benchmark proposed by the authors, static baselines and System I alone remain vulnerable, while System II substantially reduces attack success rates in three agent environments.

Related events and news

0 events · 1 news mentions

News that mentions this paper

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    To address the trilemma in defending LLM agents against indirect prompt injection, where efficiency, precision, and adaptability are difficult to reconcile.

    Core question: how to provide tool-augmented LLM agents with prompt injection defenses that simultaneously satisfy low runtime overhead, low false positives, and continuous adaptation to novel injection attacks.

    • Scenario and importance: Coding and everyday assistant agents hold system-level execution privileges and continuously ingest content from untrusted channels such as web search, local files, API responses, and MCP tool outputs; the authors cite real vulnerabilities such as EchoLeak (CVE-2025-32711) to show that injection can lead to data leakage and arbitrary code execution.
    • Shortcomings of existing methods: The authors propose an "agent defense trilemma"—rule/regex filters are fast but easily bypassed by obfuscation; LLM guards and fine-tuned classifiers are accurate but impose latency, token cost, and false positives on large volumes of benign traffic; structured access controllers and offline retrained models cannot continuously absorb new attack payloads after deployment.
    • Core observation: Drawing on Counterexample-Guided Inductive Synthesis (CEGIS) from program synthesis, the authors argue that each attack payload that bypasses existing defenses is a concrete counterexample that can serve as a formal specification for synthesizing more robust defense skills.
    • The paper proposes: CAITLYN, an agent-agnostic defense middleware comprising a real-time System I (Tier-0 rules + Tier-1 LLM detection) and a counterexample-driven System II that synthesizes new skills; it also builds a delivery-aware benchmark, Emerging, to evaluate adaptation to novel injections.
    • Threat model (Section 2.2):
      • Goal: Cause confidentiality violations (stealing user data/memory/files) or integrity violations (unauthorized state modification, arbitrary command execution, malicious parameter calls to privileged tools); passive task failure is not included.
      • Knowledge: A strong adversary with black-box query access, who knows the agent's tool interfaces and parameter schemas and can observe public outputs and tool execution traces.
      • Capability: Can write arbitrary text into web pages, repositories, shared files, APIs, and third-party MCP responses; payloads may contain obfuscation, semantic indirection, multi-stage framing, or jailbreak patterns.
      • Victim system and boundary: User prompts are trusted; the TCB includes the agent host runtime, the underlying model service, and the CAITLYN daemon and its defense repository; the attacker cannot modify system prompts, model weights, or API credentials.
  2. What related research exists?

    The paper organizes defense work into three categories—input filtering, model hardening, and system-level isolation—and draws on CEGIS program synthesis as the source of methodological inspiration.

    Injection and jailbreak attacks

    • Indirect prompt injection: Greshake et al. (2023) hijack agent execution via external resources; Pérez and Ribeiro (2022) systematize prompt injection techniques; Tensor Trust (Toyer et al., 2024) provides injection samples from an online game.
    • Jailbreaks and poisoning: adversarial attacks by Wei et al. (2023) and Zou et al. (2023); AgentPoison (Chen et al., 2024) poisons memory and knowledge bases; PoisonedRAG (Zou et al., 2025) poisons RAG knowledge bases; the MCP security audit (Radosevich and Halloran, 2025) points out that malicious MCP responses can lead to unauthorized code execution.

    Input-level defenses

    • Rules and classifiers: programmable guardrails in NeMo Guardrails (Rebedea et al., 2023); compact sequence classifiers such as Llama Prompt Guard, Protect AI DeBERTa, and Llama Guard; LLM-as-a-judge evaluators (Zheng et al., 2023).
    • Specialized detectors: canary-style known-answer verification (Liu et al., 2024); the game-theoretic minimax detector DataSentinel (Liu et al., 2025).

    Model-level and system-level defenses

    • Model-level: syntactic transformation in Spotlighting (Hines et al., 2024); instruction hierarchy training (Wallace et al., 2024); structured queries in StruQ (Chen et al., 2025); preference optimization in SecAlign (Chen et al., 2025).
    • System-level: execution isolation in IsolateGPT (2025); capability-based information flow tracking in CaMeL (Debenedetti et al., 2025); structured policy enforcement on tool calls in AgentWard and ClawGuard. The paper points out that these static rules are fragile to semantic evasion, and heavyweight evaluators and manual policies cannot dynamically absorb new attack variants.

    Program synthesis and evaluation benchmarks

    • Method inspiration: CEGIS (Solar-Lezama et al., 2006; Alur et al., 2013; Gulwani, 2011); CAITLYN treats payloads that bypass defenses as counterexample specifications.
    • Baselines and benchmarks: seven baselines—None, Regex-Guard, LLM-Judge, LLM-Judge+Fewshot, Spotlighting+Delimiting, Tool Filter, PI Detector; benchmarks are AgentDojo, ASPI, SafeClawBench, AgentDefense (detection protocol), and the authors' new Emerging.

    The authors position this paper as: rather than making defenses static heuristics, an executable, self-extending skill library, using System I/System II to decouple real-time execution from dynamic synthesis, to explore balancing the three axes of the trilemma.

  3. How does the paper address this problem?

    CAITLYN abstracts defenses into an executable skill library: System I performs two-tier real-time detection, and System II uses a CEGIS-style loop to synthesize new skills from counterexamples.

    Overall approach: formalize defense knowledge into defense skills in the form of self-contained directories. System I uses a hierarchical skill library for real-time interception, and System II takes missed attacks as counterexamples, synthesizes new skills through a generate-verify loop, and writes them back to the shared skill library (Figure 1).

    Skill representation and hierarchical organization

    • Skill structure: each skill is a directory containing a README (operating specification), config.yaml (id, category, role, tier, thresholds, LLM prompts), and executable scripts (Figure 2); the design goals are expressive flexibility, a unified interface, and readability and portability.
    • Basis for hierarchy: the authors give two observations—the vast majority of inputs in real environments are benign (Observation 3.1); high-severity attacks usually require a chain of execution/tool calls (Observation 3.2), so applying heavy detection to all inputs is not cost-effective, while a purely lightweight approach has too high a false-positive rate.
    • Initial library: 24 skills in three categories, compiled from 2024–2026 literature (Table 5): 14 Tier-0, 8 Tier-1, and 2 tier 2 (packaged only as knowledge context).

    System I: fast runtime execution

    • Tier-0 filters: rule and script skills reside in memory with no LLM calls; skill s returns a label ys ∈ {BENIGN, SUSPICIOUS, MALICIOUS} and a confidence cs; a hit occurs when ys = MALICIOUS and cs ≥ τs, and any hit is judged MALICIOUS and terminates; crashes, timeouts, or malformed output are treated as a miss (fail-open).
    • Tier-1 classifiers: perform LLM detection on inputs that bypass Tier-0, using merged-pair execution—packaged into two parallel API calls, where Call A evaluates detector-type skills and Call B uses the remaining skills as reference knowledge; the two calls share a byte-identical prefix to exploit provider-side prompt caching, output is restricted to a single-line status code plus confidence, and the final result is aggregated with OR (Figure 3).

    System II: counterexample-guided skill synthesis

    • Counterexample collection: monitor anomalous signals such as agent tool-call patterns, file-write events in monitored directories, and host OS network connection metrics, and use a dedicated agent to reverse-mine attack payloads; users may also submit candidate payloads directly.
    • Generator: an LLM generator receives the attack's statistical features (keywords, entropy, length), the nearest sample clusters retrieved from the attack corpus by token Jaccard overlap, and context, and iteratively rewrites/combines existing skill features; the original trigger text does not enter the generator prompt (information barrier).
    • Verification and resources: a deterministic verification sandbox immediately evaluates candidate scripts; an independent reviewer (another LLM agent) reviews and gives feedback; a lesson database archives successful and failed attempts. Acceptance criteria: match all attack trigger samples, and hit at most 1 of 5 held-out benign samples; regex checks time out at 200 milliseconds in an isolated subprocess and undergo static ReDoS analysis.
    • Budget and gating: at most 3 candidates per round, at most 5 CEGIS iterations, and a 40,000-token budget; after passing, candidates lacking a concrete payload enter shadow observation mode and must achieve zero false positives over 7 days or 50 scans and at least 1 confirmed hit before promotion; before deployment there is also an over-broad predicate pruning filter (Appendix 7.1, 7.2.3).

    Engineering details

    • Middleware form: a background daemon combined with agent execution hooks, file system monitoring, and OS-level telemetry to intercept unsafe observations; provides a TUI; hook errors or timeouts default to fail-open.
    • Cloud sync: off by default; after the user explicitly opts in, attack samples and synthesized skills are synced across deployments only after audit by human security experts.
    • Runtime guardrails: large inputs are truncated to a 1 MiB head and tail; noisy tool channels use a skip-list; malicious files are quarantined; synthesis is rate-limited by default to a 60-minute cooldown and a daily cap of 10.
  4. What experiments did the paper conduct?

    Compares seven baselines on four detection benchmarks and three end-to-end benchmarks, and tests System II's evolution, streaming synthesis, and adaptive attacks on the new benchmark Emerging.

    Experimental setup

    • Victim agents: Coding agents Codex, Pi Coding Agent, OpenCode; everyday assistant agents Hermes Agent, OpenClaw, 5 in total.
    • Benchmarks: AgentDojo (97 user tasks, 629 security tests), ASPI (728 task-attack scenarios), SafeClawBench (600 staged tasks, six attack families); end-to-end uses subsets (e.g., AgentDojo-S250 is 250 attack cases); the detection protocol additionally uses AgentDefense-S250; the new benchmark Emerging contains 200 attack cases, nine attack families, and ten generation templates, split into 100 seed / 100 held-out (Figure 14).
    • Baselines: None, Regex-Guard, LLM-Judge, LLM-Judge+Fewshot, Spotlighting+Delimiting, Tool Filter, PI Detector.
    • Metrics: Action ASR (proportion of attacks leading to unauthorized action execution), TPR/FPR/Precision/Recall, Utility (safe-completion rate), end-to-end latency and USD cost.
    • Implementation: Docker isolation, a clean workspace per case; all victim agents and LLM defenses share the same backbone, routed via OpenRouter; generation hyperparameters use provider defaults; the LLM judge uses greedy decoding; a 5-minute timeout per task. The paper does not state which specific backbone model was used in the main experiments, nor does it report the number of repetitions.

    Main results

    End-to-end effectiveness (Table 1, Action ASR; SafeClawBench has no benign set, so FPR is n/a):

    Swipe horizontally to read the table

    AgentMetricNoneLLM-JudgePI DetectorCAITLYN
    opencodeAgentDojo-S25016.8%0.0%3.2%0.0%
    opencodeASPI-S5.4%2.2%5.4%2.2%
    opencodeSafeClawBench-S24033.3%24.2%23.8%2.9%
    codexSafeClawBench-S24027.1%17.9%23.8%4.6%
    piSafeClawBench-S24020.0%18.8%20.8%2.1%
    hermesSafeClawBench-S24032.1%24.2%22.5%5.8%
    openclawSafeClawBench-S24030.8%22.5%25.0%3.8%
    • The authors state that CAITLYN achieves 0.0% ASR on four of the five agents on AgentDojo (openclaw is 0.4%), at most 2.2% on ASPI, within no more than 1.1 percentage points of the best baseline.
    • Exception (FPR): CAITLYN has an FPR of 0.0% on the AgentDojo benign set, but on ASPI its FPR is 12.9%–19.4%, higher than all baselines; the authors explain this as conversational benign controls mimicking the attack structure under the full-prompt protocol.
    • Latency: The authors state that end-to-end latency is often lower than the no-defense baseline, but clarify that this is because early blocking terminates the subsequent tool chain; this number mixes defense overhead with shortened task trajectories and should not be read as a reduction in pure scanning latency.

    Detection protocol and ablations

    • Detection protocol (Table 6): CAITLYN achieves TPR 100.0% on AgentDojo-S250 (on par with the two LLM judges), 76.3% on ASPI-S (tied for highest with LLM-Judge), and 63.7% on SafeClawBench-S240 and 76.4% on AgentDefense-S250, the highest in their respective columns; FPR 2.8%, 2.09–2.52 seconds per check, and per-sample cost lower than the two LLM judges.
    • System I ablation (Table 2, single paired run): Tier-0 only has zero cost and zero false positives but a TPR of only 3.2%–48.4%; the full two-call OR scheme achieves TPR 100.0% and 89.2% on AgentDojo-S250 and ASPI-S, with FPR 3.2%, reducing FPR from 6.8% to 3.2% compared with the unmerged per-detector ensemble, with detection coverage on par or within 2.2 percentage points; this run had a latency of 5.17 seconds and a cost of $0.00100 per check.

    Emerging: evolution, streaming synthesis, and adaptive attacks

    • End-to-end evolution (Table 7, Figure 6): On Emerging, the ASR of all static defenses and CAITLYN-static is between 72.5% and 80.0%; System II treats each miss as a counterexample, with 77 evolution runs, 18 acceptances, and 24 skills instantiated, of which only 4 pass the over-broad filter (Figure 13); after adding these 4 skills, ASR drops to 38.5% for OpenClaw, 39.5% for Codex, and 39.5% for Hermes, which the authors describe as a net drop of about 40 percentage points.
    • Family-level coverage (Table 8): Gains are concentrated in Status Field and Policy Delta (all three agents drop to 0.0%) and Search Mirror (0.0%/0.0%/4%); the Freshness Framing, Latest Event, Directory Alias, and Ledger Update families remain partially or fully compromised; on Hermes, the ASR of Ledger Update rises from 88% with the initial library to 100% after evolution, and the paper does not explain why.
    • Streaming synthesis (Table 4, Table 9): On the 200-case nine-family stream, Static has a held-out TPR of 16.0% (FPR 1.6%); Batch spends 20,331 tokens without synthesizing any effective skill; Sequential accumulates 4 active skills, raising held-out TPR to 30.0% while FPR stays at 1.6%; the Ledger Update and Mail Followup families reach 100% held-out TPR; the authors point out that large seed clusters are the main synthesis bottleneck.
    • Adaptive attacks (Section 5.3, Table 10): The attacker can see the source code of the 4 evolved skills and has at most 5 queries to the scanning oracle; of the 113 blocked samples, 50 cannot be evaded because the target string directly conflicts with the signature, and of the remaining 63, 38 are evaded by rewriting (a net evasion rate of 33.6% on the blocked set); after sending these 38 back to System II for one more synthesis round, all are detected again, and the benign pool FPR rises from 0.4% to 2.0%.

    Other ablations and analyses

    • Backbone impact (Table 3, opencode + SafeClawBench-S240): Across the nine backbones, ASR does not exceed 3.3%, and is 0.0% for five; GPT-5.6-Sol, with the highest Utility (60.4%), has an ASR of 0.0%; DeepSeek-V4-Flash is the cheapest but has the highest ASR (3.3%).
    • Synthesis cost (Figure 13): The Emerging experiments used about 2.18 million generator tokens in total, and 59/77 runs accepted no skill (31 exhausted rounds, 21 exhausted the token budget).
  5. What are some points that can be further explored?

    The authors point out that skill representations are easily evaded by rewriting, and end-to-end poisoning of the curation pipeline remains unsolved; experiments cover five agents and nine backbones.

    Limitations and future directions noted by the authors

    • Fragility of skill representation: The evolved predicates encode precise features such as length bands, which are easy to audit but also easy to evade through rewriting (Appendix 8.2); the authors state that robust, confidential skill representations are an open research direction (Appendix 9.4).
    • Poisoning risk in the curation process: Plausible-looking poisoned contributions still need to pass expert review; an attacker who compromises operator credentials can bypass the entire pipeline; the authors state that end-to-end poisoning campaigns against the curation process remain an open research direction (Appendix 10.1).
    • No formal guarantee of completeness: The authors state that a formal guarantee of completeness for unconstrained future payloads is beyond the capability of empirical synthesis (Section 2.2).
    • Large seed cluster bottleneck: The authors point out that large seed clusters within a single wave remain the main synthesis bottleneck (Section 5.2).
    • Engineering implementation precondition: Untrusted input triggers checks via hooks, "unless there is an engineering implementation problem (i.e., hook timeout)", and hooks default to fail-open (Sections 2.2, 3.4).

    Scope of experimental coverage

    • The agents tested are Codex, Pi Coding Agent, OpenCode, Hermes Agent, and OpenClaw, 5 in total; the backbone comparison covers 9 models (Table 3).
    • The benchmarks are AgentDojo, ASPI, SafeClawBench, AgentDefense (detection protocol), and Emerging (200 cases, nine families); end-to-end uses the subsets S250/S240.
    • The adaptive attack evaluation covers skill-aware evasion (113 blocked samples, 5-query budget, OpenClaw scanning oracle); library poisoning only performs architecture-level mitigation analysis, with no end-to-end experiments (Section 5.3).
    • The paper does not report the specific backbone model names used in the main experiments, the number of repetitions, or human evaluation or reviewer agreement.
    • On Emerging, the post-evolution ASR remains 38.5%–39.5%; the four families Freshness Framing, Latest Event, Directory Alias, and Ledger Update are not covered by the 4 retained skills (Table 8).
  6. Summarize the main content of the paper

    CAITLYN addresses prompt injection with two-tier detection plus counterexample-driven skill synthesis; the authors state that it is on par with SOTA on standard benchmarks and can autonomously adapt to novel attacks.

    A defense paper: addressing indirect prompt injection against tool-augmented LLM agents, the authors argue that existing defenses face a trilemma among runtime efficiency, contextual precision, and post-deployment adaptability, and propose an agent-agnostic defense middleware, CAITLYN.

    • Method: Defense knowledge is abstracted into a skill library of self-contained directories (24 skills initially). System I executes in real time: Tier-0 rule scripts hit quickly with zero LLM overhead, and Tier-1 packages LLM detection skills into two parallel calls sharing a prefix (merged-pair), with the decision aggregated by OR. System II draws on CEGIS: missed attacks are treated as counterexamples, an LLM generator produces candidate skills under an information barrier, and a deterministic verifier filters by "match all attack samples, at most 1 false positive on 5 benign samples", after which they are written back to the skill library following shadow observation and over-broad filtering.
    • Standard benchmarks: On AgentDojo-S250, four of the five agents have an ASR of 0.0%, and on SafeClawBench-S240 the ASR is 2.1%–5.8% (no defense is up to 33.3%); under the detection protocol, AgentDojo-S250 TPR is 100.0%, and per-sample cost is lower than the LLM-as-a-judge baseline (Table 1, Table 6). The cost is that FPR on the ASPI benign set rises to 12.9%–19.4%.
    • Adaptation to emerging attacks: On the new benchmark Emerging (200 cases, nine families), all static defenses have an ASR of 72.5%–80.0%; after System II retains 4 skills through 77 evolution runs, the ASR of three agents drops to 38.5%–39.5% (Table 7).
    • Streaming and adaptive: Under the nine-family streaming protocol, Sequential synthesis raises held-out TPR from 16.0% to 30.0% while FPR stays at 1.6% (Table 4); skill-aware adaptive attacks evade 38 of 113 blocked samples (33.6%), and after one more synthesis round all are blocked again, with FPR rising from 0.4% to 2.0% (Table 10).
    • Authors' conclusion: The authors state that CAITLYN matches SOTA detection quality on standard benchmarks with lower token overhead than LLM baselines, and that the autonomous adaptation loop can close coverage gaps for unknown attacks at the cost of a small increase in false positives; they also acknowledge that evolved skills are easy to evade through rewriting and that poisoning against the human curation process is unsolved.

Related papers

Show 3 more papers
Read originalarxiv.org