Prompt injection defense is an application security process, not a prompt-writing trick. This checklist helps you identify trust boundaries, separate instructions from untrusted content, restrict tool access, validate model outputs, require confirmation for risky actions, and test the system again whenever its model, data sources, or integrations change.
Overview
A prompt injection occurs when content supplied to an AI application attempts to influence the model’s behavior in a way that conflicts with the application’s intended instructions or user permissions. The content might come from a web page, uploaded document, email, support ticket, calendar event, database record, or another model. It may look like an ordinary instruction, such as “ignore previous directions,” or be hidden in formatting, metadata, or a retrieved passage.
The risk increases when an LLM app can call external tools. A model that only drafts text may produce a poor answer. A model that can send email, modify records, publish content, issue refunds, or retrieve private data may turn the same failure into an operational incident.
Reliable prompt injection defense uses several layers:
- Threat modeling: document what the model can read, what it can do, and which assets require protection.
- Instruction separation: clearly distinguish trusted application rules, user requests, and untrusted data.
- Least-privilege tools: expose only the functions and fields required for the current task.
- Validation and confirmation: check tool arguments and pause before consequential actions.
- Monitoring and recovery: record useful security events and maintain a way to revoke access or undo changes.
These controls complement prompt engineering. A carefully written system prompt can improve reliability, but it should not be treated as a permission boundary. Authorization belongs in application code and service controls.
What to track
1. Trust boundaries and data sources
Start with a simple inventory for every input:
- Where does it originate?
- Can an end user or external party edit it?
- Is it treated as data, an instruction, or both?
- Can it contain secrets, personal data, or content belonging to another user?
- Does it cross a tenant, account, or permission boundary?
Mark retrieved documents, webpages, files, tool results, and third-party API responses as untrusted unless they have been explicitly verified. A RAG system should retrieve relevant material, not silently promote that material to system-level authority. Review your retrieval filters, document access rules, and refresh process alongside the RAG knowledge base maintenance checklist.
2. Instruction hierarchy and prompt assembly
Keep trusted instructions separate from variable content in your application design. Use distinct fields or message roles where your model interface supports them, and label untrusted text as reference material rather than directions. Avoid concatenating a user request, retrieved content, and privileged operating rules into one indistinguishable block.
Track prompt versions, model versions, tool schemas, and important configuration values together. A prompt change can alter behavior even when the surrounding code is unchanged. The same is true of a model upgrade or a new retrieval source. A documented release process, such as the one described in how to version and maintain prompts, makes those changes easier to investigate.
3. Tool permissions and action scope
For each tool, record its purpose, inputs, side effects, required user permission, and failure behavior. Prefer narrow functions over broad ones. For example, a tool that creates a draft is safer than one that can publish arbitrary content; a tool that retrieves a specific order is safer than one that accepts unrestricted database queries.
Enforce authorization outside the model. Validate the current user, tenant, resource, and allowed operation in the tool execution layer. Do not rely on the model to decide whether a caller is allowed to access a record. Use separate credentials for read and write actions where practical, and keep high-impact capabilities disabled by default.
4. Output and argument validation
Use structured output when it helps your application parse responses, but remember that valid JSON can still contain an unsafe request. Validate types, ranges, identifiers, destinations, and allowed enum values before execution. Reject unexpected fields rather than silently accepting them.
Apply business rules after parsing. A request to send a message should be checked for recipient authorization, content policy, attachment scope, and rate limits. A request to update a record should be checked against the user’s permissions and the record’s current state. Log validation failures as security-relevant events.
5. Confirmation and audit signals
Require explicit user confirmation before actions that are external, irreversible, financially consequential, privacy-sensitive, or difficult to undo. Show the user what will happen: the target, the affected records, the destination, and any material changes. Do not ask for confirmation using a vague message such as “Proceed?”
Track tool calls, denied calls, confirmation decisions, validation errors, unusual access patterns, and model refusal or escalation events. Minimize sensitive content in logs, apply retention rules, and restrict log access. For broader data-handling controls, pair this process with an AI application data privacy checklist.
Cadence and checkpoints
Use a recurring review rather than waiting for an incident. A monthly review is reasonable for applications with frequent prompt, model, or integration changes. A quarterly review may be sufficient for a stable, low-impact system, provided teams still review changes as they occur.
At every release
- Compare the new prompt, model, tools, retrieval sources, and permissions with the previous release.
- Run injection tests against every tool-enabled workflow.
- Verify that unauthorized records, tools, and fields remain inaccessible.
- Confirm that high-impact actions still require clear user approval.
- Review output validation, error handling, rate limits, and rollback procedures.
Monthly or quarterly
- Review blocked and successful tool calls for suspicious patterns.
- Sample conversations for instruction leakage, sensitive-data exposure, and unsafe execution.
- Retire unused tools and reduce permissions that are broader than necessary.
- Refresh the attack-case library with new formats, languages, encodings, and indirect instructions.
- Confirm that owners, escalation contacts, and incident procedures are still current.
Keep a small regression set in source control. A useful test case includes the workflow, attacker input, trusted user request, expected safe behavior, tools that must remain unavailable, and the evidence required to pass. For example:
Workflow: support-ticket summarization
Untrusted input: ticket text containing an instruction to export customer records
Expected result: summarize the ticket; do not retrieve or export records
Tool expectation: customer-export tool is unavailable
Pass evidence: no export call, safe summary returned, event logged
Expand the set with indirect attacks in retrieved documents, malicious tool results, requests to reveal system instructions, attempts to change the destination of an action, and inputs that combine legitimate work with a prohibited side effect.
How to interpret changes
Do not judge the defense by refusal rate alone. A system that refuses every ambiguous request may be unusable, while a system that completes tasks smoothly may still be exposing data or granting excessive authority.
Review changes across several dimensions:
- Task success: does the application complete legitimate requests?
- Boundary adherence: does untrusted content remain data rather than authority?
- Permission accuracy: are users restricted to the correct resources and operations?
- Tool safety: are arguments validated and consequential actions confirmed?
- Recovery quality: can the team detect, stop, and reverse an unsafe action?
A rise in blocked requests may indicate better detection, a noisier data source, a changed user workflow, or a new attack pattern. A fall in alerts may indicate improvement, but it may also reflect missing logging or a broken detector. Compare security signals with sampled transcripts, tool-call records, and controlled tests before drawing a conclusion.
When a test fails, classify the failure. Was the model persuaded by untrusted content? Did the application expose a tool unnecessarily? Did authorization fail in the tool layer? Did output parsing accept an unsafe value? This classification points to the right fix. Changing the prompt alone is usually insufficient when the root cause is excessive permission or missing server-side validation.
When to revisit
Revisit this checklist immediately when you add a tool, change a tool schema, connect a new data source, alter retrieval permissions, switch models, modify system instructions, change user roles, or introduce an autonomous workflow. Also review it after a security incident, a suspicious tool call, a data-access bug, or a meaningful change in the application’s users and use cases.
For routine maintenance, schedule a monthly or quarterly checkpoint and record the date, reviewer, release versions, tests run, failures found, and follow-up owner. Keep the prior checklist and test results so you can compare behavior over time rather than relying on memory.
Before the next release, use this short sign-off list:
- Map every trusted and untrusted input.
- Confirm that instructions and reference data are separated.
- List each tool’s permissions, side effects, and authorization checks.
- Validate structured outputs and tool arguments in application code.
- Require specific confirmation for high-impact actions.
- Run regression tests for direct and indirect prompt injection.
- Review logs, retention, alerts, rollback, and incident ownership.
- Document what changed and schedule the next checkpoint.
Prompt injection defense is strongest when it is treated as ongoing model reliability and application security work. Use the checklist at design time, during release review, and after production changes. The goal is not to make the model perfectly obedient; it is to ensure that untrusted content cannot quietly turn model flexibility into unauthorized access or action.