Why AI Agents Are Vulnerable to Prompt Injection — and How to Secure Them at the Architecture Level
Classic security approaches stop working in AI systems because any text in the context window can influence model behavior. OWASP notes that all inputs carry the same trust weight, and the model cannot distinguish system instructions from external data. This architectural merger demands a fundamentally different approach to security. Andrey Biryukov proposes four architectural layers of defense: trust separation through typed context blocks, minimal tool privileges, memory and RAG-corpus control, and built-in human-in-the-loop.
AI-processed from Habr AI; edited by Hamidun News
In traditional software, architecture and security are clearly separated: there's a perimeter, authentication, input validation. In AI systems, this boundary blurs so much that classic approaches stop working.
The key problem: AI agents merge two things that were always kept apart — the control plane and the data plane. In a normal application, a user command is processed by deterministic code, and data can't rewrite the logic. In an LLM system, any text in the context window can potentially influence the model's behavior.
OWASP puts it this way: "All inputs carry the same trust weight, and the model cannot internally distinguish trusted instructions from untrusted data." This is an architectural shift that requires building security into the system from the ground up, not adding it as a filter on top.
Principle 1: Trust separation as an architectural primitive
Many architects place untrusted content, internal data, and system instructions in the same context window, assuming the model will sort it out on its own. That's a mistake. The solution is introducing an explicit trust level for every fragment, with enforced layer separation.
The system doesn't work with concatenated prompt strings — it works with typed context blocks. Each block gets provenance metadata and a trust level: system instructions are trusted, data from an internal database is internal, external content and RAG documents are untrusted. Tools check these labels before executing.
OWASP calls this "segregation of trust," and as of 2026 emphasizes that it's no longer just a best practice — it's an architectural requirement.
Principle 2: Tool isolation and least privilege
A dangerous architectural mistake is giving an LLM access to tools with excessive permissions. That could be a "read" tool that's actually able to delete documents, or a database connection with admin rights when all that's needed is SELECT. The solution: give each tool the minimum necessary set of permissions and an isolated execution context.
Instead of handing the model raw SQL queries, the system accepts structured parameters (table, filters, limit) and builds the parameterized query itself. This rules out an entire class of injection attacks. Avoid open-ended functionality like executing shell commands or arbitrary URL requests. Use granular tools with constraints: file tools that write only to a specific directory and only with a specific extension, email tools that send only to addresses on an approved allowlist.
Principle 3: Controlling memory and the RAG corpus
The RAG corpus is part of the attack surface — often a more dangerous one than the prompt itself. Research from WARP showed it's possible to inject "poisoned" documents into a search corpus so that, on trigger, RAG retrieves exactly those documents. The AgentPoison study succeeded in 82% of cases with a poisoning rate below 0.1% — a single malicious document per thousand can be enough.
Defense involves three layers: provenance control for every document, with metadata and content hashes; isolation of search results, flagged as untrusted; and drift monitoring — detecting when search starts returning documents it never returned before.
Principle 4: Human-in-the-loop as an architectural component
This isn't a UI feature with a confirmation button — it's a component built into the runtime. Actions are classified by risk level: LOW (read-only, internal data), MEDIUM (write to sandbox, internal notifications), HIGH (delete, external API calls, financial operations). HIGH-risk actions require confirmation, and the agent cannot bypass it.
Real-world incidents confirm the need: CVE-2025-32711 (EchoLeak) — a prompt injection in Microsoft Copilot with zero-click data exfiltration; CVE-2025-54135 and CVE-2025-54136 — remote code execution via prompt injection in the MCP implementation of Cursor IDE. All of these resulted from architectural mistakes, not model shortcomings.
This isn't a story about making the model safe. It's about designing security at the level of the system's architecture.
- Dec 2, 2026Ai2 Releases MolmoWeb2 Web Agents: 27B Model Solves 75.3% of Tasks
- Dec 2, 2026T-Decision-1 9B scores 71.6 points and beats a model six times its size
- Dec 2, 2026JetBrains Releases Air App: Control AI Agents in Your IDE From a Smartphone
- Dec 2, 2026JetBrains Offers Voluntary Departures as IDE Search Raised Agent Task Costs by 6–7%
Key Questions Answered
What are the key details on Principle 1: Trust separation as an architectural primitive?
Many architects place untrusted content, internal data, and system instructions in the same context window, assuming the model will sort it out on its own. That's a mistake. The solution is introducing an explicit trust level for every fragment, with enforced layer separation. The system doesn't work with concatenated prompt strings — it works with typed context blocks.
What are the key details on Principle 2: Tool isolation and least privilege?
A dangerous architectural mistake is giving an LLM access to tools with excessive permissions. That could be a "read" tool that's actually able to delete documents, or a database connection with admin rights when all that's needed is SELECT. The solution: give each tool the minimum necessary set of permissions and an isolated execution context. Instead of handing the model raw SQL queries, the system accepts structured parameters (table, filters, limit) and builds the parameterized query itself.
What are the key details on Principle 3: Controlling memory and the RAG corpus?
The RAG corpus is part of the attack surface — often a more dangerous one than the prompt itself. Research from WARP showed it's possible to inject "poisoned" documents into a search corpus so that, on trigger, RAG retrieves exactly those documents. The AgentPoison study succeeded in 82% of cases with a poisoning rate below 0.1% — a single malicious document per thousand can be enough.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
