Skip to main content

Domain Allowlist

The domain allowlist restricts browser navigation and network requests to a set of trusted domains, preventing AI agents from navigating to unexpected sites or exfiltrating data.

Quick Start

How It Works

When enabled, the domain allowlist blocks:
  1. Document navigation - Prevents navigating to non-allowed domains
  2. Sub-resource requests - Blocks scripts, images, stylesheets, fetch/XHR to non-allowed domains
  3. WebSocket connections - Prevents WebSocket connections to non-allowed domains
  4. EventSource connections - Blocks Server-Sent Events to non-allowed domains
  5. navigator.sendBeacon - Prevents beacon requests to non-allowed domains
Blocked requests are aborted with blockedbyclient error.

Domain Pattern Syntax

Exact Match

Allows:
  • https://example.com
  • http://example.com
Blocks:
  • https://www.example.com
  • https://api.example.com
  • https://other.com

Wildcard Subdomains

Allows:
  • https://app.example.com
  • https://api.example.com
  • https://cdn.example.com
  • https://example.com (bare domain also matches)
Blocks:
  • https://other.com
Wildcard patterns like *.example.com automatically match the bare domain example.com for convenience.

Multiple Domains

Allows:
  • https://example.com
  • https://api.example.com
  • https://images.cdn.net
  • https://assets.cdn.net
Blocks:
  • https://other.com

Special URLs

Data and Blob URLs

Data URIs and blob URLs are handled specially:
  • Sub-resources: Allowed (images, scripts from data: or blob: URLs)
  • Navigation: Blocked (cannot navigate to data: or blob: URLs)
This prevents data exfiltration via data: URL navigation while allowing legitimate use of data URIs for images, etc.

About: and Chrome: URLs

Internal browser URLs (about:, chrome:, chrome-extension:) are blocked.

Implementation Details

Route-based Filtering

Domain filtering is implemented via Playwright’s route interception at the browser context level:
See domain-filter.ts:src/domain-filter.ts:121 for full implementation.

JavaScript Monkey-patching

WebSocket, EventSource, and navigator.sendBeacon are patched via an init script to enforce domain allowlist at the JavaScript API level:
See domain-filter.ts:src/domain-filter.ts:33 for full implementation.

Security Note

This JavaScript monkey-patching is a best-effort defense. If page scripts can use eval(), they could theoretically restore the original WebSocket/EventSource implementations. To close this loophole, deny the eval action category in your action policy:

Common Patterns

Single Domain Application

Multi-Domain Application with CDN

Development Environment

Best Practices

1. Include CDN Domains

Many applications load resources from CDNs. Include CDN domains in the allowlist:
Without CDN domains, the page may fail to load resources (images, scripts, stylesheets).

2. Use Wildcards for Subdomains

Instead of listing all subdomains:

3. Test Before Deploying

Test the domain allowlist in headed mode to identify missing domains:

4. Combine with Action Policy

For maximum security, combine domain allowlist with action policy:
With policy.json:

Configuration File

Set domain allowlist in agent-browser.json:
Priority order:
  1. CLI flag --allowed-domains
  2. Environment variable AGENT_BROWSER_ALLOWED_DOMAINS
  3. Config file allowedDomains

Environment Variables

VariableDescriptionExample
AGENT_BROWSER_ALLOWED_DOMAINSComma-separated list of allowed domain patternsexample.com,*.cdn.example.com

Programmatic API

Install domain filter programmatically:

Helper Functions

Troubleshooting

Page fails to load resources

Symptom: Page loads but images, styles, or scripts are missing. Solution: Check network requests to identify blocked domains:
Add missing CDN domains to allowlist:

WebSocket connection blocked

Symptom: Error in console: WebSocket connection to wss://... blocked by domain allowlist Solution: Add the WebSocket server domain to allowlist:
Symptom: Cannot navigate to a new page after initial load. Solution: The target domain is not in the allowlist. Add it:

See Also