Security
~9 min readUpdated: December 2026

DefenseComposer: Knowledge-Guided Prompt Injection Stacking (0.0% ASR)

DefenseComposer Knowledge-Guided Prompt Injection Defense Stacking in Smoke Monkey

DefenseComposer (arXiv:2611.37071) evaluates 13 runtime defenses across 66 ordered stacks and 26,222 AgentDojo/DTap trajectories, exposing three compositional failure modes and delivering 11 repair rules that raise attacked task completion +15.3% (87.2%) at 0.0% ASR.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

DefenseComposer: Knowledge-Guided Prompt Injection Stacking (0.0% ASR): DefenseComposer (arXiv:2611.37071) evaluates 13 runtime defenses across 66 ordered stacks and 26,222 AgentDojo/DTap trajectories, exposing three compositional failure modes and delivering 11 repair rules that raise attacked task completion +15.3% (87.2%) at 0.0% ASR. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampledefensecomposer-hardened-agent.ts
defensecomposer-hardened-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
const hardenedAgent = createAgent({
agentId: 'defensecomposer-ipi-guarded-agent',
provider: 'google',
model: 'gemini-2.5-flash',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'ask',
run_command: 'ask',
},
// Deterministic ToolFilter (Tr1) + Boundary Delimiters (Te4) without destructive upstream paraphrasing
allowedTools: ['read_file', 'list_files', 'search_docs'],
preserveOriginalUserPromptForActionCheck: true,
});
async function processUntrustedRepo() {
const result = await hardenedAgent.run(
'Read the external issue body inside <untrusted_observation> delimiters, extract reproduction steps, and do not invoke state-changing tools.'
);
console.log('Guarded Execution Result:', result.summary);
}
processUntrustedRepo().catch(console.error);
Video Guides

Watch: Related Video Guides

Part 4 | Indirect Prompt Injection Explained: How AI Agents Get Hacked Through Webpages

Indirect prompt injection | AI & LLM App Security

What Is DefenseComposer? The Illusion of Stacking Naive Guardrails

DefenseComposer (arXiv:2611.37071) is an empirical security framework evaluating 13 runtime indirect prompt injection (IPI) defenses across 66 ordered stacks and 26,222 trajectories (3,700 benign, 22,522 attacked) on AgentDojo and DTap. Its central finding overturns common security intuition: blindly stacking more defenses often achieves 0.0% Attack Success Rate (ASR) only because upstream rewrites break the agent's ability to finish legitimate tasks.

On Gemini-2.5-Flash in AgentDojo, an uncoordinated four-defense stack (Spotlighting Te3 + PromptArmor Cl2 + TaskShield Ac1 + CommandSans Cl1) posts 0.0% ASR, yet collapses Benign Utility (BU) to 5.0% (2 of 40 tasks) at 3.14x token cost. By contrast, a targeted two-defense pair combining Delimiters (Te4) with ToolFilter (Tr1) retains 77.5% BU and 75.0% Attacked Utility (AU) at 0.4% ASR and 0.60x baseline token usage.

Defense Stack VariantBenign Utility (BU ↑)Attacked Utility (AU ↑)Attack Success Rate (ASR ↓)State-Changing TDR (↓)Benign Token Cost (TokX ↓)
Base (Undefended)80.0%63.8%13.3%53.9%1.00x
`Te4 + Tr1` (Delimiters + ToolFilter)77.5%75.0%0.4%47.9%0.60x
`Te3 + Cl2` (Spotlighting + PromptArmor)57.5%70.8%2.9%55.0%2.03x
`Ac1 + Cl1` (TaskShield + CommandSans)50.0%46.3%0.0%27.4%3.03x
`Te3+Cl2+Ac1+Cl1` (Naive 4-Stack)5.0%7.1%0.0%0.0%3.14x
*CaMeL / MELON (Architectural Ref)*30.0% / 50.0%——0.0% / 0.0%4.86x / 1.32x

Three Compositional Failure Modes & 11 Knowledge-Guided Repair Rules

Auditing 38 benign failures in Te3+Cl2+Ac1+Cl1 reveals that 79% (30 of 38) stem from defense-to-defense handoff conflicts rather than any single checker failing alone:

  1. Cross-Defense Information Loss: Upstream Paraphrasing (Te6) alters exact user-required strings (e.g., expanding "Congrats" to "Congratulations"), failing exact-match Slack tasks. Worse, TaskShield (Ac1) blocks valid tool calls if intermediate list/read evidence is stripped from its inspection context.
  2. Incompatible Execution Order: Spotlighting (Te3) prepends an 8-character marker to short fields like "Emma" (4 chars) and "Johnson" (7 chars), pushing them above CommandSans (Cl1)'s 8-character threshold and triggering 6 redundant LLM cleaning calls (+1,074 wasted tokens). Running Cl1 before Te3 drops total model calls from 28 to 22.
  3. Over-Broad Mitigation Scopes: Aggressive cleaners corrupt file IDs, JSON keys, and boundary markers needed by downstream tools.

Encoding these fixes into 11 composition rules and applying them to six unseen stacks lifts benign task completion from 85.4% to 100.0% (+14.6%) and attacked task completion from 71.9% to 87.2% (+15.3%) while holding 0.0% ASR.

Text+Action Pairs Beat Text-Only Pairs

Across 26 evaluated defense pairs, 13 text+action stacks average 1.7% ASR (with -16.0% BU loss vs strongest single component), whereas 13 text-only pairs average 7.1% ASR (-19.8% BU loss). Always pair boundary marking with deterministic tool-call enforcement.

Implementing Clean Handoffs in an Agent Defense Pipeline

Keep the original trusted prompt and retrieved read-only evidence immutable in an envelope for action checkers (Ac1), while executing output cleaners (Cl1) before adding spotlighting markers (Te3).

typescript
interface HandoffEnvelope {
  trustedPromptVerbatim: string;     // Never paraphrased before Ac1 check
  retrievedReadEvidence: unknown[];  // Forwarded to ActionChecker for provenance
  sanitizedObservation: string;      // Cleaned by Cl1 BEFORE Te3 boundary markers
}

export function runOrderedDefenseStage(rawObservation: string, env: HandoffEnvelope): string {
  const cleaned = commandSansClean(rawObservation);   // Cl1 first (skips <8 char identifiers)
  return applyDelimiterBoundary(cleaned, 'untrusted'); // Te3/Te4 second
}

Enforcing Deterministic Handoffs in Smoke Monkey Harness

Smoke Monkey Harness natively separates read-only exploration from state-changing execution (permissions: { read_file: 'allow', write_file: 'ask', run_command: 'ask' }), acting as a deterministic Tr1 + Ac1 enforcement layer. By preserving original user instructions verbatim across phases and gating external writes, teams prevent IPI payloads from hijacking repository edits without crippling benign coding throughput.

Google Search Questions & Answers

Frequently Asked Questions

Q:Why does stacking four prompt-injection defenses often ruin agent reliability?

Upstream text rewriters and cleaners mutate exact wording, strip retrieved tool evidence, or trigger downstream sanitizers—causing 79% of audited benign failures in DefenseComposer's 4-defense stack (dropping completion to 5.0%).

Q:What is the best lightweight defense stack found in DefenseComposer?

Combining Delimiters (`Te4`) with ToolFilter (`Tr1`) achieved 0.4% ASR, 77.5% benign utility, and 75.0% attacked utility while cutting benign token usage to 0.60x of the undefended baseline.

Q:Why should CommandSans (Cl1) run before Spotlighting (Te3)?

Spotlighting adds an 8-character marker that pushes short benign strings (like 4–7 char names) past CommandSans's 8-character trigger threshold, causing redundant LLM sanitization calls and higher latency.

Q:How much does DefenseComposer's knowledge-guided repair improve unseen stacks?

Across six held-out defense stacks evaluated with Codex, applying the 11 composition rules raised benign completion from 85.4% to 100.0% (+14.6%) and attacked completion from 71.9% to 87.2% (+15.3%) at 0.0% ASR.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness