Agent Security

Prompt Injection Testing for Enterprise AI Agents

Test whether untrusted instructions can redirect an agent across its tool, data or authority boundaries, and preserve evidence that reviewers can reproduce.

For: application security teams, agent engineers, assurance reviewers

Prompt injection testing examines whether an agent treats untrusted content as authority and departs from its approved instructions or permissions. The target is a boundary: between a user’s request and policy, between retrieved material and instructions, or between information an agent may read and actions it may execute.

A useful enterprise test does more than collect alarming responses. It identifies the source of the hostile instruction, the requested deviation, the affected control and the observable result. This guide describes defensive testing in an authorized environment. It does not claim that any collection of prompts can prove universal resistance to injection or jailbreaks. Our comparison of prompt injection and jailbreaks explains how the terms overlap and which boundary each finding concerns.

Start from the agent’s exposure map

List every place the agent receives content it does not fully control. User messages are only one source. Retrieved documents, websites, email, tool outputs, stored memory and delegated tasks can introduce instructions into the workflow. For each source, record how the content reaches the model and whether it could influence a tool call, a disclosure or a decision.

Then map what the agent can do. An agent with no write permissions presents a different action boundary from one that can update accounts or send messages. The exposure map should connect sources to capabilities rather than treating every hostile phrase as equally important. OWASP’s primary guidance distinguishes direct and indirect prompt injection and describes why defenses need to consider the broader application context.

Define what a successful defense looks like

The expected result should be observable and specific. The agent may need to disregard the injected instruction, continue the legitimate task safely, refuse an unauthorized operation or request human review. Do not require a particular refusal sentence unless that wording is itself a genuine product requirement. Correctly protecting a boundary can involve several acceptable responses.

Separate the main testing surfaces

Direct instructions from a user

Direct cases place the conflicting instruction in an interaction with the agent. Vary the actor’s authorization, task context and requested action. A request that is permitted for one role may be prohibited for another. Test whether the system respects that distinction without assuming that confident wording or an assertion of authority changes the user’s actual permissions.

Indirect instructions in retrieved content

Indirect cases place the instruction in material the agent encounters while completing legitimate work. Use controlled documents or tool responses in an isolated test environment. The question is whether source content is interpreted as evidence for the task or as a new instruction that can override the system’s boundaries. Preserve which source introduced the content so a reviewer can reconstruct the path.

Retrieval poisoning and persistent context

Retrieval poisoning concerns manipulation of the information available for retrieval. A test can examine whether a controlled untrusted item is selected and how its contents influence the next action. Persistent memory creates an additional question: can information from one interaction improperly affect a later task or another user’s context? Document the persistence and isolation assumptions being examined.

Tool manipulation and data boundaries

A tool response can contain misleading instructions or unsupported claims about what the agent should do next. Test the boundary between receiving a response and obtaining authority for a new operation. Use synthetic records and controlled endpoints to examine disclosure or cross-context access. A safe-looking final answer does not establish that the preceding tool behavior was acceptable.

Prompt extraction and jailbreak attempts

System prompt extraction tests whether the agent discloses instruction content that is intended to remain private. Jailbreak testing examines attempts to bypass behavioral restrictions. Their practical significance depends on the requirement: revealing an instruction and accessing protected business data are different findings. Classify each result against the actual confidentiality or behavior boundary rather than assigning the same consequence to every unusual response.

Turn an attack idea into a repeatable evaluation case

A repeatable case needs a stable setup. Register the agent version, relevant instructions, tools, permissions, retrieval material and environment. Record the legitimate task separately from the hostile instruction. This makes it possible to determine whether a change protected the boundary while preserving the useful workflow, or simply prevented the agent from completing any task at all.

For each case, preserve:

  1. The policy or control being exercised and why it applies.
  2. The attack surface and the tester’s authorized access.
  3. The controlled input, context and relevant environment state.
  4. The expected safe behavior and acceptable alternatives.
  5. The observations needed to judge tool use, disclosures and handoffs.
  6. The finding, uncertainty and references to retained evidence.

Avoid embedding production credentials or personal information in a case library. Decide how sensitive test material and traces are stored, redacted and shared. A reviewer may need the exact content to reproduce a result, while a wider audience may only need the bounded finding and a controlled evidence reference.

Follow the whole interaction, not just the final response

An agent can produce a reassuring answer after attempting an unauthorized action. Conversely, a confusing answer may occur even when a lower-level permission control correctly prevented the requested operation. Review the sequence of messages, tool requests, authorization checks, tool results and human handoffs needed to evaluate the specified boundary.

For a hypothetical document assistant, a controlled retrieved document might instruct the agent to send an internal summary to an unapproved destination. The relevant evidence is whether the agent attempted a send, whether the destination was authorized and whether the operation completed or was prevented. This example describes a defensive scenario, not a real incident or an asserted product capability.

Distinguish observations from explanations

“Requested an unauthorized tool operation” is an observation when supported by a trace. “The model ignored policy because of the retrieved instruction” is an explanation that may need additional testing. Keep those levels separate. Changing one element of the setup can help investigate the cause, but an exploratory investigation should not overwrite the original reproducible case.

Decide what needs broader red teaming

Prompt injection testing is a focused part of agent red teaming. Broader review may examine unsafe tool composition, delegated authority, multi-step paths, operational failures and interactions between components. A system can resist an instruction override while still exposing excessive permissions or an unsafe approval process.

Use the specialized test to establish a precise finding, then ask whether the same boundary can be crossed through another path. If the risk depends on a sequence involving retrieval, delegation and a writable tool, a single-turn prompt test may be insufficient. Explain that coverage gap so enterprise reviewers do not mistake a focused result for a complete security assessment.

Retest the cause and retain the history

After remediation, rerun the original case against the registered replacement configuration. Add related cases when the investigation identified a broader failure pattern. Include legitimate tasks that exercise the same workflow so a change is not accepted solely because it blocks all useful behavior. Record the new evidence alongside the original finding and the remediation rationale.

Approved regression cases can become part of a CI/CD assurance gate. The gate should reference the canonical evidence and route unresolved outcomes to human review. GitHub is a delivery client in the intended platform design; it does not become a separate evaluation authority. Availability and supported integration scope must be confirmed for the engagement.

Questions to resolve before testing begins

Agree the authorized targets, permitted techniques, synthetic data, stopping conditions and evidence access. Name the people who can respond if a test encounters an unexpected dependency or exposes a sensitive record. Identify which findings block release, which require further investigation and who can authorize an exception. These decisions make the testing useful to the enterprise after the session ends.

The goal is a reviewable account of behavior under defined conditions, with limitations visible. Read the assessment guide to connect security findings to a broader scope decision. The runtime monitoring guide explains why later changes can justify revisiting that decision even after a successful retest.

Sources and further reading

Apply the guide to your agent assurance scope

Discuss the evidence, review process and delivery approach your enterprise needs.

Request a demo