
An API request can have the correct content type, a valid identity, and a perfectly acceptable JSON structure while carrying text that attempts to redirect an AI application. This is why request validation and prompt-injection defenses address different boundaries. A schema describes the shape of a message. It does not establish that every instruction inside a document, tool result, or user message should control the application's behavior.
OWASP's LLM01:2025 guidance describes direct and indirect prompt injection. In practical terms, untrusted material may arrive from the immediate user or from content the application retrieves later. The API security overview covers the conventional request boundary; this guide proposes a separate review for how an AI workflow handles content, authority, and consequential actions.
Map where instructions and data meet
Start by drawing the inputs to the model: application instructions, user messages, retrieved documents, search snippets, tool responses, conversation history, and stored memory. Identify who can influence each source. A file uploaded by a customer and a configuration controlled by the application team should not receive the same authority merely because both become text in one model context.
Trace where content gains influence
Record what the model is allowed to do with each source. A document may be evidence to summarize, not permission to send data elsewhere. A tool response may report a result, not authorize a new privileged tool call. Keeping this distinction in the architecture helps reviewers ask concrete questions. It also prevents the team from treating a long system instruction as the only boundary protecting sensitive operations.
Keep permissions outside the prompt
The execution environment should decide whether a requested tool action is allowed. Do not make access to a private record depend only on the model saying that the user is authorized. Resolve identity, tenant membership, and resource permissions through trusted application logic. The model can propose an action, but the backend must independently evaluate whether that action is permitted.
Use narrow tool interfaces with explicit arguments rather than a general-purpose capability when the task needs only a limited operation. For example, a document-answering workflow may need a scoped retrieval function but no ability to edit documents or send external messages. The agent permission guide develops this separation. A smaller action surface makes an unexpected model instruction less likely to become an unintended real-world effect.
Treat retrieved material as evidence
For a retrieval workflow, authorize the document before including it in the model context. Preserve a source identifier and enough provenance to explain where the material came from. Keep retrieved content clearly separated from application instructions in the interface you use. These measures support interpretation and review, but they should not be described as a complete technical guarantee that the model will ignore every embedded instruction.
Test the application's behavior when a retrieved document contains irrelevant directions, conflicting claims, or content outside the user's question. The expected behavior should follow the product's task contract. For a question-answering assistant, that may mean using relevant evidence while declining to treat document text as a command. Evaluate the final output and any attempted tool calls, not merely whether a detector assigned a favorable score to the input.
Validate output before it becomes an action
A model's response may be shown to a user, inserted into a page, passed to another service, or translated into a tool call. Each destination needs its own validation and encoding rules. A response that is acceptable as plain text may be inappropriate as executable code, a database command, or an HTML fragment. The application should not silently promote generated text into a more privileged interpretation.
Define an output contract where the workflow supports it. Check required fields, allowed values, length boundaries, and the relationship between arguments. Then apply ordinary authorization to any proposed operation. For consequential actions, present a specific approval request rather than a vague instruction to trust the assistant. The approved action, target, and parameters should remain bound together through execution so that later changes do not inherit an unrelated earlier approval.
Use detection as one signal
A prompt-injection detector can provide useful evidence for review, but its output still needs a defined role. Decide whether it raises an alert, blocks a narrow class of request, requests human review, or changes the workflow in another bounded way. Consider the consequences of both missed detections and false alarms. A detector that prevents legitimate support questions may create operational pressure to bypass the entire control.
Maintain an evaluation set that reflects the application rather than relying only on generic examples. Include ordinary instructions quoted for discussion, technical documentation, multilingual content relevant to your users, and ambiguous material. Track why the expected result is correct for the task. The aim is to understand the boundary the control actually provides, not to claim that one classification label proves a prompt or document is safe.
Limit the effect of a failed judgment
Assume that some confusing or adversarial material may still influence a model. Bound what can happen next through scoped credentials, restricted destinations, resource limits, and approval requirements. Separate read operations from writes and exports. A summarization task should not automatically acquire a capability to contact an arbitrary external address merely because the model requests it.
Containment also includes the amount of work a workflow can perform. Limit repeated model calls, tool invocations, and execution duration independently of the prompt text. The token budget guide explains one part of this design. These boundaries do not eliminate prompt injection, but they make the application's possible effects more deliberate and give operators clearer stopping points when behavior deviates from the intended task.
Design evaluation around observable behavior
Use synthetic documents and authorized test environments to create controlled scenarios. Ask whether the application stays within its allowed data sources, whether it proposes an out-of-scope tool action, and whether the executor rejects that action. Distinguish model behavior from application behavior: the model might generate an unsafe proposal while the surrounding system correctly prevents it from executing.
Repeat tests when prompts, models, tools, retrieval rules, or context construction change. Keep the expected outcome tied to the product's requirements, including the handling of incomplete evidence. A test suite should contain legitimate cases as well as adversarial ones. Otherwise a control that refuses every task could appear successful even though the application no longer serves its users. Record both protection and task-completion results under clearly stated conditions.
Investigate with limited content exposure
When an event needs review, preserve the workflow identifier, source references, attempted action, policy decision, and relevant configuration version. Decide which content is truly needed for investigation and who may access it. Copying entire customer documents into a broadly visible security channel can create a second problem while trying to understand the first.
Record uncertainty in the incident notes. Unexpected output may come from an ambiguous task, missing context, a model error, or an injection attempt. Use the evidence to distinguish these possibilities rather than labeling every undesirable answer an attack. Keep corrective actions specific: a missing authorization check needs an application fix, while unclear task instructions may need a prompt or interface revision. The remedies are related but not interchangeable.
Preserve the boundary between suggestion and authority
The central design question is what happens when untrusted content asks the application to do something it was not authorized to do. A strong answer lives in the surrounding system: scoped access, explicit execution checks, bounded workflows, and reviewable evidence. Clear prompting can support the task, but it should not carry responsibilities that belong to trusted application logic.
Use OWASP's prompt-injection guidance as an external risk reference and test the actual behavior of your own workflow. Start with one consequential boundary, verify both permitted and rejected actions, and expand from there. The objective is not a claim that every input is harmless. It is a system in which content does not automatically become permission.
Primary reference: OWASP LLM01:2025 Prompt Injection. The practical workflow and examples above are editorial guidance; the linked reference supplies the relevant technical foundation.