Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

update docs to include bad examples

Nick Sweeting2c933c34ece8
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 3baa86439..5b2a1f814 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -957,7 +957,7 @@ class BrowserContext:
parsed_url = urlparse(url)
# Special case: Allow 'about:blank' explicitly
- if url == 'about:blank' or parsed_url.scheme in ('chrome', 'brave', 'edge', 'chrome-extension'):
+ if url == 'about:blank' or parsed_url.scheme.lower() in ('chrome', 'brave', 'edge', 'chrome-extension'):
return True
# Extract only the hostname component (without auth credentials or port)
@@ -984,12 +984,12 @@ class BrowserContext:
return True
else:
# Standard matching (exact or subdomain)
- if domain == allowed_domain or domain.endswith('.' + allowed_domain):
+ if domain == allowed_domain:
return True
return False
except Exception as e:
- logger.error(f'⛔️ Error checking URL allowlist: {str(e)}')
+ logger.error(f'⛔️ Error checking URL allowlist: {type(e).__name__}: {e}')
return False
async def _check_and_handle_navigation(self, page: Page) -> None:
diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdx
index 3d47932de..905fb41d4 100644
--- a/docs/customize/browser-settings.mdx
+++ b/docs/customize/browser-settings.mdx
@@ -174,11 +174,16 @@ async def run_search():
- **allowed_domains** (default: `None`)
List of allowed domains that the agent can access. If None, all domains are allowed.
- Example: ['google.com', 'wikipedia.org'] - Here the agent will only be able to access google and wikipedia.
+ Example: ['google.com', '*.wikipedia.org'] - Here the agent will only be able to access google and wikipedia.
Glob patterns are supported:
- - `['*.example.com']` will match both `sub.example.com` and `example.com`
- - `['*google.com']` will match `google.com`, `www.google.com`, and `anygoogle.com`
+ - `['example.com']` ✅ will match only `example.com` exactly, subdomains will not be allowed.
+ It's always the most secure to list all the domains you want to give the access to explicitly e.g.
+ `['google.com', 'www.google.com', 'myaccount.google.com', 'mail.google.com', 'docs.google.com']`
+ - `['*.example.com']` ⚠️ **CAUTION** this will match `example.com` and *all* subdomains.
+ Make sure *all* the subdomains are safe for the agent! `abc.example.com`, `def.example.com`, ..., `useruploads.example.com`, `admin.example.com`
+ - `['*google.com']` ❌ **DON'T DO THIS**, it will match `google.com`, `mail.google.com`, `docs.google.com`, etc. *but also `evilgoogle.com`*
+ - `['*.google.*]` ❌ **DON'T DO THIS**, it will match `google.com`, `google.co.uk`, `google.fr`, etc. *but also `www.google.evil.com`*
### Session Management