Sebastian HaasAI Security Engineer
Research note · Adversarial AI

Evaluating prompt injection in tool-using LLM systems

A jailbreak is a model-behaviour problem. Prompt injection becomes a system-security problem when untrusted data can influence an LLM that reads private context or can take actions.

Start with the system, not the prompt

A useful evaluation begins by documenting what the system can read and what it can do. The same injected instruction has radically different impact in a chat interface, a retrieval system with private documents, and an agent with email, shell, or browser tools.

The threat model should state:

Use an attack corpus, not one clever prompt

The corpus needs to cover how instructions reach the model, not just how they are worded. At minimum, test direct user instructions, indirect instructions in retrieved content, payloads embedded in tool output, multi-turn persistence, instruction obfuscation, and attempts to exfiltrate data or trigger privileged actions.

The evaluation loop

  1. Define the expected policy. Specify allowed and disallowed outcomes before running attacks.
  2. Execute deterministically where possible. Pin model, system prompt, tools, configuration, and attack version.
  3. Capture the full trace. Record messages, retrieved context, tool calls, arguments, outputs, guardrail events, and final response.
  4. Score behaviour and impact separately. A model following a malicious instruction is not equal to a successful privileged action.
  5. Replay after every control change. A defence is useful only if it reduces attack success without breaking intended tasks.

A practical scoring model

I separate four outcomes:

This keeps model weirdness separate from exploitable system impact and makes regression results easier to compare.

Controls that belong in the system

No single prompt can enforce a security boundary. Useful controls sit around the model:

The core question is not “Did the model say something unsafe?” It is “Could untrusted input move the system across a security boundary, and do we have the trace needed to prove it?”

What comes next

The next iteration of this work turns the framework into a reproducible test harness: versioned attack cases, structured traces, repeatable scoring, and comparison of guardrail combinations against the same corpus.