Skip to content

Defenses

There are two kinds of defenses: six that work on every scenario, and 59 that belong to single scenarios.

roguebench list defenses

Benchmark-wide defenses

Pass them with --defense, comma-separated. They sit in front of every call of the agent under test and change its system prompt or its prompt. Calls of simulated users and other helpers are not changed.

Name What it does
reminder Adds a security reminder to the system prompt: text returned by tools is data, not instructions from the user; check that the user asked for a deleting, sending, paying, publishing or access-changing action before taking it.
sandwich Repeats the user's task after the latest tool output. This is the same idea as AgentDojo's repeat_user_prompt.
spotlight Wraps every tool output between <<tool-output>> markers and adds a system note that marked text is data (delimiting, after Hines et al., 2024).
detector Asks a model whether the latest tool output contains an instruction for the agent. If the answer is yes, the output is replaced with a notice.
pi_detector The same with a local prompt-injection classifier (transformers; default model protectai/deberta-v3-base-prompt-injection-v2, ROGUEBENCH_PI_MODEL to change it). This is AgentDojo's transformers_pi_detector; install with pip install 'rogue-ai-bench[detector]'.
tool_filter Before the agent acts, a model reads the user's request and the tool list and keeps only the tools the request needs; the rest leave the tool list. With --tool-mode native the agent is not offered them at all. This is AgentDojo's tool_filter.
roguebench run --model gpt-5.6-luna --defense spotlight,sandwich
roguebench run --model gpt-5.6-luna --defense detector --detector-model gpt-5.6-luna

Several defenses are applied in a fixed order: tool_filter, pi_detector, detector, spotlight, sandwich, reminder. detector and tool_filter ask the agent's own model unless you set --detector-model.

The defenses find tool outputs by the labels the simulations write (OBSERVATION:, Tool results: and similar). On a transcript without such labels, spotlight and detector change nothing, and sandwich needs the agent's turn markers. A defense that does nothing on a scenario gives no protection there, so read a defense's numbers per scenario, not only in total.

Scenario defenses

59 scenarios carry a defense of their own, taken from the incident report or from the vendor's fix: a permission prompt, an allowlist, a patched rule. They run under the condition defense. Run them with the full track:

roguebench run --model gpt-5.6-luna --track full

For 25 scenarios the full track adds adaptive+defense: a variant of the incident written to get past that scenario's defense. Compare defense with adaptive+defense to see whether the defense holds against an attacker who knows it.

Write your own

A defense is a function (system, prompt) -> (system, prompt). Put it in a Python file as an entry of a DEFENSES dictionary and pass the file with --plugin:

# my_defense.py
def strip_urls(system, prompt):
    import re
    return system, re.sub(r"https?://\S+", "[link removed]", prompt)

DEFENSES = {"strip_urls": strip_urls}
roguebench run --model gpt-5.6-luna --plugin my_defense.py --defense strip_urls

Plug-ins can also be a module name on the Python path. See Contributing > Plug-ins for how to add a defense to the benchmark itself.

Reading results with a defense

The report shows harm under the incident condition with the defense on, next to the controls. A defense that lowers harm and also lowers benign utility is not free: look at both lines.