arrow_forwardGuides / LLM Security
Updated June 2026 22 min read AI security · OWASP

Securing LLM — OWASP Top 10
The ten critical risks in AI applications and how to defend against them

As LLM-based applications move into production, the attack surface grows. This guide walks through the OWASP Top 10 for LLM Applications (2025) — the ten critical risks — with an explanation, an example and a defense for each.

OWASP 2025
The standard
10
Critical risks
Secure by Design
Approach

Why LLM security is different from regular security

LLM-based applications present a new attack surface that traditional application security doesn't cover. Three main reasons: the model is non-deterministic (the same input can produce different outputs), instructions and data share a single channel (everything is text in the same context window — so it's hard to separate a "command" from "data"), andagents can take actions in the real world (read emails, run code, access an API).

To give these risks a common language, the OWASP Gen AI Security project maintains the OWASP Top 10 for LLM Applications — a list of the ten most critical risks. The 2025 edition is the basis for this guide. For each risk we'll explain what it is, a short example, and how to defend against it.

How to use this guide: This is an umbrella guide. The two hottest topics — Prompt Injection and Jailbreak — get full, separate guides. Here you get the complete picture of all 10 risks.

The ten risks at a glance

# The risk In brief
LLM01Prompt InjectionHostile input that changes the model's behavior
LLM02Sensitive information disclosureLeaking PII/secrets through the output
LLM03Supply chainMalicious models, datasets and plugins
LLM04Data and model poisoningContaminating training/RAG data
LLM05Improper output handlingBlind trust in output → XSS/SQLi/RCE
LLM06Excessive agencyToo many permissions/autonomy for an agent
LLM07System Prompt leakageRelying on the prompt's secrecy
LLM08Vector/Embedding weaknessesCross-tenant leakage in RAG
LLM09MisinformationHallucinations and over-reliance
LLM10Unbounded consumptionDenial-of-Wallet, resource exhaustion

LLM01 · Prompt Injection

The #1 vulnerability. An attacker injects instructions — directly in the user input, or indirectly through external content the model reads (a web page, PDF, email, tool/MCP description) — and makes the model bypass the developer's instructions. In AI agents with tool access this leads to malicious actions being performed.

Defense: An instruction hierarchy, separating instructions from data, least-privilege permissions for tools, human-in-the-loop for dangerous actions. The full, in-depth Prompt Injection guide → · Related: Jailbreak.

LLM02 · Sensitive information disclosure

The model exposes PII, secrets, keys or proprietary information — through the output, through stored training data, or through context that leaked between users. Example: a chatbot that returns another customer's details because the information got into the context.

Defense: Data minimization, filtering and sanitizing the output, context-based access control, and don't put secrets in the prompt.

LLM03 · Supply Chain

Models, datasets, plugins, adapters and LoRAs from third parties may be poisoned or vulnerable. A model downloaded from an untrusted repo may contain a backdoor.

Defense: Provenance verification, signatures, an "SBOM for models", vetting components before integration, and version pinning.

LLM04 · Data and model poisoning

An attacker contaminates training, fine-tuning or RAG sources to bias the model's behavior or plant hidden triggers. In RAG systems, a poisoned document that enters the index can affect future answers.

Defense: Vetting sources, anomaly monitoring, maintaining data integrity, and isolating untrusted sources.

LLM05 · Improper Output Handling

One of the common mistakes: treating the model's output as trusted. If you inject output directly into HTML, an SQL query or a shell — you create XSS, SQL Injection or even RCE vulnerabilities. The output is untrusted input for the next system in the chain.

Defense: Context-based encoding/escaping, validating the output, and don't run model output directly without a sandbox.

LLM06 · Excessive Agency

An agent that was given too many permissions, tools or autonomy. When combined with indirect injection, you get a "confused deputy" — the agent uses its permissions on the attacker's behalf. This is the vector behind the 2026 RCE incidents in agentic coding tools.

Defense: The least-privilege principle, minimal, well-defined tools, an allowlist for actions, and human approval for destructive actions. The full AI agent security guide →

LLM07 · System Prompt leakage

The system prompt can almost always be extracted (prompt leaking). The mistake is relying on its secrecy or storing secrets/keys/permission logic in it.

Defense: Assume the prompt will leak. Don't put secrets in it, and enforce permissions on the server side — not in the prompt.

LLM08 · Vector and Embedding Weaknesses (RAG)

In RAG systems: inverting embeddings to reconstruct the original text, cross-tenant leakage when there's no isolation, and poisoned vectors in the index. One tenant's query may retrieve another tenant's documents.

Defense: Tenant isolation, access control at the retrieval stage, and validating content that enters the index. Related: RAG guide.

LLM09 · Misinformation

The model produces self-confident but incorrect content (hallucinations), and users rely on it without checking. In sensitive contexts (medical, legal, financial) this is a real risk.

Defense: Grounding (grounding/RAG) with source citation, human verification, and presenting uncertainty instead of fabrication.

LLM10 · Unbounded Consumption

Attacks that exploit the cost of inference: "Denial-of-Wallet" (flooding with expensive requests), resource exhaustion, and model extraction through a large number of queries.

Defense: Rate limiting and quotas, cost monitoring, limiting input/output size, and detecting anomalous usage patterns.

A secure architecture for LLM

Good defense is defense in depth — no single layer is enough. Here's what a secure request flow looks like, with controls at every trust boundary:

User input → an input classifier (prompt guard) + sanitization
Prompt → an instruction hierarchy (system > developer > user > tool)
External content / RAG → marking as untrusted + content boundaries + tenant isolation
Tools / agent → least privilege + sandbox + an allowlist for egress
Model output → an output classifier/moderation + context-based encoding
A sensitive action → human approval (HITL) + logs + monitoring

Additional layers: canary tokens to detect leaks, secrets management, and a second guard model (dual-LLM) to check input/output.

Red Teaming and Evaluation

LLM security is an ongoing process, not a one-off check. Build a test suite that covers all ten risks, measure Attack Success Rate (ASR), and run regression after every model or prompt change. Combine automated tests with human review, and monitor in production.

Responsibility: Only test systems you own or for which you have explicit authorization. Responsible red-teaming is meant to improve defense — not exploit it.

LLM security checklist

check_circleTreat all external content as untrusted
RAG, web, PDF, email, tool descriptions and MCP — all potentially hostile input.
check_circleEncode and validate all output (LLM05)
The model output = untrusted input for the next system.
check_circleLeast privilege for agents (LLM06)
Minimal tools + HITL for destructive actions.
check_circleTenant isolation in RAG (LLM08)
Access control at the retrieval stage, not just in the display.
check_circleDon't put secrets in the system prompt (LLM07)
Assume it will leak; enforce permissions on the server side.
check_circleRate limits, quotas and cost monitoring (LLM10)
Prevent Denial-of-Wallet and resource exhaustion.
check_circleVet the supply chain (LLM03)
Verify the provenance of models, datasets and plugins.
check_circleSecurity tests on every release
Regression on all 10 risks + monitoring in production.
security

Deepen the defense

Now that you have the full risk map — dive into the two most critical topics, and build complete protection for your applications and agents.