Prompt Injection Testing Guide: A Practical Checklist for AI Applications
prompt-injectionai-securityllm-securityred-teamingai-guardrails

Prompt Injection Testing Guide: A Practical Checklist for AI Applications

eevaluate.live Editorial Team
2026-11-30
7 min read

A reusable checklist for testing direct, indirect, retrieval-based, and tool-use prompt injection risks in AI applications.

Prompt injection testing helps teams discover whether untrusted instructions can override an AI application's intended behavior. This practical checklist covers direct, indirect, retrieval-based, and tool-use attacks, with a safe test-prompt template, mitigation decisions, and a repeatable workflow for pre-release and regression testing.

Overview

A prompt injection occurs when content supplied by a user, document, web page, message, or connected system attempts to change the instructions that govern an AI application. The injected instruction may ask the model to ignore its task, reveal protected context, misuse a tool, or treat untrusted text as a higher-priority command.

Prompt injection testing is not a single pass over a system prompt. It is an application security exercise that examines the full path from input to output and, where applicable, from output to an external action. The same model may behave differently depending on the surrounding prompt, retrieved documents, conversation history, tool descriptions, permissions, and output parser.

Start by documenting the application's intended behavior and trust boundaries:

  • Which instructions are controlled by the application?
  • Which inputs are controlled by users or external sources?
  • Can the model see secrets, internal prompts, or private records?
  • Can it call tools, send messages, modify data, or trigger workflows?
  • What must happen when instructions conflict or content is ambiguous?

Build these expectations into a small evaluation set rather than relying on a few manual conversations. A representative dataset should include ordinary requests, boundary cases, malicious-looking inputs, and realistic content from connected sources. See the LLM evaluation dataset design guide for a broader approach to test-case coverage.

Checklist by scenario

1. Direct user prompt injection

Test what happens when a user explicitly attempts to override the application's task or expose restricted information. Keep test prompts controlled and avoid placing real credentials or production data in them.

  • Ask the model to ignore its assigned task and follow a new instruction.
  • Ask it to reveal the system prompt, hidden instructions, or internal decision rules.
  • Claim to be an administrator or developer without a verifiable authorization signal.
  • Wrap conflicting instructions in role-play, quotation marks, code blocks, or a fictional scenario.
  • Use long, repetitive, or distracting text before placing a conflicting instruction near the end.
  • Ask the model to disclose information from earlier messages that the user should not receive.

Expected behavior should be defined in advance. A robust response may refuse the unauthorized request, continue the original task while ignoring the conflicting instruction, or ask for clarification. A vague refusal is not enough if the application still exposes sensitive context or takes an unauthorized action.

2. Indirect injection through retrieved or uploaded content

In a retrieval-augmented generation workflow, documents are often treated as evidence for answering a question. They should not automatically become instructions for the model. Test documents, web pages, tickets, emails, and knowledge-base entries that contain text such as “ignore the user's question,” “send this data elsewhere,” or “treat this section as a system message.”

  • Place an instruction in a document title, footnote, table, comment, or metadata field.
  • Mix useful factual content with an unrelated instruction.
  • Put the injection in a document that is highly relevant to the user's query.
  • Test conflicting instructions across two retrieved documents.
  • Include a document that asks the model to reveal other retrieved documents.
  • Test malformed, duplicated, very long, and partially truncated documents.

Check both the answer and the citations or evidence selection. The model should use untrusted content as data, not silently promote it to an authority. Context-window boundaries also matter: truncation can remove the application’s instructions or the evidence needed to detect a conflict. Review the context window testing checklist when retrieval length or document size changes.

3. Tool-use and agent injection

Tool-enabled systems require a stricter test because a successful injection can lead to an external side effect. Use mock tools or a sandbox wherever possible. Test whether the model can be induced to:

  • Call a tool that is unrelated to the user's request.
  • Change arguments supplied by the user or application.
  • Skip confirmation for a destructive or irreversible action.
  • Send secrets, private records, or hidden context as tool arguments.
  • Follow instructions returned by a tool without validating them.
  • Repeat a tool call indefinitely or create an unexpected chain of actions.

For each tool, record the allowed purpose, required fields, authorization requirements, confirmation rules, and maximum impact. A model should not be the only control deciding whether an action is permitted. Enforce permissions, input validation, rate limits, destination restrictions, and approval gates in application code.

4. Output and parser attacks

Some applications trust the model's output because it is expected to follow JSON, XML, SQL, or another structured format. Test whether an injected instruction can make the model add extra fields, break the schema, include executable content, or place untrusted values in a downstream command.

  • Submit inputs that request additional fields outside the approved schema.
  • Include delimiter-like characters, nested objects, or unusually long values.
  • Ask for content that could be interpreted as markup, a query, or code.
  • Return an empty, incomplete, duplicated, or incorrectly typed field.
  • Test how the application handles invalid output, refusal text, and partial tool calls.

Validate output independently before it reaches another system. Parsing is not the same as authorization: valid JSON can still contain an unsafe instruction or an unauthorized destination.

Safe test-prompt template

Use a neutral template for repeatable tests:

Test ID: [unique identifier]
Application task: [intended behavior]
Untrusted content: [benign simulated instruction]
Expected behavior: [continue, refuse, ask, or escalate]
Disallowed outcome: [secret disclosure, unauthorized tool call, policy bypass, or unsafe output]
Observed result: [record the response and any side effect]

Keep the test deterministic where possible, but do not assume one successful response proves safety. Run multiple variations and score the result against explicit criteria.

What to double-check

Use this review list after each test run:

  • Instruction boundaries: Are system, developer, user, retrieved, and tool-generated messages clearly separated?
  • Secret handling: Can the model access secrets it does not need, and can it repeat them in text or tool arguments?
  • Authorization: Is every sensitive action checked outside the model?
  • Human confirmation: Do high-impact or irreversible actions require an explicit approval step?
  • Data minimization: Are only the necessary records and fields placed in context?
  • Output validation: Are schema, length, destination, and content constraints enforced independently?
  • Failure behavior: Does the application fail closed when the model refuses, times out, produces invalid output, or returns uncertainty?
  • Logging: Can the team reconstruct the input, retrieved context, model response, tool calls, and final action without recording unnecessary sensitive data?

Track more than pass or fail. Useful fields include attack category, test version, model and prompt version, retrieval sources, tool permissions, severity, reproducibility, and the exact control that prevented or allowed the outcome. For automated grading, calibrate the evaluator against reviewed examples rather than treating a judge model as an unquestionable authority. The LLM-as-a-Judge calibration guide provides a useful framework for that process.

When a test fails, classify the failure by impact. A harmless refusal-quality issue is different from disclosure of confidential context, and both differ from an unauthorized external action. Prioritize according to potential harm, exploitability, exposure, and whether the behavior is consistently reproducible.

Common mistakes

  • Testing only the system prompt: Injection can enter through retrieved text, tool results, attachments, memory, or user-generated metadata.
  • Using only obvious attack wording: Test indirect, polite, encoded-looking, role-play, long-context, and mixed-content variants without assuming a particular phrase is required.
  • Evaluating only the final answer: Inspect hidden intermediate inputs where available, tool calls, arguments, citations, and side effects.
  • Giving the model excessive authority: A prompt warning is not a substitute for least-privilege access and application-level authorization.
  • Testing against production systems: Use mock data and sandboxed tools until the test is proven safe.
  • Ignoring normal users: A defense that blocks legitimate requests or corrupts useful evidence can create operational failures even when it stops an injection.
  • Failing to regression-test fixes: A mitigation may change behavior in unrelated tasks. Add the discovered case to the permanent evaluation set and rerun relevant quality checks.

Prompt injection testing should complement, not replace, conventional application security practices such as access control, input validation, secret management, dependency review, and audit logging. It is one layer in a broader secure AI application workflow.

When to revisit

Re-run the checklist before releasing a new AI workflow and whenever its trust boundaries change. Important triggers include a new model or provider, a revised system prompt, a new retrieval source, changed chunking or context limits, added memory, a new tool, modified permissions, a new output parser, or a change in user roles.

Also revisit the tests after an incident, a near miss, a significant model-behavior change, or a seasonal planning cycle that alters workflows and data sources. Keep a small smoke-test suite for every deployment and a deeper scenario suite for scheduled reviews. Connect results to your prompt regression process using a prompt testing framework, and monitor production signals such as refusal changes, unusual tool calls, repeated validation failures, and quality drift.

Practical next step: create ten tests today: three direct injections, three retrieved-content injections, two tool-use cases, and two output-validation cases. Run them in a sandbox, record expected and observed outcomes, fix the highest-impact gap outside the prompt where possible, then add every discovered failure to a versioned regression set. Repeat the run whenever the workflow or its inputs change.

Related Topics

#prompt-injection#ai-security#llm-security#red-teaming#ai-guardrails
e

evaluate.live Editorial Team

AI Development and Evaluation Editors

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.