TL;DR
In security, layering defenses ("defense-in-depth") is golden wisdom—until you apply it to AI agents. When you stack multiple guardrails against prompt injection, upstream filters often mangle the exact context or formatting that downstream tools need, creating a "secure" brick that blocks hackers simply because it can no longer do anything at all. This paper systematically diagnoses why stacked AI defenses fight each other and distills the fixes into reusable rules that allow an automated coding agent to repair broken security pipelines on the fly.
What Problem Does This Paper Address?
Tool-using Large Language Model (LLM) agents don't just chat; they read emails, query databases, and update files. This makes them vulnerable to Indirect Prompt Injection (IPI)—malicious instructions hidden inside untrusted external data (like a poisoned calendar invite) that hijack the agent into leaking data or making unauthorized transfers.
To stop IPI, production systems routinely layer runtime controls: marking untrusted text at the input stage, restricting available tools, auditing proposed actions, and sanitizing returned tool outputs. Yet academic research almost exclusively evaluates each defense in isolation. Nobody had systematically tested what happens at the handoffs when these mechanisms share a loop. If Defense A rewrites a prompt to neutralize an attack, does Defense B panic and block the legitimate task? Low attack success rates mean very little if normal execution is quietly broken.
Methods
The authors introduce DefenseComposer, an empirical framework and automated repair workflow built in three phases:
- Subset-Closed Measurement Harness: They integrated 13 existing runtime defenses into a unified loop and constructed 66 ordered configurations—taking five 4-defense "source stacks" and testing every ordered subset (singles, pairs, triples, and full quads) alongside an undefended baseline. By logging state mutations at every handoff across fixed and adaptive attacks, they isolated true interaction bugs from single-component flaws.
- Trace Auditing & Taxonomy: By comparing failed full-stack traces against successful single-defense runs on identical tasks, they diagnosed where and why pipelines break, testing manual adapter repairs to verify the root causes.
- Knowledge-Guided Automated Repair: Instead of brittle, one-off patches, they distilled their manual fixes into 11 reusable composition rules (e.g., preserve original user phrasing at decision points, exempt structured IDs like file paths from text marking, strip structural delimiters before running content cleaners). They packaged these rules as an open-source skill for Codex (an AI coding agent), enabling it to automatically inspect defense code, select viable stacks, and rewrite conflicting adapters for previously unseen defense combinations.
Datasets
No new datasets were introduced; the authors evaluated over 26,200 agent trajectories using two established red-teaming benchmarks:
- AgentDojo: Primary testbed spanning banking, travel, workspace, and Slack tasks across six attack families.
- DTap (DecodingTrust-Agent Platform): Secondary evaluation covering code, CRM, file-system, and telecom domains to verify generalization.
Key Insights and Ideas
- The "Secure Brick" Illusion (Less is More): Deeper stacks frequently crush benign task utility without adding real security. Under adaptive attacks tailored to the whole pipeline, a heavy 4-defense stack had the exact same bypass rate as a lightweight 2-defense pair—while failing 95% of normal tasks.
- Failures Happen in the Handoffs: In the audited 4-defense stack, 79% (30/38) of benign failures didn't exist in individual components; they emerged purely from defense interactions.
- Three Compositional Failure Modes:
- Cross-defense information loss: An upstream paraphraser changes "Congrats" to "Congratulations," causing a downstream action-checker or exact-match requirement to reject the action.
- Incompatible execution order: A spotlighting defense appends an 8-character warning tag (
SPM#@&#+) to a 4-letter name ("Emma"), pushing it over an 8-character threshold that triggers redundant, destructive downstream sanitization. - Over-broad mitigation scopes: Text markers get appended directly to structured arguments—turning file ID
"3"into"3SPM#@&#+"—causing downstream file APIs to crash.
Key Results
- Lightweight Beats Deep: On AgentDojo, a 4-defense stack (
Te3+Cl2+Ac1+Cl1) achieved 0.0% Attack Success Rate (ASR), but completed a dismal 5.0% of benign tasks (BU) at 3.14× token cost. Meanwhile, a 2-defense pair (Delimiters + ToolFilter) hit 0.4% ASR while preserving 77.5% BU at 0.60× token usage (saving tokens by pruning tool descriptions). Under adaptive attacks, both hit 8.0% ASR. - Manual Handoff Repairs Work: Simply preserving sanitization source paths at handoffs boosted the broken 4-defense stack's benign completion from 5.0% to 35.0% while keeping ASR at 0.0%.
- Distilled Rules Generalize to Unseen Stacks: When repairing six held-out defense combinations, giving Codex the 11 composition rules raised benign task completion from 85.4% to 100.0% (+14.6%) and task completion under active attack from 71.9% to 87.2% (+15.3%) compared to giving Codex source code alone—all with 0.0% observed ASR.
Limitations and Future Work
- Sample Resolution on Adaptive Attacks: Adaptive attack searches only covered 8–10 tasks per stack (meaning a single task swings metrics by ~10–12.5%). Larger task pools are needed to finely resolve differences between low-ASR stacks.
- Coarse State-Change Tracking: Their secondary security metric—Tool Disruption Rate (TDR), which flags any state-changing tool call during an attacked run—cannot distinguish between an attacker-induced file edit and an authorized task write. Future evaluators could match specific tool arguments (like recipient IDs or transfer amounts) against retrieved observations.
- Rule Ablations: The 11 rules were tested as a unified skill; future ablations could isolate how much each individual rule contributes to automated repair.
Summary updated