AI Security · Engineering guide
Securing LLM Applications: Prompt Injection, the OWASP Top 10, Red Teaming, and API Gateways
The current OWASP list for LLM applications is the 2025 edition, and its first entry is still prompt injection — a class OWASP itself says has no fool-proof prevention. This guide works from that admission: what the platform guardrails from AWS, Microsoft, and Anthropic actually screen (and what their own docs say they skip), which architectural controls survive a bypassed filter, how to red-team the result, and what belongs at the API edge.
In this guide · 7 steps
- 01Build against the list that exists
- 02Prompt injection: two threat models, one root cause
- 03What the platform guardrails do — and what their own docs say they miss
- 04The controls that hold when the filter is bypassed
- 05Red teaming: making the failure reproducible
- 06The API edge: rate limits, Denial of Wallet, and the gateway
- 07How to apply this
Application-layer AI security starts from an uncomfortable premise, and OWASP states it plainly: "it is unclear if there are fool-proof methods of prevention for prompt injection."[1] Every control below is therefore impact-limiting, not preventive. Architect on the assumption that an injection eventually lands, and spend your budget on what the model is allowed to *do* once it does.
This guide covers attacks on what the model does inside your application: injected instructions, unsafe handling of model output, over-broad tool permissions, leaked system prompts, and abuse at the API edge. It deliberately excludes attacks on the model as an artifact — malicious checkpoint files, dependency compromise, weight theft, training-data extraction — which are a different surface with different owners and different tooling, covered separately in the model-security guide linked at the foot of this page.
1. Build against the list that exists
The OWASP Gen AI Security Project publishes the Top 10 for LLM and generative-AI applications. As of August 2026 the current edition is the 2025 list, and the previous edition is the 2023/24 list; both are published side by side on the project's own site.[2][3] If a vendor deck, a training module, or an AI-written explainer cites a different year, ask which page it came from — the project publishes each edition, its translations, and its version history openly, so the claim is checkable in about a minute.
| # | 2023/24 edition | 2025 edition (current) |
|---|---|---|
| 01 | Prompt Injection | Prompt Injection |
| 02 | Insecure Output Handling | Sensitive Information Disclosure |
| 03 | Training Data Poisoning | Supply Chain |
| 04 | Model Denial of Service | Data and Model Poisoning |
| 05 | Supply Chain Vulnerabilities | Improper Output Handling |
| 06 | Sensitive Information Disclosure | Excessive Agency |
| 07 | Insecure Plugin Design | System Prompt Leakage |
| 08 | Excessive Agency | Vector and Embedding Weaknesses |
| 09 | Overreliance | Misinformation |
| 10 | Model Theft | Unbounded Consumption |
There is no 2026 edition to build against
The Top 10 landing page on genai.owasp.org offers exactly two editions — 2025 and 2023/24 — and its document-versions section lists 2025 translations, not a newer list.[2] The project's own sitemap for LLM risk pages says the same thing from the other direction: it lists the landing page plus ten risk entries, every one of them stamped 2025.[4] Content claiming to summarize "the OWASP LLM Top 10 2026" is describing a document the project has not published; the year is usually borrowed from OWASP's separate agentic-security work, which is a different effort from this list. That matters operationally: a security-training module or a control mapping built on an invented list will contain invented control names, and nobody downstream can trace them back to a source.
Two 2025 entries have no counterpart by title in the previous edition: System Prompt Leakage (LLM07:2025) and Vector and Embedding Weaknesses (LLM08:2025) — the second of which is why RAG retrieval security now sits inside the Top 10 rather than beside it. Two 2023/24 titles no longer appear as standalone entries: *Insecure Plugin Design* and *Model Theft*. Model theft has not been dropped as a concern, though: the 2025 Unbounded Consumption entry lists "Model Extraction via API" and "Functional Model Replication" among its own vulnerability examples, so extraction is now framed as a consumption problem rather than a separate risk.[5] Retitle your control mappings accordingly; do not assume old and new numbers line up.
2. Prompt injection: two threat models, one root cause
OWASP splits the class in two. Direct prompt injections "occur when a user's prompt input directly alters the behavior of the model in unintended or unexpected ways," while indirect prompt injections "occur when an LLM accepts input from external sources, such as websites or files" whose content, once interpreted, alters model behavior.[1] The distinction is not academic — it decides who your adversary is. In the direct case the user of your application is the attacker. In the indirect case the user is a victim, and the attacker is whoever can influence a web page, an inbound email, a shared document, or a tool response your agent reads on that user's behalf.
The indirect case is the one that surprises architecture reviews, because it turns ordinary product features into attack surface. The 2023 paper that named the technique, Greshake et al.'s "Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection," describes adversaries who "remotely exploit LLM-integrated applications by strategically injecting prompts into data likely to be retrieved," with impacts the authors characterize as acting "as arbitrary code execution, manipulate the application's functionality, and control how and if other APIs are called."[6] Anything your system retrieves — a crawled page, an OCR'd upload, a wiki space, a tool result — is a delivery channel.
OWASP also notes that the input need not be legible to a person: "These inputs can affect the model even if they are imperceptible to humans, therefore prompt injections do not need to be human-visible/readable, as long as the content is parsed by the model."[1] That single sentence rules out human review as a control for high-volume ingestion, and it is why multimodal pipelines widen the problem rather than narrow it — OWASP's own scenario list includes a malicious prompt embedded in an image that accompanies benign text.
Given the stochastic influence at the heart of the way models work, it is unclear if there are fool-proof methods of prevention for prompt injection.
Read that as a design constraint, not a counsel of despair. It says: do not buy a control whose value proposition is that injection stops. Buy controls that cap the blast radius — and note that OWASP's own mitigation list is dominated by architecture, not filtering. Of its seven prevention measures, only one is input and output filtering; the rest are constraining model behavior in the system prompt, validating output formats with deterministic code, enforcing least privilege by giving the application its own API tokens instead of exposing them to the model, requiring human approval for high-risk actions, segregating and clearly labeling external content, and adversarial testing that treats the model as an untrusted user.[1]
3. What the platform guardrails do — and what their own docs say they miss
All three major platforms ship a screening product or a documented pattern. Their value is real and their limits are documented — in each case by the vendor, on the same page that describes the feature. Read the limitations section before you budget for the feature, because that is where the residual risk you are still carrying is written down — Azure's Prompt Shields page, for instance, closes with "Prompt Shields may not catch all attack vectors or may flag legitimate prompts. Always implement additional validation layers," and notes that its models are trained and tested on eight languages, so a multilingual product inherits uneven coverage.[7]
| Control | What it screens | Documented limitation you inherit |
|---|---|---|
| Amazon Bedrock Guardrails — prompt attack filter | Jailbreaks, prompt injection, and (Standard tier only) prompt leakage, at NONE / LOW / MEDIUM / HIGH strength[^aws-bedrock-prompt-attack] | Only content inside the guardrail input tags is evaluated, and "if there are no tags, prompt attacks for those use cases will not be filtered." Tool results and tool definitions are explicitly out of scope.[^aws-bedrock-prompt-attack] |
| Azure AI Content Safety — Prompt Shields | Two classes: User Prompt attacks (rule changes, conversation mockups, role-play, encoding attacks) and Document attacks embedded in third-party content[^azure-prompt-shields] | "Prompt Shields may not catch all attack vectors or may flag legitimate prompts. Always implement additional validation layers." Models are trained and tested on eight languages.[^azure-prompt-shields] |
| Anthropic — documented application pattern | Harmlessness screens run on a lightweight model, input validation, hardened system prompts, and screening of tool output before the main model acts on it[^anthropic-mitigate-injection] | It is a pattern you implement, not a managed service: the screening calls, the JSON encoding of untrusted strings, and the least-privilege tool scoping are your code, your latency, and your bill.[^anthropic-mitigate-injection] |
is what Bedrock's prompt attack filter does with tool results: "Content in messages[].content[].toolResult is not assessed for prompt attacks, and neither are the tool definitions in toolConfig.tools[].toolSpec." For an agent, that is precisely the channel indirect injection arrives on.[^aws-bedrock-prompt-attack]
Amazon Bedrock Guardrails documentation
The tagging requirement is a live misconfiguration risk
Bedrock's docs are explicit that a prompt attack and a developer system prompt look alike, so you must mark user input with input tags to separate them: "You must always use input tags with your guardrails to indicate user inputs in the input prompt while using InvokeModel and InvokeModelWithResponseStream API operations for model inference. If there are no tags, prompt attacks for those use cases will not be filtered."[8] A guardrail that is attached, enabled, and silently filtering nothing is worse than no guardrail, because it shows green on the control review. Test it with a known-blocked payload after every prompt-template change.
Notice what the three approaches agree on, since agreement across competitors is the closest thing to consensus this field has: untrusted content must be structurally distinguishable from your instructions — Bedrock does it with input tags, Azure with a separate document-screening path, Anthropic with tool-result placement and JSON encoding. If your prompt assembly concatenates retrieved text into one undifferentiated string, no screening product can fully compensate, because you have destroyed the boundary each of them depends on.
4. The controls that hold when the filter is bypassed
Excessive Agency (LLM06:2025) is where an injection becomes an incident. OWASP defines it as "the vulnerability that enables damaging actions to be performed in response to unexpected, ambiguous or manipulated outputs from an LLM, regardless of what is causing the LLM to malfunction," and roots it in three failures: "excessive functionality; excessive permissions; excessive autonomy."[10] Its worked example of excessive functionality is the one to take to your next design review: a team needs an agent that can read documents from a repository, and adopts a third-party extension that also happens to expose modify and delete. The agent never needed write access; the integration handed it over anyway.
Improper Output Handling (LLM05:2025) is a familiar web vulnerability class wearing new clothes. OWASP defines it as "insufficient validation, sanitization, and handling of the outputs generated by large language models before they are passed downstream to other components and systems," and warns that because "LLM-generated content can be controlled by prompt input, this behavior is similar to providing users indirect access to additional functionality." The listed consequences are entirely conventional — "XSS and CSRF in web browsers as well as SSRF, privilege escalation, or remote code execution on backend systems" — as are the examples: model output piped into exec or eval, generated SQL executed without parameterization, generated paths used without sanitization.[11] Your existing appsec controls apply directly. Treat the model as an untrusted client that happens to sit inside your perimeter, and the encoding, parameterization, and allowlisting rules you already enforce cover most of this entry.
System Prompt Leakage (LLM07:2025) is the entry most likely to be mis-prioritized, and OWASP is blunt about why: "the system prompt should not be considered a secret, nor should it be used as a security control," and "disclosure of the system prompt itself does not present the real risk — the security risk lies with the underlying elements."[12] The failure it points at is architectural. If leaking your prompt is damaging, it is because the prompt contained credentials or connection strings, or because the application delegated authorization to the model instead of enforcing it in code. Fix that, and the leak becomes an embarrassment rather than a breach. OWASP also notes the practical ceiling on secrecy here: even without the exact wording, "attackers interacting with the system will almost certainly be able to determine many of the guardrails and formatting restrictions."[12]
of Excessive Agency, per OWASP: excessive functionality, excessive permissions, excessive autonomy. All three are fixed in your integration layer and your access policy — none are fixed by a better model or a stricter content filter.[^owasp-llm06]
OWASP LLM06:2025 Excessive Agency
For threat modeling that goes beyond the Top 10's ten headings, NIST's adversarial machine-learning taxonomy gives a common vocabulary for attack types and mitigations spanning both the application and model layers, and it is the reference most enterprise AI risk programs can already anchor inside their existing NIST framing.[13]
5. Red teaming: making the failure reproducible
OWASP's seventh mitigation is to "perform regular penetration testing and breach simulations, treating the model as an untrusted user to test the effectiveness of trust boundaries and access controls."[1] Two open-source tools make that repeatable rather than artisanal. NVIDIA's garak describes itself as an LLM vulnerability scanner that "checks if an LLM can be made to fail in a way we don't want" and "probes for hallucination, data leakage, prompt injection, misinformation, toxicity generation, jailbreaks, and many other weaknesses," combining "static, dynamic, and adaptive probes"; it is Apache-2.0 licensed.[14] Microsoft's PyRIT — the Python Risk Identification Tool for generative AI — is "an open source framework built to empower security professionals and engineers to proactively identify risks in generative AI systems," MIT-licensed.[15] PyRIT is published under the microsoft GitHub organization; if a runbook or CI job in your estate still points at an older location, repoint it at the repository cited here before you rely on its output.[15]
Scanners test the model. They do not test your application, and that gap is where most enterprise red-team value sits. Anthropic's guidance is explicit that the exercise must run end to end: "before deploying, test your workflow with documents, emails, and tool outputs that deliberately contain injection attempts, and confirm that Claude ignores them and that your screening and confirmation steps catch the rest."[9] The deliverable is not a pass rate. It is a set of reproducible cases — payload, entry point, observed downstream effect — that become regression tests in CI, so that a prompt-template edit or a model upgrade cannot silently reopen a finding you already closed.
6. The API edge: rate limits, Denial of Wallet, and the gateway
Unbounded Consumption (LLM10:2025) is the entry that turns an availability problem into a finance problem. OWASP names the pattern Denial of Wallet (DoW): "by initiating a high volume of operations, attackers exploit the cost-per-use model of cloud-based AI services, leading to unsustainable financial burdens on the provider and risking financial ruin."[5] Its other listed vectors are just as practical — variable-length input floods, continuous input overflow past the context window, and deliberately resource-intensive queries. Its mitigations start where you would expect: strict input size validation, rate limiting and user quotas, timeouts and throttling, dynamic resource-allocation management, and limits on queued actions.[5]
One mitigation is easy to overlook and cheap to apply: "restrict or obfuscate the exposure of logit_bias and logprobs in API responses. Provide only the necessary information without revealing detailed probabilities."[5] Token-level probabilities are useful to your evaluation harness and useful to an attacker building a shadow model. Return them to internal callers if you need them; do not pass them through to a public surface by default.
Upstream limits are not your quota system. OpenAI documents rate limits measured in RPM (requests per minute) and TPM (tokens per minute) alongside images-per-minute and audio-minutes-per-minute for some models, notes that "rate limits can be hit across any of the options depending on what occurs first," defines them at the organization and project level, graduates accounts through usage tiers as API spend rises, and returns remaining requests and tokens in the response headers.[16] All of that protects the provider's infrastructure and puts a ceiling on your bill — none of it stops one tenant of your application from consuming the whole organization-level quota. Per-tenant limits are yours to build.
What a gateway is actually for
A proxy in front of the provider API earns its complexity when it centralizes four things you would otherwise reimplement per service: credential custody, so application code never holds a provider key; per-tenant quota and spend caps, which the provider's organization-level limits cannot express; a single enforcement point for the input and output screening described above; and one audit log of prompts, tool calls, and responses for incident response. Buy or build it for those. Do not buy it as a prompt-injection prevention layer — no product can honestly sell that, for the reason OWASP states.
7. How to apply this
LLM application security baseline
- Map your controls to the 2025 OWASP entry titles, not to 2023/24 numbers — the two editions do not line up, and two 2025 entries (System Prompt Leakage, Vector and Embedding Weaknesses) have no prior counterpart.
- Make untrusted content structurally distinguishable everywhere it enters: Bedrock input tags, the Prompt Shields document path, or tool_result blocks carrying JSON-encoded payloads. Never concatenate retrieved text into the instruction string.
- Verify your guardrail actually fires after every prompt-template change by sending a known-blocked payload — an untagged Bedrock guardrail filters nothing while still reporting as enabled.
- Screen tool and retrieval output, not just user input, with a lightweight classifier before the main model acts on it; the managed prompt-attack filters may not cover that channel.
- Audit every tool and extension the model can invoke for excessive functionality, permissions, and autonomy; strip write and delete scopes the workflow does not need, and give the application its own API tokens rather than exposing them to the model.
- Require human approval for high-risk actions — payments, external sends, destructive operations — and enforce it in code, outside the model's control.
- Apply your existing appsec controls to model output as untrusted input: context-appropriate encoding, parameterized queries, path allowlisting, and no exec or eval of generated content.
- Remove every credential, connection string, and authorization rule from system prompts; enforce authorization in the application, and treat the system prompt as public.
- Suppress logprobs and logit_bias on externally reachable endpoints unless a specific consumer requires them.
- Impose per-tenant rate limits, input size caps, timeouts, and spend ceilings of your own — provider RPM/TPM limits are organization-wide and will not isolate one abusive tenant.
- Run garak or PyRIT against the model and a scripted end-to-end injection suite against the application; convert every finding into a regression test that runs in CI on prompt and model changes.
- Log prompts, tool calls, and responses to one place, and monitor outputs continuously for signs of successful injection so detections feed back into your filters and prompts.
The other half: securing the model itself
Supply-chain attacks on checkpoint files, model theft through your own API, training-data extraction, and the scanning and provenance controls that close each gap.
Retrieval layer: securing enterprise RAG
Document-level access control, multi-tenant isolation, and vector-store security — the surface OWASP's Vector and Embedding Weaknesses entry points at.
Runtime layer: agent governance
Least-privilege scoping, approval gates, and audit for agents — the operating model that turns the Excessive Agency controls above into a repeatable process.
Sources
Every quantitative or attributed claim above is linked to a primary source. Last verified at publication.
- [1]LLM01:2025 Prompt InjectionOWASP Gen AI Security Project · accessed
- [2]2025 Top 10 Risk & Mitigations for LLMs and Gen AI AppsOWASP Gen AI Security Project · accessed
- [3]OWASP Top 10 for LLM Applications 2023/24OWASP Gen AI Security Project · accessed
- [4]LLM risk page sitemap (genai.owasp.org)OWASP Gen AI Security Project · accessed
- [5]LLM10:2025 Unbounded ConsumptionOWASP Gen AI Security Project · accessed
- [6]Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt InjectionarXiv (Greshake, Abdelnabi, Mishra, Endres, Holz, Fritz) · · accessed
- [7]Prompt Shields in Azure AI Content SafetyMicrosoft Learn · accessed
- [8]Detect prompt attacks with Amazon Bedrock GuardrailsAmazon Web Services · accessed
- [9]Mitigate jailbreaks and prompt injectionsAnthropic · accessed
- [10]LLM06:2025 Excessive AgencyOWASP Gen AI Security Project · accessed
- [11]LLM05:2025 Improper Output HandlingOWASP Gen AI Security Project · accessed
- [12]LLM07:2025 System Prompt LeakageOWASP Gen AI Security Project · accessed
- [13]
- [14]NVIDIA/garak — LLM vulnerability scannerNVIDIA (GitHub) · accessed
- [15]microsoft/PyRIT — Python Risk Identification Tool for generative AIMicrosoft (GitHub) · accessed
- [16]Rate limits — OpenAI APIOpenAI · accessed