Prompt Injection Defense Checklist for LLM Applications
prompt securityLLM securityAI agentsthreat modelingapplication security

Prompt Injection Defense Checklist for LLM Applications

HHiro Solutions Editorial Team
2026-11-30
7 min read

A practical prompt injection defense checklist for LLM apps covering trust boundaries, RAG, tool calling, testing, monitoring, and review triggers.

Prompt injection defense is not a single instruction added to a system prompt. This checklist helps you identify trust boundaries, limit unsafe tool use, handle untrusted content, test realistic attack paths, and decide when an LLM application needs a fresh security review.

Overview

Prompt injection occurs when content influences an LLM to disregard the application’s intended instructions, reveal information, or take an action outside its authorized purpose. The content may come directly from a user, or indirectly from a web page, uploaded document, email, support ticket, database record, or tool result.

The central security principle is simple: treat model input as data, not as a trusted control channel. Delimit content where practical, identify its source, and make authorization decisions in application code rather than asking the model to enforce them by itself. A system prompt can establish useful behavior, but it should not be the only barrier protecting secrets, privileged operations, or sensitive records.

A useful trust-boundary model looks like this:

Untrusted user or external content
        |
        v
Input parsing, classification, and policy checks
        |
        v
LLM reasoning with limited context and explicit instructions
        |
        v
Application authorization and schema validation
        |
        v
Tools, data stores, and external side effects

Every transition deserves its own control. For example, a retrieved document may be safe to summarize but not safe to treat as an instruction. Similarly, an LLM may propose a refund, database query, or email, but a separate service should validate whether the current user and workflow are allowed to perform it.

Prompt injection defense belongs within broader AI application security and reliability work. Prompt changes, retrieval changes, provider migrations, and new tools can alter the application’s behavior even when the user interface remains unchanged.

Checklist by scenario

1. Direct user prompts

  • Define what the assistant is allowed to do and what it must refuse or escalate.
  • Keep secrets, credentials, hidden configuration, and internal policy text out of the model context unless they are genuinely required.
  • Do not rely on phrases such as “never reveal these instructions” as the sole protection for confidential information.
  • Limit the assistant’s response to the user’s authorization scope. A request to help with one account should not expose another account’s data.
  • Log relevant security events without storing unnecessary personal or confidential content.

2. RAG and uploaded documents

  • Label retrieved text as untrusted reference material in the prompt and in application documentation.
  • Separate document content from the system and developer instructions using clear structure and delimiters.
  • Filter retrieval by tenant, user, document permissions, and data classification before content reaches the model.
  • Expect documents to contain instructions such as “ignore previous rules,” fake approval requests, or links to external destinations.
  • Require the application to cite or identify the source of material used for a response when that improves reviewability.
  • Test poisoned documents, conflicting documents, oversized documents, and documents containing hidden or encoded text.

3. Tool calling and agents

  • Give each tool the minimum permissions and narrowest input schema it needs.
  • Use an allowlist for tools, destinations, actions, and data fields rather than allowing arbitrary model-generated calls.
  • Validate arguments in application code, including identifiers, amounts, recipients, URLs, query structure, and file paths.
  • Require confirmation or human review for irreversible, external, financial, administrative, or high-impact actions.
  • Separate planning from execution when a workflow has multiple steps. The model can propose a plan, while a policy layer decides which steps may run.
  • Set time, token, depth, and retry limits to prevent loops, excessive tool use, or unexpected cost.
  • Return only the tool result needed for the next step. Avoid exposing credentials, internal errors, or unrelated records to the model.

4. Structured outputs and APIs

  • Use a strict schema for outputs that drive software behavior.
  • Reject malformed, incomplete, extra, or out-of-range values instead of silently repairing them.
  • Validate the output after generation and before it reaches a tool, database, browser, or user-facing workflow.
  • Keep free-form explanations separate from machine-actionable fields.
  • Define a safe failure state for invalid or ambiguous output.

For implementation patterns, pair this checklist with Structured Output Prompts: JSON Schemas, Validation, and Error Recovery and review how prompt changes are approved in Prompt Versioning for Production AI Apps.

5. Support and business workflows

  • Prevent a customer message from directly changing account status, refund state, permissions, or case priority.
  • Keep identity verification and authorization outside the model.
  • Show staff when a response or recommendation was generated from untrusted material.
  • Provide an escalation path for requests involving legal, financial, safety, privacy, or security consequences.
  • Review prompt templates for support teams whenever business rules or escalation policies change.

What to double-check

Before releasing or materially changing an LLM workflow, walk through these questions with the developer, product owner, and security reviewer:

  1. Where are the trust boundaries? List every source that can enter the context, including user messages, retrieval results, tool outputs, metadata, and conversation history.
  2. Which instructions are actually authoritative? Document the order of application-controlled instructions and identify content that is reference data only.
  3. What can the model cause? Inventory data access, tool calls, messages, file operations, code execution, and changes to external systems.
  4. Who makes the final authorization decision? Confirm that permissions are checked by deterministic application services rather than inferred from model text.
  5. What happens after a refusal? Make sure fallback logic does not accidentally grant broader access or retry the same unsafe action without a new check.
  6. Can you explain an incident? Capture prompt and model versions, tool requests, validation outcomes, relevant source identifiers, and user or workflow context subject to privacy requirements.
  7. Can you roll back safely? Keep prompt, retrieval, tool, and policy changes versioned so a known-good configuration can be restored.

Create a small red-team test set and run it in a non-production environment. Include direct override attempts, requests for hidden instructions, malicious retrieved text, conflicting authority claims, encoded instructions, tool-argument manipulation, and attempts to cross tenant or user boundaries. A reusable test prompt can use this format:

Scenario: [workflow and user role]
Untrusted content: [document, message, or tool result]
Attack objective: [disclose, bypass, or execute]
Expected behavior: [refuse, ignore, ask for confirmation, or escalate]
Required evidence: [log event, blocked tool call, or validation error]

Track both false negatives and false positives. A system that blocks every unusual request may be difficult to use, while a system that answers normally but permits an unsafe tool call has a more serious control failure.

Common mistakes

  • Putting all security in the system prompt: Model instructions guide behavior but do not replace access control, input validation, or tool authorization.
  • Trusting retrieved content: Retrieval improves relevance, not authority. A document can be useful evidence and still contain hostile instructions.
  • Giving tools broad permissions: Narrow tools are easier to validate, monitor, test, and revoke.
  • Checking only the final answer: Unsafe behavior may occur in an intermediate tool call even if the final response looks harmless.
  • Testing only obvious jailbreak language: Real failures may use ordinary business text, poisoned documents, indirect requests, or ambiguous metadata.
  • Logging too little or too much: Without enough context, incidents are hard to investigate; with indiscriminate logging, sensitive data exposure can increase.
  • Changing prompts without regression tests: A wording improvement in one scenario can weaken boundaries in another. Treat prompts as production dependencies and monitor changes as described in AI Output Monitoring.

When to revisit

Run this checklist before launch, during threat modeling, and after any change to prompts, models, retrieval sources, tool permissions, identity flows, or external integrations. Revisit it during seasonal planning cycles when workflows or staffing change, and after an incident or near miss.

A quarterly review is a practical baseline for active applications, with additional reviews after major provider, framework, or application-stack releases. Do not treat the interval as a substitute for change-based review: a new document source or tool can create a new attack path immediately.

For the next review, assign an owner and record four outcomes: the current trust-boundary diagram, the approved tool and permission inventory, the latest red-team test results, and the rollback procedure. If an unsafe response or tool call occurs, preserve the relevant evidence and use an incident process such as the LLM Incident Response Runbook. Then update the test set so the same failure becomes a permanent regression case.

The most durable defense is layered: untrusted inputs remain untrusted, application code enforces authorization, tools are narrowly scoped, outputs are validated, and behavior is tested whenever the surrounding system changes.

Related Topics

#prompt security#LLM security#AI agents#threat modeling#application security
H

Hiro Solutions Editorial Team

AI Systems Reliability Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.