Prompt injection has no complete fix, so the architecture has to limit what a misled model can do. Trust boundaries, tool permissions and data boundaries mapped to the OWASP Top 10 for LLM Applications.

The security problem at the centre of every LLM application is structural. A language model reads its instructions and its data through the same channel, as text. Greshake and colleagues described this as LLM-integrated applications that "blur the line between data and instructions", and showed that an attacker who can place text where the application will retrieve it can steer the model without ever talking to it [3]. A web page, a support ticket, an email or a PDF can carry instructions.
OWASP ranks prompt injection first in its Top 10 for LLM Applications 2025 and is candid about the state of defences: "it is unclear if there are fool-proof methods of prevention for prompt injection" [2]. That sentence should shape the architecture. If the model can be misled, the design question becomes what a misled model is able to do, and how much of that the rest of the system will refuse.
The working assumption we use is simple to state. The model is a capable but untrusted component that sits inside the trust boundary of the application and outside its authority. It can propose actions. It cannot authorise them.
User ──► Application / orchestrator ──────────────────────────────┐
│ identity, policy, rate limits, approvals │
│ │
▼ │
Model (untrusted reasoning) ◄── retrieved content │
│ proposes tool calls (untrusted text) │
▼ │
Tool gateway ── checks: is this tool allowed for this │
│ user, this task, with these arguments? │
▼ │
Downstream systems ── enforce their own authorisation │
│
Model output ──► output handler (encode, validate, parameterise) ◄┘
Every arrow out of the model passes through code that does not depend on the model's judgement. OWASP puts this as "complete mediation": enforce authorisation in downstream systems rather than relying on the LLM to decide whether an action is allowed [5]. Its guidance on system prompt leakage makes the same point from the other side. The system prompt "should not be considered a secret, nor should it be used as a security control" [6]. Anything written in a prompt ("never reveal customer data", "only refund up to the limit") is a request to the model, not a control.
The OWASP Top 10 for LLM Applications 2025 [1] is a list of risks. Turning it into design work means asking, for each risk, which layer owns the control.
| OWASP 2025 risk [1] | Where the main control lives | Examples of the control |
|---|---|---|
| LLM01 Prompt Injection | Everywhere downstream of the model | Least privilege, separation of untrusted content, human approval for high-risk actions [2] |
| LLM02 Sensitive Information Disclosure | Data access layer | Strict access controls, restricted data sources, redaction of confidential content [1] |
| LLM03 Supply Chain | Build and deployment pipeline | Vetted suppliers, a signed component inventory (SBOM), model integrity checks [1] |
| LLM04 Data and Model Poisoning | Training, fine-tuning and embedding pipelines | Data origin tracking, vetted data vendors, sandboxing of unverified data [1] |
| LLM05 Improper Output Handling | Output handler | Context-aware encoding, parameterised queries [4] |
| LLM06 Excessive Agency | Tool gateway and downstream systems | Fewer, narrower tools; user-context execution; approval [5] |
| LLM07 System Prompt Leakage | Application configuration | No secrets in prompts; controls enforced outside the model [6] |
| LLM08 Vector and Embedding Weaknesses | Retrieval layer | Permission-aware stores, partitioned indexes [7] |
| LLM09 Misinformation | Product design and evaluation | Grounding in trusted sources, automatic validation, human review of critical output, clear labelling [1] |
| LLM10 Unbounded Consumption | Platform and gateway | Rate limits, quotas, input limits, timeouts [8] |
No row puts the main control inside the model. Even for prompt injection, most of OWASP's seven mitigations, such as least privilege, human approval, segregation of external content and adversarial testing, act around the model rather than through its instructions [2]. For agents that plan and act over many steps, OWASP has also published a separate Top 10 for Agentic Applications [11], which is worth reading alongside this list.
OWASP traces excessive agency to three root causes: excessive functionality, excessive permissions and excessive autonomy [5]. Each one maps to a design decision you make before writing a prompt.
Functionality. Offer only the tools the task needs, and prefer narrow tools to open-ended ones. OWASP gives shell execution and URL fetching as examples of open-ended extensions to avoid [5]. A get_order_status(order_id) tool can do far less damage than a general run_sql(query) tool.
Permissions. Run tools with the permissions of the user on whose behalf the agent acts, not those of a service account that can see everything [5]. The Model Context Protocol's security guidance applies the same idea to tokens. An MCP server "MUST NOT accept any tokens that were not explicitly issued for the MCP server", because passing a client's token through to a downstream API bypasses that API's controls and confuses the audit trail [9]. The same guidance recommends starting with a minimal scope set and elevating scope only when a privileged operation is first attempted, and it lists wildcard scopes such as * or full-access as common mistakes [9].
Autonomy. Decide which actions need a person to approve them before they run. OWASP lists human approval for high-impact actions under both prompt injection and excessive agency [2][5]. What the approver sees, and how approvals are recorded, is the subject of designing human approval into enterprise AI agents.
Take a hypothetical customer-support agent that reads tickets, looks up orders and can issue small goodwill credits. A tool design that follows the guidance above might look like this.
| Tool | Runs as | Scope | Approval | Reason |
|---|---|---|---|---|
read_ticket(ticket_id) | Signed-in support user | Tickets assigned to the user's team | None | Read-only and already visible to the user |
get_order(order_id) | Signed-in support user | Orders of the ticket's customer only | None | Argument checked against the ticket in code, not in the prompt |
issue_credit(order_id, amount) | Signed-in support user | Amount at or below a configured cap | Required above a lower threshold | Moves money; the cap is enforced by the billing service |
send_email(to, body) | Not offered | The ticket's reply channel already exists; a free-form email tool is an exfiltration route |
The last row is the most important. Removing a tool is the cheapest control there is.
The same reasoning applies to data tools. Where a model generates SQL, a database role that can only read, combined with statement validation outside the model, means a misled model can at worst run an unwanted query, not change data. Daivota's DataMantri product works in this area: it generates, validates and runs read-only SQL on PostgreSQL to answer plain-language questions. The detailed patterns are in making natural-language SQL safer.
Simon Willison describes a "lethal trifecta" for AI agents: access to private data, exposure to untrusted content, and the ability to communicate externally [10]. An agent with all three can be instructed, by text it reads, to send private data somewhere an attacker can collect it. With any one leg removed, that particular attack has nowhere to go.
This gives a practical design test for each agent or session.
| Private data | Untrusted content | External communication | Assessment |
|---|---|---|---|
| Yes | Yes | Yes | Redesign: remove a leg, or put a person in front of every outbound action |
| Yes | Yes | No | Workable; check that no tool or rendered output is a hidden outbound channel |
| Yes | No | Yes | Workable if the content really is controlled; review what "controlled" means |
| No | Yes | Yes | Workable for public research tasks; watch for consumption abuse |
"External communication" is broader than an email tool. Willison notes that a tool able to make an HTTP request, to load an image or even to offer the user a link to click, can pass stolen data to an attacker [10]. He is also sceptical of guardrail products that claim to catch most attacks, observing that in web application security "95% is very much a failing grade" [10]. OWASP's improper output handling guidance is relevant here: treat the model "as any other user, adopting a zero-trust approach", and encode its output for the context in which it will be used [4].
Retrieval-augmented generation creates a second database of your content, in the form of embeddings and chunks, and it is easy to build it without the access rules of the first. OWASP warns that weak access controls on embeddings can expose sensitive information, and that in multi-tenant systems sharing a vector database "there's a risk of context leakage between users or queries" [7]. Its recommendations are permission-aware vector stores and logical partitioning of datasets by user group [7].
Two design judgements follow from that guidance. First, apply the permission filter in the retrieval query itself, before ranking, so that chunks the user may not see never reach the model. Filtering the model's answer afterwards is too late, because the model has already read the content. Second, carry the source document's access labels onto every chunk at indexing time, and re-index when permissions change. Tenant isolation patterns more generally are covered in the article on multi-tenant SaaS isolation in this series.
Whatever the model produces will be parsed by something else: a browser, a shell, a database, an email client. OWASP lists remote code execution, cross-site scripting and SQL injection among the results of passing model output on without validation, and recommends parameterised queries for any database operation involving LLM output, context-aware encoding and a strict Content Security Policy [4]. These are ordinary web security controls. The difference is only that the untrusted input arrives from your own model.
An attacker does not need to steal data to cause harm. OWASP's unbounded consumption entry includes "denial of wallet" attacks that run up usage-based bills, and recommends input size limits, rate limits and quotas per user, resource allocation controls, and timeouts [8]. Put these limits in the gateway in front of the model and the tools, and make them per tenant and per user, so that one account cannot exhaust a shared budget. Measuring tokens and tool calls per request is covered in observability for AI applications.
The snippet below is illustrative configuration for a tool gateway, not the format of any specific product. The point is that every rule in it is enforced by code the model cannot edit.
# Illustrative only: policy evaluated by the tool gateway, outside the model.
agent: support-assistant
identity: end_user # tools run with the signed-in user's permissions
tools:
read_ticket:
allow: true
get_order:
allow: true
argument_checks:
order_id: belongs_to_ticket_customer
issue_credit:
allow: true
max_amount: config.credit_cap
require_approval_above: config.credit_approval_threshold
send_email:
allow: false # no outbound channel: breaks the trifecta
limits:
max_tool_calls_per_turn: 10
max_input_tokens_per_request: config.input_token_limit
logging:
record: [tool_name, arguments_hash, decision, approver_id]
| Check | Why |
|---|---|
| No authorisation decision depends on the model's output alone | The model can be steered by text it reads [2][5] |
| No secrets or access rules live only in the system prompt | The prompt is neither secret nor a control [6] |
| Each tool is the narrowest that does the job | Open-ended tools widen the blast radius [5] |
| Tools run with the end user's permissions and audience-bound tokens | Service accounts and passed-through tokens bypass downstream controls [5][9] |
| No agent combines private data, untrusted content and an outbound channel without a person in the loop | That combination enables exfiltration by injected instructions [10] |
| Retrieval filters by permission before ranking | Content the model reads can leak into the answer [7] |
| Model output is encoded or parameterised for its destination | Output handling failures become XSS, SQL injection or RCE [4] |
| Per-user and per-tenant limits exist for tokens and tool calls | Unbounded consumption is a listed risk [8] |
| Prompt-injection tests are part of the regular test suite | OWASP recommends adversarial testing that treats the model as an untrusted user [2] |
None of these controls make prompt injection impossible. Together they limit what a successful one can achieve: the injection reaches a model that holds no secrets, can call few tools, acts only with the user's own rights, and cannot send what it reads anywhere new. Architecture reviews of this kind are part of our enterprise infrastructure and architecture work. Where an application handles regulated or personal data, the legal requirements on top of these engineering controls are a question to take to counsel.
Prepared with AI-assisted research and drafting.
[1] OWASP GenAI Security Project, "OWASP Top 10 for LLM Applications 2025" (list page and the individual entries LLM01:2025 to LLM10:2025 linked from it), OWASP, 2025. https://genai.owasp.org/llm-top-10/
[2] OWASP GenAI Security Project, "LLM01:2025 Prompt Injection", OWASP, 2025. https://genai.owasp.org/llmrisk/llm01-prompt-injection/
[3] K. Greshake, S. Abdelnabi, S. Mishra, C. Endres, T. Holz, M. Fritz, "Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection", arXiv:2302.12173, 2023. https://arxiv.org/abs/2302.12173
[4] OWASP GenAI Security Project, "LLM05:2025 Improper Output Handling", OWASP, 2025. https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
[5] OWASP GenAI Security Project, "LLM06:2025 Excessive Agency", OWASP, 2025. https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
[6] OWASP GenAI Security Project, "LLM07:2025 System Prompt Leakage", OWASP, 2025. https://genai.owasp.org/llmrisk/llm072025-system-prompt-leakage/
[7] OWASP GenAI Security Project, "LLM08:2025 Vector and Embedding Weaknesses", OWASP, 2025. https://genai.owasp.org/llmrisk/llm082025-vector-and-embedding-weaknesses/
[8] OWASP GenAI Security Project, "LLM10:2025 Unbounded Consumption", OWASP, 2025. https://genai.owasp.org/llmrisk/llm102025-unbounded-consumption/
[9] Model Context Protocol, "Security Best Practices", Model Context Protocol documentation, version 2025-11-25, 2025. https://modelcontextprotocol.io/docs/2025-11-25/tutorials/security/security_best_practices
[10] S. Willison, "The lethal trifecta for AI agents: private data, untrusted content, and external communication", simonwillison.net, 2025. https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
[11] OWASP GenAI Security Project, "OWASP Top 10 for Agentic Applications for 2026", OWASP, 2025. https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/