The Research Report
Defense-in-Depth for LLMs: Assume Breach Architecture
OWASP has ranked prompt injection as LLM01 for three consecutive years. The 2025 Top 10 for LLM Applications states, in plain language, that "foolproof prevention may not exist" given how transformers process input. That is the standards body telling you the perimeter is fake.
Yet most production deployments still operate as if the perimeter is real. They add filters, tune system prompts, stack safety training, and hope the model will behave. The track record says it will not.
Anthropic built Constitutional Classifiers, one of the hardest defenses shipped to date. Automated jailbreak success dropped from 86% to 4.4%. Then a two-month, $55,000 public bounty found a universal bypass. One bypass. One is enough. NeuralTrust chained Echo Chamber with Crescendo and broke Grok-4 within 48 hours of release. No explicit malicious prompt anywhere in the chain.
The question is not "how do we prevent prompt injection." That question has no answer. The question is: when injection lands, what can it actually reach?
That reframing is the entire architecture.
The Structural Problem
Traditional software separates instructions from data. SQL has parameterized queries. Operating systems have kernel mode and user mode. CPUs enforce privilege rings in silicon. LLMs ship with none of that.
A system prompt arrives as tokens. User input arrives as tokens. A poisoned document pulled from RAG storage arrives as tokens. All three hit the same attention layer with the same weight. Researchers call this instruction-data conflation, and every other LLM risk hangs off it.
You can wrap user input in XML tags. Add delimiters. Stack reminders. The model treats every line as soft guidance. The next token decides whether to follow. Encoding attacks bolt on base64 and alternative character sets to sail past every classifier, because the model decodes the payload while the filter, trained on English, sees noise.
Multimodal inputs make it worse. Adversarial pixels and audio waveforms carry instructions that text-only monitoring will never see. Every new tool, plugin, and data source is a new injection point.
The wall was never a wall. It was a suggestion written in the same language as the attack.
Probabilistic vs. Deterministic Defenses
Defense-in-depth for LLMs splits into two categories doing different jobs.
Probabilistic defenses reduce the likelihood of a successful attack. Input filters, safety training, injection classifiers, LLM-as-judge checks. These are speed bumps. They slow opportunistic attackers and catch lazy payloads. They will always have bypasses, because every probabilistic defense can be overcome with enough attempts and enough prompt variation.
Deterministic defenses provide hard boundaries regardless of what the model decides to do. Privilege separation, output blocking, tool sandboxing, human-in-the-loop confirmations. These are blast doors. They do not care whether injection landed. They care whether the resulting action is allowed at the application layer.
Speed bumps without blast doors are theater. Blast doors without speed bumps are noisy. Stack both, scoped to the threat each one addresses.
This is the same assume-breach mindset that zero trust architecture baked into enterprise networks for a decade. Microsoft formalized it. CISA published it. Now we apply it to systems where the perimeter was never real in the first place.
When Injection Lands: What the Blast Radius Looks Like
Three incidents from the 2025-2026 track record illustrate what happens when injection lands in a system that did not scope the landing zone.
Vanna.AI (CVE-2024-5565, CVSS 8.1). The library's ask() function generated Plotly visualization code and passed it straight into Python's exec(). A prompt injection in the question field rewrote the visualization code into arbitrary commands. The host ran it. Remote code execution through a graphing library, because the trust chain between model output and code execution had no boundary.
MCP metadata poisoning. A poisoned tool description in the metadata field reads as trusted instructions. The model fabricates credentials the tool never returned. The attacker never needed to compromise the model. They poisoned the metadata it loads before the first user message arrives.
TeamPCP / LiteLLM supply chain (March 2026). Two backdoored LiteLLM versions shipped to PyPI containing a credential stealer targeting SSH keys, cloud credentials, and Kubernetes configs across thousands of CI/CD pipelines. The malware had a bug that crashed boxes with a runaway fork bomb. Without that mistake, the exfiltration would still be running quietly today.
Every one of those incidents is what happens when injection lands in a system that did not contain what the landing zone could touch.
The Five Layers: Assume-Breach Edition
None of these layers stop injection. All of them shrink the radius. That is the point.
Layer 1: Provenance Tagging (Input Sanitization Reframed)
Every piece of content entering the context gets a trust label at the application layer. System prompt: trusted. User input: untrusted. RAG result: untrusted. Tool output: untrusted.
The model still sees everything. The wrapper around it uses the tags to decide whether a given output is allowed to trigger a tool call. This is not input filtering trying to detect attacks. This is structural tracking that does work regardless of how capable the model gets.
Pattern matching on incoming input still has a role. It catches lazy attempts and script-kiddie variants at sub-millisecond cost. NFKC Unicode normalization defeats confusable-character bypasses. Regex patterns catch known injection shapes.
What pattern matching cannot catch: semantic injection without recognizable patterns, indirect injection from embedded documents, multi-turn steering where each message is innocuous in isolation, and encoded payloads beyond NFKC normalization. That is why provenance tagging is the real structural control. Pattern matching is the speed bump. Provenance is the tracking system that every downstream layer relies on.
Implementation priority: Deploy pattern matching first because it costs nothing. But invest real engineering in provenance tagging, because it is the metadata foundation for every deterministic layer that follows.
Layer 2: Prompt Structuring (Least Privilege for Integrations)
This is the single most impactful control in the architecture. If the customer service bot has write access to production, injection does not need to be clever. It just needs to land.
Scope every API token, every database connection, every MCP server as if you are handing a service account to a contractor who lies about everything. Because behaviorally, that is the situation. The model will follow whatever instructions reach its context window, including instructions an attacker embedded in a document three layers deep.
Provider safety APIs play a role here. Azure AI Foundry's Content Safety Prompt Shield classifies both direct prompts and indirect attacks in retrieved documents. AWS Bedrock Guardrails apply configurable prompt attack filters with strength levels. Google Cloud Vertex AI offers Model Armor for policy-based filtering. Anthropic relies on constitutional training and strong system prompt adherence with no separate detection endpoint.
But provider safety APIs are probabilistic. They catch known attack shapes. They do not catch novel semantic attacks, multi-turn steering, or tool-call hijacking. The deterministic boundary comes from least privilege: the model cannot call tools it does not have tokens for, cannot access databases it does not have credentials for, cannot exfiltrate data from systems it cannot reach.
Implementation priority: Audit every integration your model connects to. Remove every permission that is not strictly necessary for the model's intended function. This is not a filtering problem. It is an authorization problem.
Layer 3: Output Validation and Deterministic Blocking
Validate the output stream before anything executes. This is the blast door layer.
Block markdown image rendering for exfiltration. Strip embedded URLs with query parameters. Microsoft Copilot's defense kills markdown image exfiltration at this layer. The injection lands, the model generates the payload, the output filter drops it before render.
An LLM-as-judge classifier adds probabilistic coverage here too. A fast, cheap model (Haiku-class, GPT-4o-mini, Gemini Flash) runs as a secondary check, catching semantic attacks that pattern matching missed and provider safety APIs did not cover. Cost is fractions of a cent per call. Latency adds 100-300ms. The classifier sees retrieved RAG content alongside user input, providing a second opinion on indirect injection.
But the deterministic controls are what matter at this layer. Output blocking does not ask whether the output looks malicious. It enforces rules: no markdown images with external URLs, no tool calls to services outside the allowlist, no responses containing patterns that match known exfiltration templates.
Implementation priority: Build the deterministic output filters first. They catch the most dangerous outcomes (data exfiltration, tool call hijacking) without any model involvement. Add the LLM-as-judge classifier as a probabilistic overlay for semantic attacks.
Layer 4: Tool-Call Filtering (The Authorization Boundary)
The LLM's intent is advisory. The authorization lives in your code, not in the model's reasoning. Every tool call is intercepted, policy-checked, and either executed, denied, or escalated to a human.
This is where agentic AI lives or dies on security. A model with Slack, email, CRM, and GitHub tool access is an internal threat actor with arbitrary execution capability if injection succeeds. The authorization layer does not care what the model decided. It sees a high-value read followed by an external communication to a non-allowlisted recipient, and it denies, escalates, or requires multi-factor consent.
Hard denials for wildcard destructive operations. Confirmation required for external communications to non-allowlisted recipients. Rate limits per user per tool. Audit logging of everything, denied or approved.
This layer is application-specific. Every provider supports tool calling. None of them provide the authorization layer for you. Build it. Audit it. Treat it as a security boundary.
The Vanna.AI RCE is the canonical example of what happens when this layer is missing. The model generated code, and the host executed it with no boundary between output and action. Drop that same chain into a container with filesystem restrictions, no network access, and no process creation, and the worst case becomes "weird Plotly chart" instead of "shell on the box."
Implementation priority: If your model calls tools, this is not optional. Implement before launch. There is no provider-native substitute.
Layer 5: Behavioral Monitoring (Application-Layer Detection)
Prompt injection does not trip a firewall. The attack lives in tool calls and output patterns, so detection has to live there.
Baseline normal model behavior. Alert on deviations. The LiteLLM compromise got caught because the malware had a bug. Without that bug, monitoring was the only thing standing between the credential stealer and a quiet six-month dwell.
Human-in-the-loop confirmation is part of this layer, but treat it with caution. The Lies-in-the-Loop technique forges the dialog the human sees, so the click approves something different from what the agent runs. Treat the HITL prompt as untrusted output too. Any action that spends money, modifies data, or sends communications gets human confirmation. The confirmation dialog itself needs integrity verification.
Behavioral monitoring also catches what no upstream filter can: novel attack patterns that nobody has classified yet. Anomalous tool call sequences, unusual data access patterns, output that diverges from established baselines. These are signals, not certainties, but they are the signals that matter when the model has already been compromised.
Implementation priority: Start with audit logging of all tool calls and model outputs. Build baselines over time. Layer in anomaly detection as you accumulate data. Add HITL for high-impact actions from day one.
The Assume-Breach Playbook
The five layers work because they do not rely on the model behaving correctly. That is the assumption that makes them resilient.
Credential Isolation
The model never holds credentials in its context. No API keys in system prompts. No database passwords in retrieved documents. No tokens in tool descriptions. Authentication happens at the tool execution boundary, outside the model's reach. Follow an injected instruction to exfiltrate credentials and you find nothing to steal. Single architectural decision that kills an entire class of attack outcomes.
Tool Execution Sandboxing
Every tool runs in an isolated environment with its own permission boundary. Vanna's RCE worked because exec() ran in the host process. The same chain in a container with filesystem restrictions, no network access, and no process creation makes the worst case a malformed chart instead of a compromised host.
Blast Radius Partitioning
Segment the AI system so compromise of one component does not cascade. Customer-facing chatbot, internal analytics agent, and code review agent each get their own credentials, their own tool scope, their own monitoring profile. Microsegmentation for AI. Same principle that limited lateral movement in network security for a decade.
Session Isolation
A successful injection in one user's session should not reach other sessions. Context windows are ephemeral. Tool access is session-scoped. If the model has persistent memory, sanitize what gets stored and treat stored context as untrusted on retrieval. Persistent memory becomes a persistence mechanism for attackers if what goes in is not validated.
Red Team for Landing, Not Entry
The standard red team question is "can we inject." Settled. The honest test is "we successfully injected, now what is the worst outcome?" If the answer is "weird response, no real-world action," ship it. If the answer is "full database access with the service account," the architecture needs work before deployment, because attackers will find that path before the patch ships.
Why This Architecture Matters Now
The MCP ecosystem is replicating the Vanna mistake at scale. A poisoned tool description in metadata reads as trusted instructions. The model fabricates credentials the tool never returned. The attacker never needed to compromise the model. They poisoned the metadata it loads before the first user message arrived.
The supply chain attack surface is expanding. TeamPCP showed that package dependencies in AI pipelines can carry credential stealers targeting CI/CD infrastructure across thousands of organizations. The attack did not touch the model at all. It exploited the deployment pipeline the model runs in.
Multimodal inputs are opening injection vectors that text-only monitoring will never see. Vision models cannot distinguish content from command when adversarial pixels carry hidden instructions. Audio waveforms do the same for voice-enabled agents.
Every new integration, every new tool, every new data source connected to the model is a new injection point. The perimeter is not getting smaller. It is getting larger, faster, and more complex. Defense-in-depth is not a best practice. It is the only architecture that survives contact with this reality.
The Provider Matrix
Provider-native defenses vary significantly across the major platforms. Knowing what comes with the platform versus what you must build is the foundation of your defense architecture decision.
| Control | Azure AI Foundry | AWS Bedrock | Google Vertex AI | OpenAI | Anthropic |
|---|---|---|---|---|---|
| Direct injection detection | Prompt Shield | Guardrails | Model Armor | Moderation API (partial) | Training-level |
| Indirect injection detection | Prompt Shield (docs) | Guardrails (partial) | Model Armor | None | None |
| Output filtering | Content Safety | Guardrails | DLP policies | Moderation API | Training-level |
| Tool auth framework | Build your own | Build your own | Build your own | Build your own | Build your own |
| HITL framework | Build your own | Build your own | Build your own | Build your own | Build your own |
None of the providers ship the deterministic controls that matter most. Tool authorization, output blocking, credential isolation, and blast radius partitioning are all build-your-own. The provider safety APIs are probabilistic speed bumps. The blast doors are your responsibility.
Getting Started
Day one. Audit every integration. Remove every permission that is not strictly necessary for the model's intended function. This is the highest-impact change you can make. If the model cannot reach production databases, injection targeting those databases is moot.
Week one. Implement provenance tagging on all content entering the context. Label everything as trusted or untrusted. Build pattern-matching input filters for known injection shapes. These cost nothing and catch 30% of casual attacks.
Week two. Build deterministic output filters. Block markdown images with external URLs. Strip embedded URLs with query parameters. Validate tool call arguments against allowlists before execution. This is the blast door layer.
Month one. Add LLM-as-judge classifiers for semantic attack detection. Build behavioral monitoring baselines. Implement session isolation and credential isolation. Start red teaming for landing, not entry.
Ongoing. Every new tool, every new integration, every new data source gets the same treatment. Least privilege from day one. Provenance tags on every content source. Deterministic output validation on every model response. The architecture does not rely on the model behaving. It relies on the walls around the model holding.
The Core Thesis
Defense-in-depth for LLMs replaces the unreachable prevention goal with a containment goal. Assume injection will succeed. Design so it cannot reach anything worth stealing. Red team against the post-injection blast radius. If the worst case is a weird response with no real-world consequence, the architecture works.
The model is not the security boundary. The model is the compromised zone. Security lives in the deterministic controls around it: provenance tracking, least-privilege integrations, output blocking, tool authorization, and behavioral monitoring. These work regardless of how capable the model gets, because they do not ask the model to behave. They prevent the model from misbehaving at scale.
Prompt injection will land. The architecture around the model determines whether that landing is a bump or a catastrophe.
Sources: ToxSec, "LLM Defense in Depth: Assume Breach and Contain the Blast" (May 31, 2026); AboutCloud.io, "Five Layers of Prompt Injection Defense: A Production Implementation Guide" (May 2026); OWASP LLM Top 10 2025; JFrog CVE-2024-5565 analysis; Trend Micro LiteLLM supply chain analysis.