Prompt Injection Prevention for LLM Apps: Threats, Tests, and Defense Checklist
prompt securityAI safetyLLM appsthreat modelingprompt injection

Prompt Injection Prevention for LLM Apps: Threats, Tests, and Defense Checklist

PPromptCraft Labs
2026-11-29
6 min read

A practical prompt injection prevention checklist covering direct and indirect attacks, tool permissions, testing, validation, and human approval.

Prompt injection prevention is a design and testing problem, not something solved by adding one stronger instruction to a system prompt. This checklist explains how to identify direct and indirect attacks, define trust boundaries, restrict tool access, validate outputs, add human approval, and retest an LLM application whenever its model, data, tools, or workflow changes.

Overview

Prompt injection occurs when untrusted content influences an LLM to disregard, reinterpret, or bypass the instructions that govern an application. The content may come from a user, a web page, an uploaded document, an email, a database record, or another model. The risk becomes more serious when the model can retrieve private information, call APIs, modify records, send messages, or trigger other actions.

There are two useful categories. Direct injection is supplied by the person interacting with the application. For example, a user may ask a support assistant to reveal its hidden instructions, ignore its task restrictions, or perform an unauthorised action. Indirect prompt injection is hidden in material the application retrieves or processes. A web page, document, ticket, or calendar entry might contain instructions aimed at the model rather than information relevant to the user’s request.

Neither category should be treated as a normal prompt-engineering problem. A well-written prompt can establish intent and priorities, but it cannot create a reliable security boundary by itself. Protecting an AI application requires controls around the model: least-privilege tools, separate data permissions, structured inputs and outputs, monitoring, testing, and a safe response when uncertainty is detected.

Start by mapping the application’s trust boundaries. Record who supplies each input, whether it is trusted, what the model is allowed to do with it, and which actions require approval. For a wider review of permissions and approval flows, see the AI agent tool-calling design guide.

Checklist by scenario

1. Chat and user-facing assistants

  • Define the assistant’s permitted purpose in plain language and in enforceable application logic.
  • Treat user messages as untrusted data, even when the user is authenticated.
  • Do not place secrets, credentials, private policies, or unnecessary personal data in the model context.
  • Limit responses to the user’s authorised records rather than relying on the model to decide what the user may see.
  • Test requests to reveal hidden instructions, impersonate an administrator, change the assistant’s role, or bypass refusal rules.
  • Return a controlled response when the request falls outside the supported task instead of asking the model to improvise.
  • Classify retrieved text as reference material, not as an instruction source.
  • Keep document permissions in the retrieval layer and apply them before content reaches the model.
  • Test documents containing phrases such as “ignore previous instructions”, fake system messages, or requests to expose context.
  • Separate citations and source text from executable workflow instructions.
  • Validate that the answer uses relevant evidence and does not follow commands embedded in a source.

For quality and regression testing, pair security cases with ordinary answer-quality cases. The LLM evaluation guide provides a useful framework for maintaining test cases, expected behaviour, and review results.

3. Tool-using agents

  • List every tool, its purpose, the data it can access, and the side effects it can cause.
  • Give the model the smallest possible permission set. A read-only search tool should not also be able to edit, delete, or send.
  • Validate tool arguments against a strict schema and reject unknown fields, malformed values, and unexpected destinations.
  • Apply authorisation checks outside the model before each sensitive operation.
  • Require explicit human approval for irreversible, financial, external-communication, or high-impact actions.
  • Use limits for volume, frequency, destination, and spending where appropriate, and stop repeated failures rather than retrying indefinitely.

4. Content and operations workflows

  • Keep imported copy, customer data, instructions, and approval notes in separate fields.
  • Do not allow generated text to publish, email, or overwrite a source record without a separate workflow decision.
  • Show reviewers the source material, proposed output, and any action the system wants to take.
  • Log prompt versions, tool calls, approvals, refusals, and errors without retaining more sensitive data than necessary.
  • Use the AI content workflow audit template to review accuracy, SEO requirements, and human checkpoints together.

What to double-check

Before deployment, write a short threat model that answers five questions:

  1. What is the asset? Identify private data, credentials, customer records, business decisions, system availability, and external reputation.
  2. Who can influence the context? Include users, uploaded files, retrieved pages, connected services, administrators, and upstream models.
  3. What can the model cause? List data disclosure, tool calls, edits, deletion, messages, purchases, scheduling, and access changes.
  4. Which control stops each failure? Assign the control to code, identity and access management, retrieval, validation, a human reviewer, or monitoring. Avoid assigning every responsibility to the prompt.
  5. What happens after a failure? Define how the action is blocked, the incident is recorded, credentials are reviewed, and the affected workflow is restored.

Check that output validation is meaningful. A JSON schema can confirm structure, but it does not prove that a destination, recipient, query, or proposed action is safe. Validate semantics as well as syntax. For example, confirm that an email recipient is permitted, a database operation is read-only when required, and a requested record belongs to the current user.

Also check logging and privacy. Logs should support investigation without becoming a second source of sensitive exposure. Review which prompts, retrieved documents, tool arguments, and outputs are retained, who can access them, and how long they are needed. The LLM data privacy checklist can help structure this review.

Common mistakes

  • Relying on a system prompt as a security boundary: use application permissions and independent validation for security decisions.
  • Treating retrieved content as trusted: retrieval improves context, but source text may contain malicious or irrelevant instructions.
  • Giving agents broad credentials: separate read and write capabilities, use scoped identities, and remove unused tools.
  • Testing only obvious attacks: include paraphrases, encoded text, long instructions, mixed languages, attachments, and multi-step attempts.
  • Approving the first successful test: record expected behaviour and repeat the full suite after prompt, model, tool, retrieval, or permission changes.
  • Hiding automation from reviewers: make proposed actions, evidence, uncertainty, and approval requirements visible.
  • Ignoring operational limits: rate limits, timeouts, retry caps, and emergency disable controls reduce the impact of unexpected behaviour.

When to revisit

Run the checklist before the first production release and whenever the workflow or its inputs change. Revisit it after a model change, prompt revision, new retrieval source, new tool, permission update, API integration, or change to human approval rules. It is also useful before seasonal planning cycles when content volumes, scheduled jobs, or business processes may change.

Keep a small regression set with direct injection, indirect injection, data-access, tool-use, and ordinary task examples. Record the application version, prompt version, model configuration, expected result, observed result, and reviewer decision. If a test fails, reduce permissions or add a deterministic control before attempting to improve the wording of the prompt.

As a final pre-deployment check, confirm that: untrusted inputs are labelled and isolated; retrieval permissions are enforced outside the model; tools use least privilege; arguments and outputs are validated; sensitive actions have approval gates; logs support investigation; rate and retry limits are active; and there is a tested way to disable a tool or workflow. Repeat the checks after every meaningful change, not just on a fixed calendar. Prompt injection prevention is strongest when it is maintained as part of normal LLM evaluation, release review, and incident learning.

Related Topics

#prompt security#AI safety#LLM apps#threat modeling#prompt injection
P

PromptCraft Labs

AI Development and Security 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.