Skip to content
Back to blog

Prompt Injection Testing: Direct, Indirect and Stored Cases

4 min read
Prompt Injection Testing: Direct, Indirect and Stored Cases

Sources checked: . FailSafe Research.

A prompt injection test is not a list of strings that make a model say something odd. It is a test of whether untrusted content can change what the system does, and whether that change crosses a security boundary. Organizing the work by delivery path makes the result easier to reproduce and easier to fix.

Three delivery paths

Where the untrusted instruction comes from, and what a finding should show
PathExample sourceEvidence a finding needs
DirectThe user types the instruction into the chat or form.The identity, the input class, the resulting action and whether the user already had authority for it.
IndirectA retrieved document, web page, email, ticket or tool result contains the instruction.The content source, how it entered context, the action or output that changed and the permission decision.
StoredAn instruction is saved in memory, a profile, a document, a system prompt or a shared workspace and takes effect later.Where it was stored, which identities or sessions it affected and when it took effect.

The paths overlap in practice. A stored instruction may be delivered indirectly. The useful distinction is not the label but the trust boundary the content crossed.

Start from the action, not the sentence

Before testing, write down what the system can do: read data, call a tool, send a message, change a record, approve a payment, run code. Then ask which of those actions should be impossible from untrusted content. An injection that produces a rude answer is a quality issue. An injection that causes a read outside the caller's workspace is a security finding.

Use synthetic records and canary values so that a boundary crossing is visible without touching real data. Record the proposed action, the server-side permission decision and the observed result. A model output alone does not prove the action occurred.

Design cases that can be repeated

  1. Baseline. Perform the legitimate action with an authorized identity and no injected content. Keep the result as the control.
  2. Direct attempt. Ask the system to exceed the caller's authority. Record whether the request is refused or attempted and what the server decides.
  3. Indirect attempt. Place a synthetic instruction in a document or tool result the system is expected to read. Record whether the content is treated as data or as instruction.
  4. Stored attempt. Save a synthetic instruction in memory or a shared document, start a new session and see whether it affects a later action.
  5. Boundary check. Inspect the server or API decision, not only the model output. Note whether denied content entered the model context.
  6. Retest. Repeat the original cases on the corrected build, including the legitimate control.

What makes a result weak

  • Reporting a model refusal as proof that the boundary is safe. The refusal may be probabilistic, and the data may still have been retrieved into context.
  • Reporting a successful injection without the resulting action or permission decision.
  • Testing only one model version, prompt template or tool configuration and generalizing to all deployments.
  • Using real customer content to prove access instead of a synthetic record.
  • Ignoring the user's existing authority. An action a user is allowed to take is not an injection finding just because the wording was adversarial.

Fixing by layer

Prompt wording is the weakest control. Durable fixes sit around the model: treat retrieved content as data with a clear boundary, enforce authorization on the server for every action, limit which tools can be called with which arguments, require approval for high-impact actions, and log the decision. A change to the system prompt can be part of the response, but it should not be the only one.

The same principle applies to tool output. Content returned by a tool is untrusted input to the next step, even when the tool itself is trusted.

Where FailSafe fits

FailSafe tests prompt injection as an authorized boundary test across LLM applications, agents, retrieval pipelines and MCP tools. The LLM application testing methodology describes the test areas and evidence record. The AI pentesting scope covers direct and indirect injection alongside tool and data boundaries, and the MCP security page covers injection delivered through tool descriptions and results. The tool result injection guide goes deeper on that path.

Questions & answers

Questions about this topic

Direct answers to common questions about this page.

Direct injection comes from the user's own input. Indirect injection arrives through content the system reads, such as a document, web page or tool result. Stored injection is saved and takes effect in a later session.

No. A refusal is one observed outcome. The test should show whether restricted data entered context and what the server allowed, not only what the model said.

The source of the untrusted content, the test identity and permitted data, the proposed action, the server decision and the observed consequence, with synthetic data.

It is one layer. Authorization at the action boundary, tool limits, approval gates and logging do more to contain an injection than prompt wording alone.

Put this guidance to work

Bring the model, retrieval and tool configuration. FailSafe can design repeatable cases around the boundaries that matter.

Startup offer: $999 USD for 250 credits and one authorized black-box run. Sign in to SWARM before Stripe checkout. Custom scope and sovereign deployments are separate.