Stacking Prompt-Injection Defenses Without Testing the Stack¶
A prompt-injection defense stack accepted on attack success alone can look secure while the agent fails most legitimate tasks.
The mistake is to add runtime defenses and accept the stack because attacks stop succeeding. An upstream defense can lower attack success rate (ASR) by stripping context the task needs or by rejecting legitimate tool calls. One preprint tested stacks on AgentDojo with Gemini-2.5-Flash. A stack of Spotlighting, PromptArmor, TaskShield, and CommandSans reached 0.0% ASR and completed 5.0% of benign (attack-free) tasks. A two-defense stack of delimiters and a tool filter reached 0.4% ASR and completed 77.5%. The undefended agent scored 13.3% ASR and completed 80.0% (Chen et al., arXiv:2611.37071v1).
The collapse differed by model. The same four-defense stack completed 47.5% of benign tasks on Qwen-Max and 50.0% on DeepSeek-V4-Pro, where the undefended agent completed 77.5% and 82.5% (Chen et al.).
What breaks between defenses¶
The paper traces three kinds of handoff failure. The examples below come from 20 paired comparisons on AgentDojo with DeepSeek-V4-Flash, so read them as cases, not rates (Chen et al. §V):
- Information loss. A paraphrasing defense reworded a message the user wanted posted exactly. The planner and the action checker used the rewrite, and the sent message failed the task's exact-text requirement.
- Wrong order. Spotlighting adds eight-character markers, and the CommandSans cleaner skips strings shorter than eight characters after trimming. Marking first led the cleaner to cut "Help" from the title "Help me". Cleaning first kept it.
- Over-broad scope. A cleaner removed some of the boundary markers that a delimiter defense had added around external content.
Reordering is not a general fix. When the paper paired two cleaners, both orders removed task information needed for invitation and channel details (§V-B).
Test the stack you ship¶
These checks draw on the paper's composition rules and recommendations (Chen et al., §III-E, Table IX, and §VII):
- Report benign task completion, task completion under attack, and ASR together, next to an undefended run.
- Compare the full ordered stack with its smaller ordered subsets on the same tasks and attacks.
- Log each defense's input and output. Protect the original user request, IDs, paths, enum values, and boundary markers from rewriting or removal.
- Where one defense changes text another reads, test the order.
- Attack the complete stack with payloads written for its order.
Step 2 matters because a pair can score outside the range of its parts. Below, the first pair completes fewer benign tasks than either part. The second has lower ASR than either part. Each row is 40 benign runs and 240 attacked runs on AgentDojo with Gemini-2.5-Flash (Table XXI):
| Defenses, in order | Benign completion | ASR |
|---|---|---|
| Spotlighting | 67.5% | 2.5% |
| CommandSans | 72.5% | 8.8% |
| Spotlighting, then CommandSans | 20.0% | 3.3% |
| Delimiters | 92.5% | 11.2% |
| Tool filter | 52.5% | 4.2% |
| Delimiters, then tool filter | 77.5% | 0.4% |
A separate study on GPT-4o also saw a cost from combining. A tool-output firewall alone completed 74.09 ± 5.75% of benign AgentDojo tasks at 0.00% ASR. With a tool-input firewall added, ASR stayed at 0.00% and benign completion was 58.41 ± 2.61%. The authors describe the combined utility as slightly lower and attribute that to the input firewall's redactions (Bhagwatkar et al., arXiv:2510.05244v2).
Step 5 raised ASR in the paper. The delimiter-plus-filter stack scored 0.4% on fixed payloads and the four-defense stack 0.0%. Under tailored attacks (100 attacked runs per stack), both reached 8.0%. The same payloads reached 18.0% and 14.0% respectively against the undefended agent (§IV-C).
Why it works¶
The handoff failures occur when defenses transform shared text that holds both untrusted content and information the task needs. The next defense or tool receives the changed form (Chen et al. §II-A). ASR alone cannot show the damage, because "A stack that blocks legitimate execution can also suppress attack activity" (§III-E). Matched runs of a full stack and its subsets hold tasks and attacks fixed, so you can compare the stack with and without one component (§III-C).
Three authors audited 38 benign failures of the four-defense stack. They labeled 30 as compounding blocks or upstream-induced refusals or rewrites (§IV-D). A compounding block is a failure that appears only when the defenses' restrictions combine. Defense in depth treats layers as independent, and these handoffs are where to test that.
When this backfires¶
- Adding a layer can lower ASR. Combining the PromptGuard 2 and AlignmentCheck detectors gave 1.75% ASR and 42.68% utility. AlignmentCheck alone gave 2.89% and 43.09%, and PromptGuard 2 alone gave 7.53% and 47.01%. AlignmentCheck ran on Llama 4 Maverick, and the authors scored static AgentDojo traces offline (Chennabasappa et al., arXiv:2505.03574v1).
- Your benign task set is small. At 40 benign runs, one task moves benign completion by 2.5% (Chen et al., Appendix B), and a smaller set moves in larger steps.
- The full sweep costs more than you can spend. The paper's main matrix of 66 variants took 18,480 runs (Appendix Table XIII). For two defenses, you can limit the sweep to no defense, each alone, and both.
- Your agent differs from the test bed. The main matrix used banking, travel, workspace, and Slack tasks, and it sampled only some of the possible orders (§III-C and §III-D).
- You treat a tested stack as a security boundary. Automated search found at least one exact attack bypass, within five attempts, for each of the three stacks it targeted (§IV-C).
Example¶
In an AgentDojo Workspace task run with DeepSeek-V4-Flash, Spotlighting turned the file ID "3" into 3SPM#@&#+. The agent passed that value to append_to_file, which reported that the file did not exist. The repair excluded file IDs from Spotlighting's text marking. That restored the argument "3", and the first write succeeded (Chen et al. §V-C).
Key Takeaways¶
- Read a near-zero ASR beside benign completion before you accept a stack.
- Keep a defense when the ordered stack measures better with it, on your model and tasks.
- Check the fields a later defense or tool reads, such as IDs, paths, and the user's exact wording.
- Retest under attacks written for the whole stack. In the paper, three stacks at 0.4% ASR or lower on fixed payloads reached 8.0% to 11.0% that way.
Related¶
- Single-Layer Prompt Injection Defense — the opposite failure, relying on one safeguard.
- Defense-in-Depth Agent Safety — the layering approach these checks apply to.
- Adaptive Evaluation of Out-of-Band Prompt-Injection Defenses — attacking a defense with knowledge of how it works.
- Destyling Untrusted Input as a Prompt Injection Defense — a defense that rewrites text, so its effect on later layers needs testing.
- Per-Layer Suppression Accounting — recording which layer discarded each item.