WebInject: Prompt injection against multimodal web agents via webpage pixel perturbationsWebInject: Prompt Injection Attack to Web Agents
WebInject modifies webpage pixels to induce target actions; Gemma-3's ASR is 0.972, and the authors state it is 0.910 higher than the baseline.
The attacker controls or has compromised the target webpage, can modify the source code and access the agent's MLLM parameters, and can construct the target prompt, display information, and shadow history themselves. They cannot obtain the real interaction history, nor directly modify the screenshot. The goal is: on the target prompt or its semantically similar variants, and on the target display, to make the agent execute specified actions, with changes invisible to ordinary users.
- MLLM webpage agents generate actions from screenshots and prompts. An attacker can modify the webpage source code but cannot modify the screenshot on the user's device; the authors believe heuristic HTML injection is hard to make both effective and stealthy, while directly modifying the screenshot is unrealistic.
- WebInject optimizes an ℓ∞-bounded perturbation on the raw pixels so that the screenshot after the ICC mapping increases the probability of the target action. A U-Net approximates the non-differentiable mapping, a differentiable scaling replaces model scaling, PGD solves in the overlapping region of multiple monitors, and the perturbation is then written back into the source code.
- Averaged over the ten datasets, Phi-4's WebInject ASR in Table 1 is 0.963, and UI-TARS's is 0.975. The authors state that Gemma-3 is 0.910 higher than the best-performing baseline; the screenshot baseline is 0.000.
- The authors point out that the source-code modification assumption may not hold for sites such as Amazon, and that transfer to closed-source MLLMs was not evaluated. The experiments cover five open-source MLLMs with accessible parameters and self-built real and synthetic webpages, with a default LG monitor, and ASR is computed by exact equality of the action string.
- Evaluated models
- UI-TARS-7B-SFTPhi-4-multimodal-instructLlama-3.2-11B-Vision-InstructQwen2.5-VL-7B-InstructGemma-3-4b-it
- Benchmarks
- Real webpages (blog, commerce, education, healthcare, portfolio)Synthetic webpages (blog, commerce, education, healthcare, portfolio)
- Metrics
- ASR
The researchers propose WebInject, a prompt injection attack that induces a multimodal webpage agent to execute attacker-specified actions by modifying the raw pixel values of the rendered webpage. The attack formulates finding the perturbation as an optimization problem; since the mapping from raw pixels to screenshots is non-differentiable, the authors train a neural network to approximate this mapping and then solve it with projected gradient descent. Evaluations on multiple datasets show that WebInject is significantly effective and outperforms baseline methods. This work was published at the EMNLP 2025 main conference.
Paper analysis
What problem does this paper attempt to solve?
When the attacker can only modify the source code, how can a web agent be made to execute a specified action while the changes are hard to see?
How to make an MLLM web agent execute a specified action when only the webpage source code can be modified, not the user-side screenshot, while making the change imperceptible to the human eye.
- Scenario: The agent takes the user prompt, the display screenshot, and the executed actions as input, and outputs actions such as click and type (Section 2). The authors state that inducing a click at a specified coordinate could lead to click fraud, malicious downloads, or sensitive information leakage.
- Existing approaches: The authors divide them into two categories. Source-code-modifying web-based methods mostly rely on heuristics, with suboptimal effectiveness, and the injected elements are usually visible; directly modifying the screenshot is unrealistic because the screenshot is generated locally on the user's device and the webpage-to-screenshot mapping is not handled.
- The authors' observation: Different display sizes and ICC profiles make the same webpage produce different screenshots, and this mapping is non-differentiable. The authors state that directly adding a perturbation optimized for screenshots to the original pixels fails completely.
- This paper's method: WebInject computes a perturbation on the rendered original pixels, which after mapping increases the probability of the target action; the ℓ∞ norm is bounded, and the perturbation lies only in the overlapping region of multiple target displays.
- Threat model:
- Goal: Effectiveness requires that when the user issues the target prompt or a semantically similar variant and uses a target display, the agent executes the target action; stealthiness requires that ordinary users cannot notice the modification.
- Capability: Can modify the target webpage's source code. There is no real interaction history, but shadow history can be constructed by randomly sampling from the action space. Cannot directly modify the screenshot.
- Knowledge: Has access to the agent MLLM's parameters; the authors state this enables a worst-case analysis. Can construct target prompts and collect the target displays' sizes and ICC profiles.
- Victim system: A webpage controlled or compromised by the attacker, and an MLLM web agent running on that page.
What related research exists?
The authors divide existing work into heuristic or optimization-based prompt injection, as well as webpage injection and screenshot perturbation.
The paper mainly discusses two categories of work in the introduction and Section 6: general prompt injection, and injection against web agents.
General prompt injection
- Manual construction: Willison (2022, 2023), Greshake et al. (2023), and Liu et al. (2024) discuss embedding prompts in untrusted inputs to make the model deviate from its original task and move toward an attacker-chosen task.
- Automatic optimization: Hui et al. (2024), Shi et al. (2024, 2025), and Jia et al. (2025) use optimization to generate injection prompts. Shao et al. (2024) report that poisoning the alignment process can amplify a model's vulnerability to prompt injection.
- Existing uses: PLeak by Hui et al. (2024) induces the model to output the system prompt; Shi et al. (2024, 2025) influence tool selection; InjecAgent by Zhan et al. (2024) and AgentDojo by Debenedetti et al. (2024) involve poisoned tool returns.
Injection on web agents
- Source-code modification: The pop-up attack by Zhang et al. (2024) injects misleading pop-ups; EIA by Liao et al. (2025) injects HTML similar to legitimate elements. The introduction also lists AdvAgent by Xu et al. (2024) in the web category. The authors state that these attacks mostly rely on heuristics, have suboptimal effectiveness, and the elements are usually visible, or they sacrifice some effectiveness for stealth.
- Screenshot modification: Aichberger et al. (2025) and Zhao et al. (2025) add visual perturbations to screenshots to increase the probability of target actions. The authors state these are impractical: the attacker cannot directly modify the local screenshot, and these works do not address the webpage-to-screenshot mapping.
Experimental baselines and datasets
- Baseline methods: For the web category, Naive Attack, Context Ignoring, Fake Completion (Willison, 2022, 2023), and Combined Attack (Liu et al., 2024) are turned into pop-ups, following EIA and Pop-up Attack. For the screenshot category, perturbations are optimized on screenshots following Aichberger et al. (2025) and Zhao et al. (2025), then added to the original pixels.
- Benchmarks/datasets: Evaluation uses ten self-constructed webpage sets, with categories blog, commerce, education, healthcare, and portfolio, each containing real and synthetic pages.
The authors state in the conclusion that WebInject is the first effective, stealthy, and practical prompt injection attack to web agents: the perturbation can be implemented by modifying the source code, and the display mapping is handled.
How does the paper address this problem?
Use U-Net to approximate the display mapping, then use differentiable scaling and PGD to find ℓ∞ perturbations in the overlapping region.
WebInject does not directly modify the screenshot. It computes a perturbation δ on the webpage's original pixels, then modifies the source code to implement that perturbation, so that the screenshot after display mapping increases the probability of the target action.
Problem Setting and Optimization Objective
- Rendering and agent: Source code ω is rendered by the browser on display d to obtain original pixels I(ω, d), which are then mapped to a screenshot according to the ICC profile. The action is a function of the prompt, the resized screenshot, and the history of actions. The history contains only executed actions. Action names are given in Table 2, such as click, drag, type, scroll, finished.
- Effectiveness: Over the target prompt set, target display set, and shadow history set, minimize the sum of cross-entropy of the target action a*, thereby maximizing the product of conditional probabilities of each token in Equation (1).
- Stealthiness and generality: The ℓ∞ norm of δ does not exceed ε. The width and height of the overlapping region are the minimum of the widths and heights of the target displays, respectively; optimization is performed only within this rectangle, and values outside it are 0.
- Solution form: After replacing the mapping and resizing with differentiable approximations, the authors solve
minδ∑p,d,H−log Pr(a∗|[p,r′(Nd(I(ω,d)+δ)),H]),
while retaining the ℓ∞ constraint and the constraint that values outside the region are 0.
Two Non-Differentiable Components
- Display mapping: For each target display, train a mapping network N_d that takes the perturbed original pixels as input and outputs the corresponding screenshot. The architecture is U-Net. Training pairs are obtained by randomly perturbing and then applying the ICC mapping; the authors write that the ICC profile can be used to simulate the display without physical access.
- Resizing: MLLM resizing is usually discrete resampling. During optimization, a differentiable resize is used instead; the main text gives PyTorch's interpolate and TensorFlow's resize as examples.
PGD and Writing Back to Source Code
- Iteration: δ is initialized to 0, for a total of T iterations. Each iteration samples a mini-batch from the prompt set and shadow history set and updates according to the loss gradient.
- Projection: Clamp restricts elements to [−ε, ε]; a mask then sets values outside the overlapping region to 0. The steps are shown in Algorithm 1.
- Hyperparameters given in the main text: ε = 16/255, learning rate α = 0.3, T = 2500. The mapping network is trained on 16,240 pairs across all target webpages, with 200 epochs, learning rate 0.005, and batch size 16. The paper does not state the PGD mini-batch size.
- Writing back: The injected code reads the original pixels in the overlapping region, adds δ, and writes them back. The original HTML elements are placed at the top layer with opacity 0, so user interactions still target the original elements, while the screenshot comes from the ICC transform of the perturbed pixels. An implementation snippet is shown in Fig. 7.
What experiments did the paper conduct?
Gemma-3's WebInject ASR in Table 1 is 0.972, and the screenshot baseline is 0.000.
Experimental Setup
- Models: UI-TARS-7B-SFT, Phi-4-multimodal-instruct, Llama-3.2-11B-Vision-Instruct, Qwen2.5-VL-7B-Instruct, Gemma-3-4b-it. In the table abbreviated as UI-TARS, Phi-4, Llama-3.2, Qwen-2.5, Gemma-3. The attacker has access to the parameters.
- Data: Real pages were saved with SingleFile; synthetic pages were generated by GPT-4-Turbo, 100 pages per category. The real pages in Table 3 are Blog 50, Commerce 26, Education 42, Healthcare 51, Portfolio 43. Each page has 10 target prompts. The paper writes that the generator is GPT-4-Turbo, while the sentence related to Fig. 10 writes guide GPT-4o.
- History and default action: Optimization uses shadow history, evaluation uses user history, each randomly 10 entries, each entry 3–5 actions. The default target action is click((x,y)) at random coordinates within the overlap region.
- Metric: Equation (5) first computes, for the target display, the proportion of exactly equal action strings, then averages over webpages, prompts and user history. The paper did not use an LLM judge and did not report the number of independent repetitions.
- Baselines: Naive, Context Ignoring, Fake Completion, Combined were made into pop-ups, containing an attention hook, text instructions, and an information banner placed at the target coordinates, following EIA and Pop-up Attack; clicking the banner counts as success. Screenshot-based methods first optimize on the screenshot, then add the perturbation directly to the original pixels.
- Optimization and displays: ε = 16/255, α = 0.3, T = 2500. The mapping network for each target display uses 16,240 pairs, 200 epochs, learning rate 0.005, batch size 16. Unless otherwise stated, the target display is one 27-inch 4K UHD LG 27UL500-W. There are also a physical 24-inch iMac M1, a 15-inch MacBook Air M3, and simulated Dell S2722QC and ASUS XG27UCG.
Main Results
The table below is the ten-dataset average ASR from Table 1, corresponding to the default single LG display. Combined is not listed because of the number of columns.
Swipe horizontally to read the table
Agent WebInject Screenshot baseline Naive Context Ignoring Fake Completion UI-TARS 0.975 0.000 0.085 0.147 0.054 Phi-4 0.963 0.000 0.095 0.050 0.047 Llama-3.2 0.972 0.000 0.270 0.212 0.345 Qwen-2.5 0.970 0.000 0.100 0.095 0.067 Gemma-3 0.972 0.000 0.062 0.054 0.037 - The authors' comparison: The authors state that WebInject is higher than these baselines. The difference given in the introduction is 0.910, corresponding to Gemma-3 relative to the best-performing baseline in this table.
- The authors' attribution: The authors state that the gap comes from directly maximizing the target action probability, whereas the webpage baselines are heuristic injections. The screenshot baseline is implemented according to this paper's threat model, with the perturbation added to the original pixels; the authors state that it does not cross the webpage-to-screenshot mapping.
- Combined: Table 1 separately reports UI-TARS 0.050, Phi-4 0.025, Llama-3.2 0.248, Qwen-2.5 0.063, Gemma-3 0.062. Llama-3.2's webpage baselines are higher than those of the other agents, but still lower than WebInject in that row.
Number of Displays and Perturbation Bound
- What was measured: Fig. 2 gives the average ASR of the five agents as a function of the number of target displays and ε. Fig. 11–14 plot by dataset; the main text gives no point-by-point readings.
- The authors state: As the number of displays increases, ASR decreases slightly, because optimization is only performed in the overlap region; and they state that the two types of baselines are still worse than WebInject in this case. As ε increases from 4/255 to 32/255, ASR rises to close to 1.
- Imperceptibility: The authors state that ε≤16/255 is generally regarded as imperceptible in Qi et al. (2024) and Luo et al. (2024). Fig. 5 only gives webpage examples for different ε. The paper does not report a user detection rate.
Prompt Variants and Other Target Actions
- Semantic variants: GPT-4-Turbo generates user prompts that differ in text but are semantically equivalent according to Fig. 8, which are then substituted into Equation (5). The authors give an example: on Gemma-3, synthetic Blog, this ASR is 0.957, while the target prompt under the same setting is 0.988. The authors state that no optimization was performed for these user prompts.
- Table 11: The main text does not interpret it cell by cell. The lowest in the table is Qwen-2.5, real Portfolio at 0.871; UI-TARS synthetic Blog and Llama-3.2 synthetic Education are both 0.959.
- Other actions: Table 10 reports only synthetic Blog, Phi-4. The ASR for the nine actions is 0.993, 0.980, 0.988, 0.979, 0.976, 0.982, 0.992, 0.987, 0.990. type(content) uses one harmful search query; the table note gives the original text, which is not quoted here. The authors state that it is likewise successful on these actions.
Other Ablations and Analyses
- In Table 4, the lowest WebInject is Gemma-3, real Education at 0.929; 0.999 appears for Qwen-2.5 synthetic Commerce, and for Gemma-3 synthetic Commerce and Education.
- The screenshot baseline in Table 9 is 0.000 on all listed agents and datasets. The webpage baselines are not all close to 0: in Table 6, Llama-3.2 synthetic Education Fake Completion is 0.459; in Table 8, Llama-3.2 real Healthcare Combined is 0.440.
- Table 12, on a single NVIDIA RTX A6000, per target webpage and per target display, writes training time as Δ plus 1.92, 2.18, 2.57, 2.07, 1.70 minutes, and memory as Ω plus 1.93, 1.99, 2.61, 2.10, 2.18 GB, in the order UI-TARS, Phi-4, Llama-3.2, Qwen-2.5, Gemma-3. The paper does not give the absolute values of Δ and Ω.
- Section 4.1 writes the 24-inch iMac M1 as 4480×2520 and the 15-inch MacBook Air as 2880×1864; Fig. 6 labels that iMac as 3200×1556 and the LG 27UL500-W as 3840×1916. The paper does not explain the discrepancy.
- The paper does not report the pixel error of the mapping network, the PGD mini-batch size, or evaluation numbers for the source code inspection, adversarial example detection and adversarial training written in Section 8.
What are some points that can be further explored?
The authors note that the source code modification assumption does not apply to high-trust sites, and transfer to closed-source MLLMs was not evaluated.
Limitations and future directions noted by the authors
- Source code control: Section 8 states that the assumption of being able to modify the target webpage source code may not apply to high-trust sites such as Amazon.
- Closed-source transfer: The same section states that transferability to closed-source MLLMs was not evaluated. The authors note that high transfer typically requires optimizing perturbations on multiple surrogate models (Hu et al., 2025), which was not done due to insufficient compute.
- Future directions: The authors state that addressing the above limitations is a worthwhile research direction.
Experimental coverage
- The tested MLLMs are UI-TARS-7B-SFT, Phi-4-multimodal-instruct, Llama-3.2-11B-Vision-Instruct, Qwen2.5-VL-7B-Instruct, and Gemma-3-4b-it, 5 in total; the attack setting assumes access to their parameters (Sections 3, 5.1).
- The data are 5 categories of real webpages and 5 categories of synthetic webpages. Real page counts are given in Table 3: Blog 50, Commerce 26, Education 42, Healthcare 51, Portfolio 43; synthetic has 100 per category. Each page has 10 target prompts, with shadow history and user history each having 10 entries, each with 3–5 actions.
- The default target display is 1 27-inch 4K UHD LG 27UL500-W. The display-count experiment uses 3 physical displays and 2 ICC-profile-simulated displays (Section 5.1, Fig. 2).
- Success is determined by exact string equality of the action (Eq. 5). Reported ε values are 4/255, 8/255, 16/255, 32/255. Numbers for other target actions appear only for synthetic Blog, Phi-4 (Table 10).
- The paper does not report the number of independent repetitions, PGD mini-batch size, or mapping network approximation error. Section 8 lists three possible defenses—source code inspection, adversarial example detection, and adversarial training—and states that DataSentinel is not applicable because the attack does not inject explicit text prompts; the experimental section has no evaluation numbers for these defenses.
Summarize the main content of the paper
WebInject perturbs original pixels via source code; in Table 1, the ASR of five agents is higher than the webpage and screenshot baselines.
WebInject is an environment prompt injection against MLLM web agents: it modifies the webpage source code so that a perturbation on the original pixels, after display mapping, induces the agent to execute an attacker-specified action.
- Problem: The agent operates on the webpage based on the prompt, screenshot, and action history. The authors believe that heuristic HTML injection struggles to be both effective and stealthy; directly modifying the screenshot is inconsistent with the setting where the attacker cannot access the user's screenshot.
- Method: Minimize the cross-entropy of the target action within the overlapping region of multiple target displays, with the perturbation constrained by the ℓ∞ norm. A U-Net approximates the ICC mapping, a differentiable resize replaces the model's resize, PGD solves the optimization, and the perturbation is written back into the source code; the original page elements are placed at the top layer with zero opacity.
- Main results: According to Table 1, averaged over the ten datasets, Phi-4's WebInject ASR is 0.963 and UI-TARS's is 0.975. The authors state that on Gemma-3 it is 0.910 higher than the best-performing baseline. Under this paper's implementation, the screenshot baseline is 0.000.
- Other results: The authors state that ASR decreases slightly as the number of target displays increases, and approaches 1 when ε increases to 32/255. On semantically equivalent but textually different prompts, the ASR for Gemma-3 on synthetic Blog is 0.957. In Table 10, for synthetic Blog and Phi-4, type(content) is 0.976 and left_double is 0.993.
- Authors' conclusion: The authors state that the attack is effective, stealthy, and practical, and in the conclusion call it the first effective, stealthy, and practical prompt injection attack to web agents. Section 8 also states that the source-code modification assumption does not apply to high-trust sites, and transfer to closed-source MLLMs is left for future work.