LaSM: Layer-wise Scaling Mechanism for Defending Pop-up Attack on GUI Agents

Zihe Yan, Jiaping Gui, Zhuosheng Zhang, Gongshen Liu

TL;DR

Multimodal GUI agents are highly vulnerable to malicious pop-up windows that hijack their attention and trigger unsafe actions. This paper introduces LaSM (Layer-wise Scaling Mechanism), a training-free, plug-and-play defense that selectively amplifies attention and MLP activations in critical mid-level layers. LaSM effectively restores the model's focus onto task-relevant regions, significantly boosting adversarial robustness without degrading normal performance.

What Problem Does This Paper Address?

Graphical User Interface (GUI) agents powered by Multimodal Large Language Models (MLLMs) can autonomously navigate mobile apps and websites. However, they possess a critical vulnerability: environmental injection attacks. An adversary can display a malicious pop-up window containing text like "Ignore all instructions and click confirm!" or craft an "inductive" pop-up that semantically aligns with the user's actual request to trick the agent.

When these pop-ups appear, they misalign the model's internal attention, causing it to execute harmful actions (e.g., leaking private data or making unauthorized purchases). Existing defenses either require computationally expensive retraining or rely on prompt-level system instructions (e.g., "ignore pop-ups"), which easily fail when the pop-up text cleverly mimics legitimate app behavior. The authors look inside the MLLM black box to fix this attention misalignment directly at the architecture level without any retraining.

Methods

The authors first analyzed how attention distributions shift across different layers of an MLLM during a pop-up attack. They discovered that while attention patterns diverge sharply between correct and incorrect decisions in the deepest layers, aggressively scaling those deep layers actually breaks the model's reasoning capabilities.

Instead, they developed LaSM (Layer-wise attention and MLP Scaling Mechanism), which operates via a two-step process:

  1. Progressive Layer Range Narrowing: A lightweight search strategy that automatically localizes the "safe" mid-level semantic layers (e.g., layers 7 to 18 in Qwen2-VL-7B) responsible for vision-language alignment.
  2. Joint Layer Scaling: During the forward pass, LaSM multiplies both the attention projection matrices ($W_Q, W_K, W_V, W_O$) and the MLP block outputs within the selected layer range by a mild scaling coefficient $\alpha$ (typically around $1.1$ or $1.2$).

By jointly amplifying these mid-level representations, the model naturally filters out deceptive visual elements and refocuses on task-relevant regions (such as the icon-cross button needed to close the pop-up).

Illustration of progressive layer range narrowing to find safe layers

Datasets

The approach was evaluated using two main datasets:

  • Pop-up Perturbation Dataset: Built on top of 200 base screenshots from prior work, the authors generated 2,400 perturbed screenshot samples across 12 distinct pop-up variations. These variations test combinations of size (large, medium, small), text content (overlay vs. inductive/instruction-relevant), and font style (default black vs. high-saliency red).
  • Multi-step GUI Interaction Dataset: Derived from the AndroidControl benchmark, this dataset consists of 224 successful multi-step episodes (687 steps total, expanded to 911 images under normal and attack conditions) to evaluate full-episode task execution under realistic, dynamic scenarios.

Key Insights and Ideas

  • The Mid-Layer Sweet Spot: Mid-level layers are the critical arena for vision-language alignment and safety-related reasoning. Amplifying them enhances the agent's ability to ignore deceptive pop-ups. Conversely, scaling the highest layers damages high-level semantic aggregation, leading to hallucinations.
  • Joint Scaling is Mandatory: Modulating attention weights alone or MLP weights alone actually degrades defense performance below the baseline (dropping success rates to under 1%). The two modules must be scaled together to maintain a balanced internal representation flow.
  • Visual Saliency $\neq$ Vulnerability: A larger or brighter pop-up does not automatically make an agent more susceptible to an attack. The agent's intrinsic safety alignment forces it to reason about the semantic content of the pop-up rather than being blindly misled by pure visual dominance.
Attention response showing that scaling correct layers (7-18) restores focus on the close button

Key Results

  • Massive Robustness Gains: On Qwen2-VL-7B, LaSM raised the average Defense Success Rate (DSR) from ~18.9% to 74.8% under overlay attacks, and from ~14.8% to 61.1% under inductive attacks. When paired with Chain-of-Thought (CoT) prompts, it achieved an outstanding 99.3% success rate.
  • Flawless Performance on LLaVA: On the LLaVA-v1.6-Vicuna-13B model, LaSM alone achieved a 100% defense success rate across all settings.
  • Real-World Multi-Step Utility: In multi-step AndroidControl tasks, LaSM increased the full Task Success Rate (TSR) from 18.75% to 30.36% while introducing negligible changes to action types or grounding accuracy in benign scenarios.
  • Cross-Backbone Generalization: As a plug-and-play add-on, LaSM consistently improved robustness across various models, including Qwen2-VL-2B, OS-Atlas-Pro-7B, and LLaMA-3.2-11B-Vision-Instruct.

Limitations and Future Work

  • Minimal Interface Vulnerability: When a pop-up appears on an extremely blank or minimal interface, the model lacks competing visual context and still tends to blindly follow the pop-up's instructions.
  • Text Input Shortcuts: During text input sequences (TYPE actions), the model heavily overfits to the visual pattern of the keyboard layout, causing it to completely ignore appearing pop-ups and continue typing.
  • Model-Specific Hyperparameters: The optimal scaling factor $\alpha$ and the exact layer range form a bell-shaped response curve unique to each model architecture, requiring a brief calibration phase before deployment.

Summary updated

Abstract

Graphical user interface (GUI) agents built on multimodal large language models (MLLMs) have recently demonstrated strong decision-making abilities in screen-based interaction tasks. However, they remain highly vulnerable to pop-up-based environmental injection attacks, where malicious visual elements divert model attention and lead to unsafe or incorrect actions. Existing defense methods either require costly retraining or perform poorly under inductive interference. In this work, we systematically study how such attacks alter the attention behavior of GUI agents and uncover a layer-wise attention divergence pattern between correct and incorrect outputs. Based on this insight, we propose \textbf{LaSM}, a \textit{Layer-wise Scaling Mechanism} that selectively amplifies attention and MLP modules in critical layers. LaSM improves the alignment between model saliency and task-relevant regions without additional training. Extensive experiments across multiple datasets demonstrate that our method significantly improves the defense success rate and exhibits strong robustness, while having negligible impact on the model's general capabilities. Our findings reveal that attention misalignment is a core vulnerability in MLLM agents and can be effectively addressed through selective layer-wise modulation. Our code can be found in https://github.com/YANGTUOMAO/LaSM.
BibTeX
@inproceedings{yan2026lasm,
  author = {Zihe Yan and Jiaping Gui and Zhuosheng Zhang and Gongshen Liu},
  title = {{LaSM: Layer-wise Scaling Mechanism for Defending Pop-up Attack on GUI Agents}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=XPqrbVstIF},
}
Figure