Manuscript Offprint

arXiv:2610.08773

AdvSim2Real : Training Web Agents Against Adaptive Prompt Injection in a Web World Model

Sarim Hashmi, Mukul Ranjan, Kshitij Mishra, Mikhail Kuznetsov, Praneeth Vepakomma, Nils Lukas

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Web agents complete user requests by reading and acting on pages that third parties write, so an instruction planted on a page can redirect the agent away from the user's goal. The agent cannot simply ignore the page, because the page also holds the values and controls the task requires. Current defenses fine-tune the agent on injections fixed before training, and attackers that adapt to the trained model bypass them. Adversarial training lets the attacker adapt but keeps the tasks fixed, so a task stops teaching once the agent solves it. We introduce AdvSim2Real, which co-evolves a task curriculum, an injection adversary, and the agent inside a frozen web world model. The curriculum is rewarded for tasks the agent solves about half of the time, and the adversary only for a success flip, an injection that turns a judged success into a failure. Training in the simulator makes a 4B agent both more capable and more robust: its completion rises with and without attacks, holds against a frontier-model adversary it never trained against, and its capability gain carries over to a real browser. On 150 web tasks, AdvSim2Real raises completion under this unseen adversary by 33.6% relative to the base agent. We release our code, the benchmark, and all checkpoint results.

(a) Co-evolution in a frozen world model

Figure

(b) Completion over training

Figure

(c) Robustness gain

Figure 1: ADVSIM2REAL makes the agent both more capable and more robust. (a) A curriculum proposes tasks (Stage 1) and an adversary inserts one timed injection (Stage 2) into pages that a frozen world model simulates. A frozen LLM judge rewards tasks solved about half of the time and success flips. (b) Judged completion on the 150 tasks over training, clean and under the learned adversaries. (c) Base model against the final checkpoint. Mean ± SD over rollout seeds (three; two for Kimi-K3).

Figure

Figure 2: The same injected notice diverts the base agent but not the trained one. Task 34 of the 150-task benchmark, Adv v2, seed 1; numbered markers give each agent's actions in order, fields show final values, and pages are cropped. The base agent clicks the forbidden Reset all right after the notice appears and is judged bad; Robust iter 3 sees the notice before five actions, never clicks it, and is judged good.

1 INTRODUCTION

Web agents now complete multi-step requests on websites, such as updating a customer record from the entries a page displays (Zhou et al., 2024; Qi et al., 2025; Xi et al., 2025). The web differs from other tool settings because every page is written by a third party and mixes the data a task needs with the controls that act on it. An instruction planted in page content can therefore redirect the agent away from the user's request, an attack known as indirect prompt injection (Greshake et al., 2023), and on a web-agent security benchmark such attacks partially succeed in up to 86% of cases (Evtimov et al., 2025). The agent cannot defend itself by ignoring the page, because the page also holds the values and controls the task requires. A provider therefore needs task-preserving robustness: the agent completes its authorized goal despite competing page instructions whenever the task remains feasible.

Current defenses fine-tune the agent on injected examples built before training, in some cases with a delimiter-based input format, so that it follows the user and disregards the planted instruction (Wallace et al., 2024; Chen et al., 2025a;b;c). Because these injections never change, the defender never meets an attacker that adapts to it, and attackers that optimize against the trained model bypass StruQ and Meta SecAlign (Nasr et al., 2026). Recent work therefore trains the attacker as well: RETA red-teams a frozen agent and trains the defender on the recorded attacks (He et al., 2026), while ARLAS, DMAST, and CoER co-train an attacker and an agent in executed tool or browser environments (Wang et al., 2025c; Liu et al., 2026a; Zhang et al., 2026). These methods adapt the attacks but keep the training tasks fixed, so a task stops teaching once the agent solves it, and each new task requires a site that can execute it.

A web world model removes both limits, because it predicts the next page for any goal, page, and action, including a page that an adversary asks it to alter (Xiao et al., 2026). We use this to introduce ADVSIM2REAL, which trains three policies against one another inside a frozen world model: a curriculum that writes tasks as a goal and an initial page, an adversary that requests one injection per trajectory, and the web agent, which we call the executor, as Figure 1 shows. The curriculum is rewarded for tasks the current executor solves about half of the time, as graded by a fixed language-model judge. The adversary is rewarded only for a success flip: a clean run that the judge accepted is replayed to the chosen step, the injection is rendered there, and the adversary earns credit only if the continuation fails.

ADVSIM2REAL runs in two stages. In the first, the curriculum and the executor alternate updates, so the tasks follow the executor's competence. In the second, the curriculum is frozen and the adversary and the executor alternate, and the executor trains on clean tasks, new attacks, and the attacks of earlier rounds.

We evaluate a Qwen3.5-4B executor on the 150 web tasks of our benchmark in the frozen WebWorld-14B world model; fifty of them are close variants of eight parent tasks. Figure 2 shows a typical attack: an injected notice orders the agent to click a forbidden reset button, the base agent obeys and fails, and the trained executor completes the same task. ADVSIM2REAL raises clean completion from 74.89% to 81.33% and completion under the three learned adversaries from 48.07% to 57.48% (Table 1). Against Kimi-K3, a frontier model that took no part in training, completion rises from 23.00% to 30.72%, a 33.6% relative gain (Table 3). all attacked results are measured inside the world model, where injections are rendered in the context of the page (Section 3) The capability gain of the first stage carries over to a real browser, where strict success on the submitted form rises from 25.56% to 44.44% without any world-model call (Table 2).

References (100)

Couldn't load all references. Reload the page to try again.