
Defense framework enforcing routed origin policy to prevent indirect prompt injection in tool-using LLM agents, with deterministic origin checks and benchmark harnesses for evaluating attack success and utility retention.
Code, router cache and run logs for our paper:
ROPE: Routed Origin Policy Enforcement against Indirect Prompt Injection by Xinhang Ma, Chaowei Xiao, William Yeoh, Ning Zhang, Yevgeniy Vorobeychik
ROPE lets a value reach a state-changing tool only if it comes from the user, a source the user named, or the user's own records. Enforcement is a deterministic provenance check over an audited set of sensitive tool parameters; a router LLM reads only the trusted user request and sets how strictly each parameter is checked.
| Path | Contents |
|---|---|
src/rope/ | The defense: router, per-task scope, policy compiler, origin labeler, runtime guard. |
src/rope/scopes/_floor/<suite>.json | The audited sensitive-parameter table per suite (shared by every router). |
src/rope/scopes/<router>/<suite>.json | The router cache: per-task scopes of the four evaluated routers (opus on all six suites; gemini-3-flash, gpt-oss-20b, gpt-4o-mini on the AgentDyn suites). |
src/common/ | LLM completion cache for the router. |
autodojo/ | Benchmark harness with the six evaluated suites (banking, slack, travel from AgentDojo; github, shopping, dailylife from AgentDyn) and the adaptive (AutoDojo) attack. |
agentlab/ | Long-horizon benchmark: AgentLAB Task-Injection traces and the replay driver (agentlab/README.md). |
logs/ | Every ROPE run behind the paper's numbers. |
analysis/aggregate.py | Recomputes every ROPE number of the paper from logs/. |
Python 3.12 with openai, pydantic, jsonschema, pyyaml, docstring-parser (and google-genai for the native Gemini path). From the repository root:
export PYTHONPATH=$PWD/autodojo/src:$PWD/src
python analysis/aggregate.py logs # every model
python analysis/aggregate.py logs gpt-4o-mini # one model
It prints, per agent model: clean utility (CU), utility under attack (UA) and attack success rate (ASR) per suite and as the unweighted suite mean, for every configuration; static vs adaptive attack; the long-horizon attack; per-category results; and every residual attack success.
Three benchmark oracles score a blocked attack as a success; analysis/corrections.py rescores those three injection tasks by their effect (slack IT5, dailylife IT7, github IT1). CU and UA are never touched.
logs/<benchmark>/<model>/<config>/<suite>/user_task_<i>/<attack>/<case>.json
| Level | Values |
|---|---|
<benchmark> | agentdyn, agentdojo |
<model> | gpt-4o-mini, gpt-4o (AgentDyn only), gemini-2.5-flash, qwen3-235b |
<config> | rope (the defense, Opus 4.8 router); GPT-4o-mini on AgentDyn also: rope-clamp, rope-defaults-only, rope-always-fully-specified, rope-always-action-open (policy ablation), rope-router-<router>[-clamp] (cheaper routers) |
<attack> | clean (no attack, none.json), static (important_instructions), adaptive (AutoDojo), long_horizon (AgentLAB Task-Injection, AgentDojo suites) |
<case> | none.json (clean) or injection_task_<k>.json |
Each JSON is an AgentDojo run log: the full message trace, the injections, and the utility and security verdicts (security: true means the attack succeeded).
# the defense (cached Opus router):
python -m rope.run_eval --suite github --attack important_instructions
python -m rope.run_eval --suite github --attack none # clean utility
python -m rope.run_eval --suite github --defense passthrough # no defense
# a cheaper router, optionally clamped to the audited floor; a fixed-policy ablation arm:
python -m rope.run_eval --suite github --router gemini-3-flash --clamp
python -m rope.run_eval --suite github --policy-mode defaults-only
# a live router (any OpenAI-compatible model):
python -m rope.run_eval --suite github --router live --router-model openai/gpt-4o-mini
# adaptive attack: replay the AutoDojo-optimized injections
AUTODOJO_CACHE=$PWD/autodojo/variant_generation/variants/github/openai/gpt-4o-mini/routed/injections.json \
python -m rope.run_eval --suite github --attack autodojo
# long-horizon attack: replay the AgentLAB traces
python agentlab/run_eval.py --suite banking --user-task user_task_0 --injection-task injection_task_0
Environment: OPENROUTER_API_KEY (agent model and live router), ROPE_AGENT_MODEL (default openai/gpt-4o-mini), ROPE_PIPELINE_TAG (the run name prefix; it must contain an AgentDojo model name, default gpt-4o-mini-2024-07-18).
To cache a router of your own and use it like the shipped ones:
python -m rope.cache_router --router my-router --router-model <llm-id> --suite github
python -m rope.run_eval --router my-router --suite github --attack important_instructions
This repository builds on AgentDojo and AgentDyn (benchmark suites), AutoDojo (adaptive attack) and AgentLAB (long-horizon attack traces).
@article{ma2026rope,
title={ROPE: Routed origin policy enforcement against indirect prompt injection},
author={Ma, Xinhang and Xiao, Chaowei and Yeoh, William and Zhang, Ning and Vorobeychik, Yevgeniy},
journal={arXiv preprint arXiv:2608.27496},
year={2026}
}