Prompt Injection Defenses for LLM Apps: A Practical Checklist

Prompt injection defenses for LLM apps need depth, not one filter. A checklist covering secrets, tool limits, human approval, guardrails and testing.

By Galactic News Editorial · Published 2026-11-27T11:08:37+00:00 · Updated 2026-11-27T11:08:37+00:00

Prompt injection defenses for LLM apps checklist for developers

Prompt Injection Defenses for LLM Apps: A Practical Checklist

Prompt injection is the top risk in the OWASP Top 10 for LLM applications. An attacker tricks your model into following instructions it was never given. The attack can come from the user or from content the model reads. This checklist gives you practical prompt injection defenses for LLM apps, layer by layer.

What prompt injection is

A language model cannot tell the difference between instructions and data on its own. It reads a system prompt, a user message and retrieved documents in the same context. An attacker exploits that. They write text that the model treats as a command. The model then ignores your instructions and follows theirs.

The impact is real. An injected prompt can make a support bot leak customer data. It can make an agent send emails, delete records or run commands. Microsoft calls indirect prompt injection one of the most widely used techniques in AI security reports it receives. OWASP ranks it first in its LLM Top 10 for 2026.

Direct vs indirect injection

Direct injection comes from the user. The user types a prompt that tells the model to ignore its rules. A common form is a jailbreak. The user asks the model to adopt a new persona with no restrictions. The model may comply if the system prompt is weak.

Indirect injection is sneakier. The attacker hides instructions in content the model will read later. A web page, an email, a document or a database record carries the payload. The user never sees it. The model reads the page to answer a question and follows the hidden instruction instead. The attacker never talks to the model directly.

Both forms share one root cause. Untrusted data and trusted instructions sit in the same context. Every defense below attacks that root cause from a different angle.

Prompt injection defenses LLM apps: the checklist

  1. Keep secrets out of the system prompt. Never put API keys, passwords or internal URLs in prompts. The model can leak them. Enforce access control outside the model, not inside a prompt.
  2. Treat all external content as untrusted data. User input, web pages, emails, tool outputs and retrieved chunks are data, never instructions. Label them as data in the prompt and in your code.
  3. Separate instructions from data. Use clear delimiters and message roles. Extract only the fields you need from untrusted content instead of pasting raw text into the instruction channel.
  4. Limit tool access to the minimum. Give the model only the tools the task needs. Use scoped credentials and short-lived permissions. Replace general shell access with narrow functions.
  5. Require human approval for high-impact actions. Email sends, refunds, database writes and deletions should pause for a person. No model output should trigger them on its own.
  6. Validate every tool argument. Treat each argument the model produces as attacker-controlled. Check types, ranges and allowed values before the tool runs.
  7. Validate and sanitise model output. Treat output as untrusted input before it reaches a browser, a database or another system. Encode it, check it against a schema and strip executable content.
  8. Filter inputs and outputs. Run prompt-attack detection on inputs and content filters on outputs. Use a dedicated guardrail model for the checks, not the main model checking itself.
  9. Control retrieval and memory. Ingest only verified material. Enforce per-user access control on vector stores. Version memory snapshots and log every write so poisoned context can be traced.
  10. Cap cost and volume. Rate-limit requests, cap tokens per call and set spend budgets per user. Unbounded consumption is its own attack and it amplifies every other one.
  11. Test with adversarial prompts. Run direct and indirect injection tests before each major release. Include jailbreaks, hidden instructions in documents and poisoned tool outputs.
  12. Monitor at runtime. Watch for plan drift in multi-step agents, unexpected tool sequences and odd output patterns. Log prompts and tool calls so incidents can be reconstructed.

Tools that help: guardrails and shields

You do not have to build every layer by hand. Microsoft offers Prompt Shields, which detect user-prompt attacks and hidden instructions in documents, emails and web pages. Its guidance pairs shields with spotlighting, which marks untrusted data so the model treats it as data, not commands.

NVIDIA NeMo Guardrails is an open-source library for programmable safety controls. It applies input rails before the model call and output rails after it. It also checks tool calls and tool results. You define the policy in configuration files. The library works in check mode, where your app calls it at each decision point, or in proxy mode, where requests route through it.

Pick tools that fit your stack. A guardrail library suits self-hosted apps. A cloud shield suits teams already on that cloud. Either way, the tool is one layer. It does not replace least-privilege design or human approval.

Testing your defenses

Build a small test set and run it on every release. Include direct jailbreaks. Include a document with a hidden instruction to exfiltrate data. Include a tool output that tells the model to run a different command. Include a RAG chunk that changes the answer's meaning. Record which tests pass and which fail.

Test the failure mode, not just the block. When a defense blocks a prompt, check what the user sees. A silent failure confuses users. A clear refusal keeps trust. When a defense fails, check what the model could actually do. A failed block matters more when the model holds a database password than when it holds a search tool.

Bottom line

No single control stops prompt injection. The defense is depth. Keep secrets out of prompts. Treat external content as data. Limit tools. Gate high-impact actions behind a human. Validate inputs and outputs. Test with real attacks and monitor in production. Assume some attacks will get through and design so a compromised interaction cannot cause broad damage.