Skip to content

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

add test

Nick Sweeting3a1fa0f506ca
diff --git a/tests/test_url_allowlist_security.py b/tests/test_url_allowlist_security.py
new file mode 100644
index 000000000..9a205eba0
--- /dev/null
+++ b/tests/test_url_allowlist_security.py
@@ -0,0 +1,21 @@
+from browser_use.browser.context import BrowserContext, BrowserContextConfig
+
+
+class TestUrlAllowlistSecurity:
+ """Tests for URL allowlist security bypass prevention."""
+
+ def test_authentication_bypass_prevention(self):
+ """Test that the URL allowlist cannot be bypassed using authentication credentials."""
+ # Create a context config with a sample allowed domain
+ config = BrowserContextConfig(allowed_domains=['example.com'])
+ context = BrowserContext(browser=None, config=config)
+
+ # Security vulnerability test cases
+ # These should all be detected as malicious despite containing "example.com"
+ assert context._is_url_allowed('https://example.com:[email protected]') is False
+ assert context._is_url_allowed('https://[email protected]') is False
+ assert context._is_url_allowed('https://example.com%[email protected]') is False
+ assert context._is_url_allowed('https://example.com%[email protected]') is False
+
+ # Make sure legitimate auth credentials still work
+ assert context._is_url_allowed('https://user:[email protected]') is True