Skip to content

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

Bridge BrowserProfile IP address blocking

Magnus Müller0631f63f6af5
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index ab8f3513d..b23f5c660 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -201,10 +201,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- The terminal helper layer uses those values for post-navigation waits, default network-idle windows, and action helper delays.
- Proof: `test_rust_agent_translates_browser_profile_wait_timings` and `browser_script_helpers_read_wait_timing_env`.
+39. BrowserProfile IP address blocking bridge
+ - `BrowserProfile.block_ip_addresses` is serialized into `BU_BROWSER_BLOCK_IP_ADDRESSES`.
+ - The terminal helper layer rejects IP-literal hosts for `goto_url`, raw `Page.navigate`, and `http_get` when the setting is enabled.
+ - Proof: `test_rust_agent_translates_browser_profile_block_ip_addresses` and `browser_script_helpers_block_ip_address_env`.
+
## Current Verification
- `python3 -m py_compile browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`
-- `uv run pytest -q tests/ci/test_rust_agent.py` (48 tests)
+- `uv run pytest -q tests/ci/test_rust_agent.py` (49 tests)
- `cargo build -q -p browser-use-cli`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent bare_browser_connect_resolves_to_selected_managed_mode_with_launch_args -- --nocapture`
@@ -217,6 +222,7 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_highlight_env_controls_color_and_duration -- --nocapture`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_user_agent_env_builds_override_params -- --nocapture`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_helpers_read_wait_timing_env -- --nocapture`
+- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_helpers_block_ip_address_env -- --nocapture`
- Managed-headless end-to-end:
- `BROWSER_USE_TERMINAL_BINARY=/home/exedev/Developer/terminal/target/debug/browser-use-terminal BROWSER_USE_RUST_BROWSER_MODE=managed-headless BU_TASK='Open https://example.com and report the page title only.' BU_MAX_STEPS=12 timeout 300 uv run python examples/rust_agent/basic.py`
- Output: `Example Domain`
diff --git a/browser_use/rust/service.py b/browser_use/rust/service.py
index f29fa5e6f..81fcd9637 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/rust/service.py
@@ -304,6 +304,15 @@ def _extract_wait_timing_settings(
return settings
+def _extract_block_ip_addresses(browser_session: BrowserSession | None, browser_profile: BrowserProfile | None) -> bool | None:
+ session_profile = getattr(browser_session, 'browser_profile', None)
+ for profile in (session_profile, browser_profile, browser_session):
+ value = getattr(profile, 'block_ip_addresses', None)
+ if isinstance(value, bool):
+ return value
+ return None
+
+
def _extract_profile_permissions(browser_session: BrowserSession | None, browser_profile: BrowserProfile | None) -> list[str]:
values: list[str] = []
seen: set[str] = set()
@@ -958,6 +967,7 @@ class Agent(Generic[AgentStructuredOutput]):
self.browser_session, self.browser_profile
)
self.wait_timing_env = _extract_wait_timing_settings(self.browser_session, self.browser_profile)
+ self.block_ip_addresses = _extract_block_ip_addresses(self.browser_session, self.browser_profile)
self.browser_permissions = _extract_profile_permissions(self.browser_session, self.browser_profile)
self.browser_accept_downloads, self.browser_downloads_path = _extract_browser_downloads(
self.browser_session, self.browser_profile
@@ -1422,6 +1432,8 @@ class Agent(Generic[AgentStructuredOutput]):
if self.highlight_duration_ms is not None:
env['BROWSER_USE_TERMINAL_HIGHLIGHT_DURATION_MS'] = str(self.highlight_duration_ms)
env.update(self.wait_timing_env)
+ if self.block_ip_addresses is not None:
+ env['BU_BROWSER_BLOCK_IP_ADDRESSES'] = 'true' if self.block_ip_addresses else 'false'
if self.browser_permissions:
env['BU_BROWSER_PERMISSIONS'] = json.dumps(self.browser_permissions)
if self.browser_accept_downloads is not None:
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.py
index 95b7b877d..537c14a8a 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_rust_agent.py
@@ -273,6 +273,22 @@ def test_rust_agent_translates_browser_profile_wait_timings(monkeypatch):
assert env['BU_BROWSER_WAIT_BETWEEN_ACTIONS_MS'] == '125'
+def test_rust_agent_translates_browser_profile_block_ip_addresses(monkeypatch):
+ from browser_use.rust import Agent
+
+ class BrowserProfile:
+ block_ip_addresses = True
+ cdp_url = 'http://127.0.0.1:9222'
+
+ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')
+
+ agent = Agent(task='report title', browser_profile=BrowserProfile())
+ env = agent._run_env()
+
+ assert agent.block_ip_addresses is True
+ assert env['BU_BROWSER_BLOCK_IP_ADDRESSES'] == 'true'
+
+
def test_rust_agent_translates_browser_profile_headless(monkeypatch):
from browser_use.rust import Agent