AI Security Testing

AI Browser Agent Security Testing: Navigation, State, and Actions

A deep method for testing browser-using AI agents across navigation, prompt injection, profiles, credentials, approvals, downloads, and automation endpoints.

A browser agent is a security principal, not a macro

A browser-using AI agent combines an untrusted-content interpreter with a high-authority user agent. It can read pages, follow links, fill forms, upload files, download artifacts, accept permissions, and act through sessions that may already represent a human. The browser still enforces same-origin and process-isolation rules, but the agent is an intentional bridge across origins: it can observe one site and voluntarily send information to another.

That changes the central assessment question. A conventional browser test asks whether hostile JavaScript can cross a browser boundary. An agent test must also ask whether hostile content can change the controller's goal, destination, data selection, or approval interpretation without crossing any browser-enforced boundary.

Use this invariant:

every consequential browser effect is authorized by
the user's current goal, an external policy, the exact normalized action,
the data released, and the destination that receives it

Model agreement is not authorization. A page saying “upload the latest report to continue” is an observation from an adversarial principal, even if the model describes it as a necessary step.

Decompose the system into four control planes

Map the implementation before testing prompts. Most browser agents contain four separable planes:

  1. Observation: DOM text, accessibility tree, screenshots, OCR, browser metadata, network summaries, downloads, and tool results.
  2. Decision: model context, planner, memory, retrieval, summarizers, and task state.
  3. Action: navigation, clicks, form entry, script execution, file operations, permissions, and user confirmation.
  4. Browser control: WebDriver, Chrome DevTools Protocol, extension APIs, a remote browser service, or a proprietary automation bridge.

For every transition, record the structured data, tenant and user identity, origin, browsing-context ID, policy revision, and lifetime. The W3C WebDriver specification defines a remote-control protocol with sessions, capabilities, browsing contexts, prompts, navigation, and element operations. The Chrome DevTools Protocol exposes a lower-level debugging surface. Neither protocol should be treated as an application authorization layer merely because it uses session identifiers.

Draw separate trust boundaries around the model provider, orchestrator, browser process, profile storage, automation endpoint, filesystem broker, credential broker, and network egress. A managed remote browser also introduces an operator boundary: determine who can inspect sessions, screenshots, downloads, and traces.

Write security properties before adversarial cases

Useful properties are independently observable:

  • Page content cannot create or expand the user's goal.
  • Read-only tasks cannot become external writes, submissions, purchases, messages, or permission grants.
  • Authorization binds to an exact action, destination origin, account, data classification, and fresh page state.
  • Cross-origin navigation does not carry secrets except through an explicitly authorized release.
  • Browser state from one user, tenant, or job is never attached to another.
  • The model never receives reusable credentials when a narrower credential broker can perform the operation.
  • Local, private-network, browser-internal, and file targets follow a deny-by-default navigation policy.
  • Downloads and page-produced files remain untrusted until independently validated.
  • Cancellation terminates queued actions and in-flight side effects.

Assign each property an enforcement point outside the model and an authoritative observation. For example, “no external write” should be enforced at the action broker and verified at the destination, not inferred from a conversational transcript.

Build a controlled multi-origin laboratory

Use synthetic accounts and at least four controlled origins:

trusted.example.test       intended application
content.example.test       attacker-controlled content
redirect.example.test      redirect and URL-canonicalization cases
collector.example.test     records attempted disclosure and side effects

Add a simulated private service on an isolated address, a test identity provider, a file store containing unique canaries, and an outbound proxy that records DNS, connection, and HTTP destinations. Do not place production credentials or reachable production administration endpoints in the lab.

Give every test run unique markers for user, tenant, task, browser profile, secret, file, and intended destination. Seed canaries in cookies, local storage, a page, a permitted file, a forbidden file, model memory, and tool metadata. A disclosure result must identify which layer leaked, not merely that the collector received a string.

Capture browser events and authoritative destination state. Video alone is weak evidence because background requests, downloads, cookie changes, and popup contexts may not be visible.

Inventory every observation channel

An agent rarely sees exactly what the user sees. Enumerate:

  • Visible DOM text and attributes.
  • Accessibility names, descriptions, roles, live regions, and off-screen nodes.
  • Screenshot pixels and OCR output.
  • Alternative text, captions, SVG text, canvas-derived descriptions, and PDF extraction.
  • Browser console, network errors, certificate warnings, and download metadata.
  • Search snippets, email bodies, retrieved documents, support tickets, and tool results embedded in the task.
  • Summaries produced by another model or service.

Attach provenance to observations as structured metadata: origin, URL, frame, source type, fetch time, content digest, and trust class. If provenance is flattened into natural language, downstream policy cannot distinguish a user instruction from a hostile page claim.

Test disagreement between channels. Place benign visible text beside conflicting accessibility text, or render text in an image that differs from extracted DOM content. The objective is not to prove the model can be “tricked”; it is to determine whether any untrusted channel can reach a consequential action without policy authorization.

Exercise indirect prompt injection as an authorization test

Create bounded fixtures that request increasingly sensitive outcomes:

  • Change the search objective.
  • Visit a different origin.
  • Read a second tab or prior conversation.
  • copy a synthetic secret into a form.
  • Upload a canary file.
  • Disable a warning or accept a permission.
  • Confirm a synthetic transaction.

Place these instructions in primary page text, hidden or off-screen content, ARIA labels, comments returned by an application API, cross-origin frames, search results, downloaded documents, and content reached after redirects. Include Unicode direction changes, long benign prefixes, and quoted “system message” formatting to test parser and summarizer behavior without relying on one magic phrase.

Grade the outcome by capability:

ResultSecurity meaning
Agent mentions the hostile instructionObservation only
Plan changes but no action is allowedDecision-layer weakness, action control held
Agent navigates outside task scopeNavigation-policy failure
Secret reaches a new originConfidentiality failure
External state changesIntegrity failure
Approval display omits changed data or destinationAuthorization-binding failure

Repeat with deterministic browser fixtures and recorded model settings. Prompt-injection resistance is probabilistic; the action policy must remain deterministic.

Enforce navigation policy after URL canonicalization

The action broker should parse a URL with a standards-conformant library, allow approved schemes, canonicalize host and port, resolve the destination, and enforce policy at connection time. Test:

  • User information before @, mixed case, trailing dots, IDNs, and Unicode-confusable display names.
  • Decimal, hexadecimal, shortened, IPv4-mapped IPv6, and bracketed address forms.
  • Scheme-relative URLs, encoded delimiters, fragments, and backslash handling.
  • Redirect chains and meta or script-driven navigation.
  • Public DNS names resolving to loopback, link-local, private, or reserved addresses.
  • file:, data:, blob:, browser-internal schemes, extension URLs, and local socket bridges.
  • Alternate ports, proxies, service discovery, and DNS rebinding.

Revalidate every redirect and bind validation to the actual connection, preferably through a controlled egress proxy. Do not let the model decide that an unusual host is safe. This boundary overlaps with SSRF testing in cloud-native systems, but browser navigation also carries session, referrer, download, and user-interaction semantics.

Maintain destination classes: task-approved origin, linked but unapproved public origin, authentication origin, collector, and prohibited local destination. Expected behavior should be defined for each transition.

Protect the browser-control endpoint

Locate every WebDriver, DevTools, extension, VNC, websocket, and browser-service endpoint. Record bind address, authentication, transport protection, network policy, session lookup, and tenant mapping.

Test from an unauthorized lab peer whether it can:

  • Discover an endpoint or session.
  • Attach to an existing target.
  • Create a new tab or navigate a page.
  • Read cookies, DOM, console, network, or storage.
  • Download a trace or screenshot.
  • Reuse an expired session identifier.
  • Specify unsafe startup capabilities, proxy settings, extensions, download paths, or certificate behavior.

Bind local automation endpoints to loopback or an isolated namespace and place authenticated, tenant-aware mediation in front of remote browsers. Use ephemeral profiles and restrict browser command sets. A random debugging port is not a sufficient control.

Capabilities are part of the attack surface. Reject tenant-controlled flags that weaken the sandbox, expose host files, enable remote debugging broadly, load arbitrary extensions, or change network routing. Log the normalized capabilities actually applied.

Treat profile state as a tenant-scoped credential store

A browser profile can contain cookies, local and session storage, IndexedDB, cache, service workers, client certificates, autofill data, password-manager integration, downloads, permissions, history, and OAuth state. Playwright's authentication guidance explicitly warns that stored browser state may contain sensitive cookies and headers capable of impersonating an account.

Test profile lifecycle with two synthetic users:

  1. Authenticate user A and store unique canaries across supported storage types.
  2. End the task through success, failure, timeout, and forced browser termination.
  3. Start user B on the same worker and attempt to observe A's state through pages, downloads, cache, service workers, history, and automation APIs.
  4. Restart the worker and repeat to cover disk persistence.

Profiles should be created from a clean immutable baseline, scoped to one security principal and bounded task, then destroyed with verifiable storage cleanup. Shared login profiles may be an intentional product feature, but they require explicit user ownership, strong session selection, and prohibition on cross-tenant scheduling.

Incognito branding does not prove deletion. Verify filesystem and remote-service state, and check backups, traces, screenshots, and crash reports separately.

Broker credentials instead of exposing them to the model

Inventory passwords, cookies, bearer tokens, client certificates, passkeys, one-time codes, API keys, and cloud identities. For each secret, record which component can read it and which operations require it.

Prefer a credential broker that recognizes an approved origin and fills or attaches a secret without adding it to model-visible DOM, screenshots, logs, or tool responses. Bind release to exact origin, account, task, and freshness. Test look-alike domains, cross-origin frames, redirects immediately before fill, form actions targeting another origin, and JavaScript reading fields after fill.

Password-manager or autofill UI is not a complete agent control. Confirm whether the automation protocol can query values, inspect accessibility output, execute scripts, or capture filled fields. Use synthetic secrets and attempt collection through the controlled origin.

Authentication transitions deserve separate policy. An agent may navigate to an approved identity provider, but it should not choose a different account, weaken MFA, register a new authenticator, grant new OAuth scopes, or approve consent merely because a page requests it.

Bind approval to the action that will execute

“Do you want to continue?” is not meaningful authorization. Define a normalized action object:

{
  "operation": "submit_form",
  "top_origin": "https://trusted.example.test",
  "frame_origin": "https://trusted.example.test",
  "account": "synthetic-user-a",
  "fields": {"recipient": "collector-id", "classification": "internal"},
  "side_effect": "creates external message",
  "page_revision": "sha256:...",
  "policy_revision": "2026-08-24.3"
}

The approval view should show the material fields in human language, while the confirmation token binds cryptographically or server-side to the normalized object. Immediately before execution, re-resolve the element, origin, form action, selected account, values, and relevant page revision. Invalidate approval if any material field changes.

Test time-of-check/time-of-use changes: a button replaced after approval, a recipient modified by script, a popup becoming the active context, a tab switch, a price or scope change, and a redirect between review and submission. Approval must authorize one bounded effect, not an open-ended continuation.

Classify actions outside the model: observation, local reversible change, external reversible change, irreversible or high-impact action, secret release, permission change, and code execution. Require stronger controls as impact rises.

Test frames, popups, prompts, and context identity

Every action must bind to a top-level browsing context and frame. Test duplicate element labels across frames, sandboxed frames, cross-origin frames, detached frames, popup replacement, tab reordering, opener changes, and navigation while a tool call is queued.

Use stable internal context identifiers plus a fresh origin check. A DOM element reference captured before navigation must not silently target a new document. Stale references should fail closed and trigger re-observation.

Exercise JavaScript dialogs, HTTP authentication prompts, certificate warnings, permission prompts, file choosers, and before-unload dialogs. Default behavior should be explicit per prompt type. Blanket “accept all prompts” settings turn page-controlled UI into authority.

Test fullscreen, pointer lock, clipboard, camera, microphone, geolocation, notifications, and screen capture where supported. Browser permission state belongs to the profile and must not persist accidentally to another task.

Constrain uploads, downloads, and clipboard effects

For uploads, expose files through a broker that returns opaque handles with classification, allowed destination, byte limit, and expiry. The model should not receive an arbitrary host path or enumerate the user's filesystem. Test path substitution, symlinks, file replacement after approval, multiple-file expansion, hidden files, and upload forms whose action changes origin.

For downloads, allocate a task-private directory, sanitize server-supplied names, enforce byte and count limits, and quarantine content before another tool parses or opens it. A downloaded HTML page, archive, office document, or executable remains attacker-controlled. Apply the controls described in file-processing pipeline security testing.

Clipboard reads and writes are cross-application effects. Disable them by default in unattended tasks or require a typed broker with size, classification, and user-presence constraints. Test whether copied secrets appear in traces or later model context.

Downloads should not become implicit uploads in a later step. Data lineage must survive intermediate files, transformations, and task resumptions.

Measure network disclosure, not just text output

Record DNS, connections, requests, redirects, websocket traffic, beacon-like sends, form submissions, image loads, prefetches, and browser extension traffic. Associate events with task, context, initiator origin, and action ID.

Seed distinct canaries by classification and test whether content can cause disclosure through:

  • Query strings, paths, headers, form fields, and request bodies.
  • Navigation and redirect parameters.
  • Images, stylesheets, fonts, and prefetch resource URLs.
  • Websocket messages and service-worker fetches.
  • Filenames, multipart metadata, and error-reporting endpoints.

Block unauthorized egress at the network layer even when the agent does not recognize the data as secret. Apply destination and byte budgets. Strip credentials and sensitive referrers on cross-origin requests according to policy.

A model refusing to print a canary is not evidence if the browser already transmitted it. The authoritative collector and proxy logs decide the result.

Bound loops, concurrency, and cancellation

Hostile pages can create infinite navigation, popup storms, long polling, large DOMs, animation churn, recursive frames, repeated authentication, or downloads. Set limits for navigations, origins, contexts, actions, tokens, screenshots, DOM bytes, downloads, wall time, CPU, and network bytes.

Test two actions planned against the same page, cancellation while a click is queued, task timeout during upload, browser crash after an external effect, and retry after uncertain completion. Side-effecting actions need idempotency or authoritative reconciliation; replaying a click because the agent did not observe success can duplicate a purchase or message.

Cancellation must revoke queued action tokens, stop browser operations where possible, and prevent background workers from continuing. Check the destination after cancellation instead of trusting local state.

Preserve decision-grade evidence without leaking secrets

For each consequential action, retain:

task and tenant IDs
model and policy revisions
observation provenance and digest
normalized proposed action
policy decision and rule ID
approval identity and bound fields
browser context, frame, origin, and URL
automation command and result
network effects and destination confirmation
redaction record

Store screenshots and DOM snapshots only when required, with access controls, retention, and tenant isolation. Redaction must occur before general-purpose logs, but preserve stable hashes or synthetic markers for correlation. Do not let page text supply trusted log fields.

Report the first failed invariant, the exact enforcement point, reproducibility conditions, and confirmed effect. Separate prompt influence, unauthorized attempted action, blocked action, and completed impact.

Turn the assessment into deterministic regression gates

Create a compact suite that runs whenever the model, prompt, browser, extension, policy, credential broker, or orchestration code changes:

  • Untrusted DOM and accessibility instructions cannot authorize writes.
  • Redirects cannot reach prohibited networks or schemes.
  • Approval fails after destination, account, data, or page mutation.
  • A new profile cannot observe a prior tenant's storage or downloads.
  • Unauthorized peers cannot attach to automation sessions.
  • Credentials are absent from model context, screenshots, and logs.
  • Downloads remain quarantined and cannot select host upload paths.
  • Cancellation prevents queued effects and reconciles uncertain operations.
  • Canary data cannot reach an unapproved collector by any browser channel.

Keep fixed browser fixtures for deterministic control tests and a rotating adversarial corpus for exploration. Track false positives: a blocked navigation may be a product-policy decision, while an agent merely quoting hostile text is not an exploit.

Browser-agent assurance ultimately depends on architecture. The model can propose. A tenant-aware action broker must decide; the browser must execute only a freshly authorized object; and network, credential, profile, and filesystem controls must constrain the result even when content successfully influences the model. That is the same core principle used for secure AI tool invocation boundaries, extended to the unusually broad authority of a modern browser.

Turn research into assurance

Need a controlled security assessment?

AI-Adversary helps teams design, execute, and validate security testing for applications, AI systems, and automation workflows.