TL;DR
AI agents designed to navigate the web suffer from a classic operating system flaw: Time-of-Check to Time-of-Use (TOCTOU) vulnerabilities. Because Large Language Model (LLM) reasoning takes several seconds, dynamic or malicious web pages can change between the time an agent observes the page and the time it executes an action, leading to hijacked clicks or bypassed constraints. This paper exposes this widespread vulnerability across 10 popular open-source agents and introduces a lightweight, zero-overhead defense that effectively eliminates the exploit window.
What Problem Does This Paper Address?
Large language models are increasingly being deployed as "browser-use agents" to automate tasks like online shopping, form filling, and account management. These agents typically operate in a loop: they observe the current web page (via the DOM or a screenshot), plan their next action using an LLM, and then execute that action.
The core issue is latency. LLM inference is slow, often taking anywhere from several seconds to tens of seconds. During this planning window, a web page is still live and can change asynchronously due to delayed scripts, ads, or malicious updates.
The authors frame this temporal mismatch as a TOCTOU vulnerability. Because browsers lack an atomic "check-and-act" primitive for external automation, an agent might decide to click a button based on a stale snapshot, only for a malicious overlay or a price change to occur right before the click lands.
Methods
The authors systematically categorize how these vulnerabilities can be exploited into three attack vectors:
- Type I (UI Changes): Late-loading content or pop-ups shift elements or cover the intended target area, causing coordinate-based clicks to hit unintended elements (e.g., clicking a malicious ad instead of a "Continue Reading" button).
- Type II (Data Changes): Content updates asynchronously (like a stock or ticket price refreshing) after the agent checks it, causing it to violate user-imposed constraints (e.g., buying a ticket that just jumped past a budget ceiling).
- Type III (Expiring State): Time-sensitive elements like OTPs or CAPTCHAs expire during the LLM's long planning phase, causing persistent execution failures.
To mitigate this, the authors design a Pre-execution Validation framework. Instead of overhauling the LLM or agent prompts, they introduce a parallel monitoring layer using browser-native APIs (MutationObserver and ResizeObserver). This layer tracks structural DOM edits, text updates, and layout shifts during the planning phase. Immediately before the agent dispatches an action, the validator checks the queue. If any relevant changes are detected, the action is aborted, and the user is alerted.
Datasets
The authors introduce DYNWEB, a benchmark specifically designed to evaluate TOCTOU vulnerabilities under controlled, reproducible timing conditions. It includes:
- 9 Synthesized Cases: Spanning news browsing, online shopping, stock trading, and form submissions with deterministic update schedules.
- 5 Real-World Scenarios: Testing organic page dynamics on popular websites including eBay, Amazon, Yahoo Finance, CoinMarketCap, and Google Sheets.
Key Insights and Ideas
- Observation space alone doesn't fix TOCTOU: You might think that agents reading the structured DOM are safe compared to vision-based agents reading screenshots. While DOM-based agents are more robust against some layout shifts (Type I) because they target elements via stable selectors, they remain completely vulnerable to data changes (Type II) and expiring states (Type III).
- Prompting is useless as a defense: Simply adding a warning to the system prompt telling the agent to "be cautious of page updates" yielded zero measurable improvement. The agent cannot think its way out of a race condition that happens after its thinking phase is already complete.
- Exploitation shifts to a game of probability: By introducing pre-execution validation, the vulnerability window shrinks from a massive multi-second planning phase down to a residual ~0.13-second window between validation and execution. Because LLM planning times vary randomly based on hardware and network delays, attackers cannot reliably predict when this tiny window will occur.
Key Results
- Widespread Vulnerability: All 10 evaluated open-source browser agents (including Browser-Use, Midscene, UI-TARS, and Agent-S) were found to be vulnerable to at least one type of manipulation.
- 100% Attack Success Rate: Without defenses, adversarial page changes successfully triggered TOCTOU failures across 100% of the benchmarked cases.
- Complete Mitigation: Enabling the pre-execution validation framework dropped the successful attack trigger ratio to 0% across all tested scenarios.
- Negligible Overhead: The defense adds less than 0.05 seconds of latency per interaction loop, which is completely unnoticeable compared to the 5–15 seconds typically required for LLM reasoning.
Limitations and Future Work
While highly effective, pre-execution validation does not provide strict atomicity. A residual window of roughly 130 milliseconds remains where a perfectly timed page change could still slip through. Furthermore, highly dynamic but benign websites (e.g., pages with constantly rotating ad carousels or live tickers) might trigger false positives, causing the agent to frequently pause and alert the user unnecessarily.
The authors suggest that true, robust atomicity will ultimately require closer cooperation with web browsers themselves—specifically through new primitives like a scoped "freeze" command or transactional interaction APIs that allow agents to submit actions alongside strict preconditions.
Summary updated