Research
BrowseSafe: Understanding and Preventing Prompt Injection Within AI Browser Agents
Overview Research area: Security of AI agents, specifically prompt injection attacks against AI browser agents (LLM agent security, adversarial robustness, and detection benchmarks). Technical level:
- arXiv
- 2511.20597
- Published
- 2025-11-25
- Authors
- Kaiyuan Zhang, Mark Tenenholtz, Kyle Polley, Jerry Ma, Denis Yarats, Ninghui Li
AI summary
Overview
- Research area: Security of AI agents, specifically prompt injection attacks against AI browser agents (LLM agent security, adversarial robustness, and detection benchmarks).
- Technical level: Intermediate. The paper is readable without deep machine-learning background, but it assumes familiarity with large language models, agent tool calls, and web content (HTML).
- Scope: The paper builds a realistic prompt injection benchmark from production browser-agent data, empirically diagnoses why existing detectors fail, and proposes a multi-layered defense called BrowseSafe.
What This Paper Is About
Prior work has shown that prompt injection is a real attack vector for AI web agents, but it has not explained why detection fails when agents operate in real, messy web environments rather than in clean, single-line test cases. Existing benchmarks typically use simplified text, single-line injections, and no benign "look-alike" content, so they do not reflect what an agent actually sees in a tool-call output. The authors build a benchmark of attacks embedded in realistic HTML (BrowseSafe-Bench) and use it to measure how over 20 open- and closed-weight models perform, then design a defense that responds to the specific failure modes they measured.
Key Contributions
- BrowseSafe-Bench, a benchmark of 14,719 constructed malicious and benign samples, partitioned into a training set of 11,039 samples and a test set of 3,680 samples. It varies 11 attack types, 9 injection strategies, 5 distractor types, 5 context-aware generation types, 5 domains, and 3 linguistic styles, and is grounded in 100,000 anonymized and redacted tool-call outputs sampled from a production browser agent.
- BrowseSafe, a multi-layered defense that enforces trust boundaries on tool outputs, preprocesses raw web content to strip AI-generated annotations, runs a parallelized fine-tuned detection classifier with conservative OR-based aggregation over chunks, and intervenes by replacing flagged tool output with a placeholder.
- A comprehensive empirical evaluation of over 20 open- and closed-weight AI models (23 frontier models in the case studies) on BrowseSafe-Bench across five evaluation metrics, quantifying the fragility of current detectors.
- A generalization ablation that isolates which benchmark axis is hardest to transfer to, plus a same-data fine-tuning comparison to show the benchmark carries reusable training signal.
Main Findings
- Benign distractors break detectors: Detection accuracy is 90.5% on "clean" samples with zero distractors, but drops to 81.3% with just three distractor elements, then stays in a band between 79.4% and 82.9%. The authors describe this as roughly a 10-point drop (90% to 81%) caused by reliance on spurious correlations rather than semantic understanding.
- Hidden attacks are caught, visible rewrites are not: Attacks placed in non-rendered HTML (data attributes, hidden form fields, HTML comments) yield 87–92% balanced accuracy, while attacks woven into visible, context-aware rewritten content yield 69–75% — evading detection at nearly twice the rate. Footer rewrite and table cell rewrite are the most challenging strategies.
- Sophisticated wording evades detection: Accuracy falls from 84.6% for explicit attacks to 78.1% for indirect and 75.3% for stealth styles, indicating keyword matching rather than understanding of malicious intent.
- Multilingual attacks are the hardest category: Averaged across models, the multilanguage attack type has the lowest balanced accuracy at 76.0%, versus 85.0% for system prompt exfiltration and 84.1% for URL segment attacks. The training set contains only 184 multilingual samples.
- General reasoning beats small safety classifiers: PromptGuard-2 (22M and 86M) achieves F1 scores of 0.350 and 0.360, hampered by low recall (0.213 and 0.221). The gpt-oss-safeguard models reach F1 of 0.730 to 0.796. GPT-5 and Sonnet 4.5 families generally land between F1 0.840 and 0.863.
- Fine-tuning wins on the same test set: BrowseSafe reaches F1 0.904, precision 0.978, recall 0.841, and balanced accuracy 0.912, compared with Sonnet 4.5 (32K) at F1 0.863, precision 0.935, and balanced accuracy 0.873.
- A same-data control confirms the benchmark's value: Fine-tuning Qwen3-8B on the 11,039-example training split raises F1 from 0.559 to 0.765 and recall from 0.392 to 0.626 at a matched 1% false-positive operating point. The authors report the full BrowseSafe system still leads that same-data fine-tuned model by 0.14 F1 and 0.21 recall.
- Reasoning settings matter more than context length: Haiku 4.5 F1 varies only from 0.805 to 0.810 across 1K, 8K, and 32K context settings, and Sonnet 4.5 stays at 0.862–0.863. Disabling Sonnet 4.5's thinking drops F1 to 0.807. Sonnet 4.5's thinking configurations also produce 613 to 669 refusals, while most other models produce 0 refusals.
- Latency is a practical ceiling: Sonnet 4.5 scores high F1 but takes 23 to 36 seconds, while GPT-5 and GPT-5 Mini cluster around 2 seconds at 75–85% F1. BrowseSafe achieves over 90% F1 at under 1 second of latency.
- Unseen injection strategies are the hardest generalization case: Holding out URLs raises F1 from the 0.905 baseline to 0.935; holding out attack types lowers it to 0.863; holding out injection strategies lowers it to 0.788.
Methodology in Plain English
The authors started by sampling 100,000 anonymized and redacted tool-call outputs from a production browser agent, filtering for common domains, quality, and length. They used these to build realistic HTML scaffolds rather than simplified text or accessibility-tree representations. Samples were produced through a four-step pipeline: extracting and anonymizing text content from real sites; wrapping it in one of eight HTML template styles; injecting benign "distractors" (navigation bars, forms, command-like text) into both benign and malicious samples; and finally injecting attacks either by traditional hidden placement (HTML comments, data attributes) or by LLM-based context-aware rewriting that blends the payload into visible page content.
The benchmark treats the attack objective, its HTML placement, and its wording as independent choices, so the same goal can appear in different locations and registers. They then ran every benchmark sample's full HTML (up to 80k tokens, untruncated) through each candidate detector and computed standard binary classification metrics: F1, precision, recall, balanced accuracy, and refusal counts.
For defense, they treat all browser tool output as untrusted, strip AI-generated annotations before classification so adversaries cannot exploit summarization bias, and classify fixed-window chunks in parallel with a conservative OR rule that flags the whole document if any chunk is malicious. When something is flagged, the tool output is replaced with a placeholder so the agent never sees the payload. The detector is a fine-tuned Qwen3-30B-A3B-Instruct-2507 (3B active parameters at inference), trained for one epoch with learning rate 1e-5 and weight decay 0.1, with hard negatives containing realistic distractors to prevent overfitting to attack vocabulary.
Why This Matters
Impact on research: The paper shifts the evaluation question from "can a detector spot an injection?" to "why do detectors fail under realistic conditions?" It isolates four concrete failure axes — distractors, visible placement, linguistic sophistication, and multilingual content — and shows that unseen injection strategies, not unseen websites or attack goals, are the main generalization bottleneck. It also releases both the benchmark (huggingface.co/datasets/perplexity-ai/browsesafe-bench) and the model (huggingface.co/perplexity-ai/browsesafe).
Real-world applications:
- Browser agents that summarize forums, Reddit posts, or GitLab issues, where attackers can hide instructions in user-generated content.
- Productivity and travel-planning agents that autonomously complete multi-step workflows and can act on the user's behalf.
- Email and messaging agents that process untrusted third-party content and may leak data or follow injected instructions.
- Enterprise deployments that need a low-latency detection layer, since 23-to-36-second detection latency is unusable in a synchronous agent loop.
Industry relevance: The work comes from Perplexity with academic collaborators, and it evaluates named commercial and open models (GPT-5, GPT-5 mini, Haiku 4.5, Sonnet 4.5, gpt-oss-safeguard, PromptGuard-2). It argues that prompt injection security is an architecture problem, not just a model-alignment problem, and that fine-tuned specialized detectors can beat frontier general-purpose models on both accuracy and latency.
Future Directions
- Multilingual coverage: The training set contains only 184 multilingual samples, and multilingual attacks are the weakest category at 76.0% balanced accuracy, so expanding this coverage is explicitly called out as a priority.
- Robustness to unseen injection strategies: Holding out injection strategies drops F1 to 0.788, the largest generalization gap in the ablation. The authors frame this as a fundamental property of any learning-based detector rather than something a single fix resolves.
- Cheaper detection options: The authors note that most benchmarked models would meet or exceed their detector if fine-tuned on this data, and that PromptGuard-2 can run on CPU at better latency than Qwen3-30B-A3B, suggesting narrow-scope deployments may be viable.
- Understanding refusal behavior: Sonnet 4.5 produces hundreds of refusals (up to 669) under reasoning configurations, which the paper treats as an operational reliability concern and analyzes further in its appendix.
Target Audience
This paper is most useful to security researchers and engineers building or evaluating AI browser agents, to model developers working on prompt injection detection and fine-tuned safety classifiers, and to product teams deciding whether to rely on frontier API models versus a specialized low-latency detector. It is also relevant to benchmark designers who need realistic, distractor-laden evaluation data rather than clean synthetic injections. Readers need only a working understanding of LLM agents and web content; the paper's metric definitions and benchmark taxonomy are stated explicitly.
Authors’ abstract
The integration of artificial intelligence (AI) agents into web browsers introduces security challenges that go beyond traditional web application threat models. Prior work has identified prompt injection as a new attack vector for web agents, yet the resulting impact within real-world environments remains insufficiently understood. In this work, we examine the landscape of prompt injection attacks and synthesize a benchmark of attacks embedded in realistic HTML payloads. Our benchmark goes beyond prior work by emphasizing injections that can influence real-world actions rather than mere text outputs, and by presenting attack payloads with complexity and distractor frequency similar to what real-world agents encounter. We leverage this benchmark to conduct a comprehensive empirical evaluation of existing defenses, assessing their effectiveness across a suite of frontier AI models. We propose a multi-layered defense strategy comprising both architectural and model-based defenses to protect against evolving prompt injection attacks. Our work offers a blueprint for designing practical, secure web agents through a defense-in-depth approach.