Abstract
Multi-modal large language model (MLLM)-based web agents interact with webpage environments by generating actions based on screenshots of the webpages. In this work, we propose WebInject, a prompt injection attack that manipulates the webpage environment to induce a web agent to perform an attacker-specified action. Our attack adds a perturbation to the raw pixel values of the rendered webpage. After these perturbed pixels are mapped into a screenshot, the perturbation induces the web agent to perform the attacker-specified action. We formulate the task of finding the perturbation as an optimization problem. A key challenge in solving this problem is that the mapping between raw pixel values and screenshot is non-differentiable, making it difficult to backpropagate gradients to the perturbation. To overcome this, we train a neural network to approximate the mapping and apply projected gradient descent to solve the reformulated optimization problem. Extensive evaluation on multiple datasets shows that WebInject is highly effective and significantly outperforms baselines.
Introduction: The Vulnerability of Visual Web Agents
As Multi-modal Large Language Models (MLLMs) become the primary decision-makers for autonomous web agents, they increasingly rely on visual screenshots to navigate and interact with the web. However, this visual dependency introduces a novel security vector. Existing prompt injection attacks typically target the HTML structure (webpage-based) or the final image (screenshot-based). Webpage-based attacks are often detectable by humans, while screenshot-based attacks are impractical as attackers rarely have access to the local screenshot captured on a user's device.
WebInject addresses this "gap" by operating in the webpage space—modifying source code—while accounting for the complex, non-differentiable transformations that occur during rendering, such as monitor-specific color profiles (ICC profiles) and resizing operations. This allows for a stealthy attack that is virtually invisible to the human eye but highly effective against the MLLM agent.
Methodology: Bridging the Rendering Gap
The core of WebInject is an optimization problem designed to find a pixel perturbation ($\delta$) that maximizes the probability of an MLLM outputting a target malicious action. The authors identified two primary technical hurdles in this process:
- Non-differentiability of Rendering: The mapping from raw pixels to a screenshot is governed by hardware-specific ICC profiles and is not mathematically differentiable. To enable gradient backpropagation, the authors trained a Mapping Neural Network (U-Net) to approximate the behavior of various monitors.
- Screenshot Resizing: MLLMs typically resize screenshots to fit specific input dimensions. WebInject utilizes a differentiable resizing alternative during optimization to ensure gradients can flow through the entire pipeline.
The attack is deployed via a small snippet of JavaScript or CSS injected into the target webpage. This code applies the calculated perturbation to the rendered pixels just before the agent captures its screenshot.
Experimental Results
The effectiveness of WebInject was evaluated across 10 datasets, including five real-world categories (Blog, Commerce, Education, Healthcare, and Portfolio) and five synthetic datasets generated to represent diverse modern web layouts. The attack was tested against five state-of-the-art MLLMs: UI-TARS, Phi-4, Llama-3.2, Qwen-2.5, and Gemma-3.
As shown in the results, WebInject achieves a near-perfect Attack Success Rate (ASR) of approximately 97% across all tested models. In contrast, traditional webpage-based baselines (such as injecting deceptive text or fake UI elements) rarely exceeded a 20% success rate. Notably, previous screenshot-based attacks failed completely (0% ASR) when applied to raw pixels because they did not account for the color shifts introduced by monitor profiles.
Key Insights and Conclusion
WebInject demonstrates that the "monitor gap"—the transformation between raw pixels and the final screenshot—is a critical security boundary. By modeling this transformation, WebInject can craft perturbations that are robust across different hardware profiles. The attack is also semantically robust, remaining effective even when the user's prompt varies slightly from the one used during optimization.
While the current implementation requires white-box access to the MLLM's parameters and the ability to modify webpage source code, it highlights a significant vulnerability in current multi-modal agent architectures. Future defenses may need to focus on detecting abnormal pixel-manipulation scripts or developing adversarial training techniques to harden MLLMs against such environmental visual perturbations.
Summary updated