Free tech learning for everyone, from basics to pro

AI & Cyber SecurityEmerging Technologies and SecurityIntermediate

Securing LLM apps: prompt injection and the OWASP Top 10 for LLMs

In short: LLM applications mix instructions and data in the same text, so attackers can hide instructions in input or documents. The OWASP Top 10 for LLM Applications lists the main risks. Defend with least privilege for tools, careful output handling, human approval for risky actions and good monitoring.

Why LLM apps need their own security thinking

A large language model (LLM) reads text and predicts a useful continuation. Applications wrap it with a system prompt (the developer’s instructions), user input, and often extra data pulled from documents or the web, known as retrieval-augmented generation (RAG). Many apps also let the model call tools: send email, query a database, run code. The core problem is that the model cannot reliably tell trusted instructions from untrusted data, because everything arrives as text.

Where an LLM app can be attackedUser inputdirectinjectionRetrieveddataindirectinjectionModelleaks, misuseOutputunsafehandlingTools / APIsexcessiveagency
Figure 1. Data flows through several stages in an LLM application, and each stage needs its own control.

Prompt injection

Direct prompt injection is when a user types instructions designed to override the system prompt, for example asking a support bot to ignore its rules and reveal internal notes. Indirect prompt injection is more dangerous: the instructions are hidden in content the model processes on someone else’s behalf, such as a web page, an email or a shared document. If an assistant that can send email summarises a poisoned message, the hidden text might tell it to forward private data elsewhere.

There is no complete fix today. Input filters and stronger system prompts help, but determined attackers find new wording. The reliable approach is to limit what a successful injection can do.

The OWASP Top 10 for LLM Applications

The OWASP project publishes a list of the most important risks for LLM applications. The 2025 edition covers:

RiskIn plain terms
LLM01 Prompt InjectionInput changes the model’s behaviour against the developer’s intent
LLM02 Sensitive Information DisclosureThe app reveals personal, secret or confidential data
LLM03 Supply ChainRisky third-party models, datasets, plug-ins or libraries
LLM04 Data and Model PoisoningTampered training or fine-tuning data plants bad behaviour
LLM05 Improper Output HandlingModel output used unchecked in HTML, SQL, shell or code
LLM06 Excessive AgencyThe model has more tools, permissions or autonomy than it needs
LLM07 System Prompt LeakageSecrets or logic placed in the system prompt are exposed
LLM08 Vector and Embedding WeaknessesFlaws in RAG stores, such as poisoned or over-shared documents
LLM09 MisinformationConfident but false output that people or systems trust
LLM10 Unbounded ConsumptionAbuse that drives up cost or denies service

Practical controls

Layered controls for LLM appsGovernanceuse policy, risk reviewInput controlsfilters, separationLeast privilegescoped tools, approvalsOutput handlingvalidate, encodeMonitoringlogs, abuse detection
Figure 2. No single filter stops prompt injection, so LLM apps rely on several layers of defence.
  • Least privilege for tools: give the model narrow, read-only functions where possible, using the end user’s own permissions, never a shared admin account.
  • Human approval for high-impact actions such as sending external email, making payments or deleting data.
  • Treat output as untrusted: encode before showing in a web page, use parameterised queries, never pass output straight to a shell.
  • No secrets in prompts: keep API keys and access rules in code and back-end checks, not in the system prompt.
  • Access control in RAG: only retrieve documents the current user is allowed to read.
  • Limits and monitoring: rate limits, token budgets, logging of prompts and tool calls, and alerts on abuse.

Tip: test your own LLM app with red-team prompts in a non-production environment and with permission. Record which attacks succeeded and fix the design, not just the wording.

Practice

What is the difference between direct and indirect prompt injection?
Direct injection comes from the user’s own input; indirect injection is hidden in content the model processes, such as a web page, email or document.
Why should API keys never be placed in a system prompt?
System prompts can leak through clever questioning (LLM07), so secrets there may be exposed. Keep them in back-end code and enforce access there.
An assistant can delete files when asked. Which OWASP LLM risk applies and how do you reduce it?
Excessive agency (LLM06). Remove the delete tool if not needed, scope permissions to the user, and require human approval for destructive actions.

Key takeaways

  • LLMs cannot reliably separate instructions from data, so prompt injection is a design risk.
  • Indirect injection hides instructions in documents, emails or web pages the model reads.
  • The OWASP Top 10 for LLM Applications gives a shared list of risks to review.
  • Limit the blast radius: least-privilege tools, human approval, no secrets in prompts.
  • Treat model output as untrusted input to every downstream system.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.