Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseInsight · On RadarHabr AI→ original

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
Why AI Agents Are Vulnerable to Prompt Injection — and How to Secure Them at the Architecture Level
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Trust separationevery context block gets a label (SYSTEM, INTERNAL, UNTRUSTED) and is checked before an action is executed
Tool isolationparameterized queries only, no shell commands, file and network restrictions
RAG monitoringtracking document hashes, blocking low-trust sources, detecting anomalies in search results

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.

Story

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.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

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.

Try Nomad AI →Launch Nomad Agent
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — Why AI Agents Are Vulnerable to Prompt Injection — and How to Secure Them at the Architecture Level https://news.hamidun.com/en/news/14254/why-ai-agents-are-vulnerable-to-prompt-injection-and-how-to

What do you think?
Loading comments…