Skip to content

The agent that grows with you

fix: raw CDP Input.* text is not screened as a request target

Teknium9a0bbf03af77
diff --git a/tests/tools/test_browser_eval_ssrf.py b/tests/tools/test_browser_eval_ssrf.py
index e05ac53d749..3ceb40922af 100644
--- a/tests/tools/test_browser_eval_ssrf.py
+++ b/tests/tools/test_browser_eval_ssrf.py
@@ -123,3 +123,6 @@ def test_raw_cdp_url_params_are_screened_even_when_the_open_page_is_public(monke
assert (verdict is None) == local_backend
public = {"frameId": "F", "url": "https://93.184.216.34/", "options": {}}
assert guard(method="Network.loadNetworkResource", params=public, endpoint="ws://x", target_id="T") is None
+ # Typing a URL fetches nothing: text input stays allowed, metadata and LAN addresses alike.
+ for typed in (metadata, "http://192.168.1.10/"):
+ assert guard(method="Input.insertText", params={"text": typed}, endpoint="ws://x", target_id="T") is None
diff --git a/tools/browser_cdp_tool.py b/tools/browser_cdp_tool.py
index aae2d3ff26a..c567153a869 100644
--- a/tools/browser_cdp_tool.py
+++ b/tools/browser_cdp_tool.py
@@ -197,6 +197,9 @@ def _current_page_private_url(endpoint: str, target_id: Optional[str]) -> Option
return next((u for u in page_urls if u and not u.startswith(_ORIGINLESS_PAGE_PREFIXES) and url_blocked(u)), None)
+_TEXT_INPUT_METHOD_PREFIX = "Input."
+
+
def _param_url_literals(value: Any, key: str = "") -> list[str]:
"""Every URL a CDP call's params name: each ``url`` value whole, plus the ``http(s)://`` literals in
every string at any depth (``Network.loadNetworkResource``, ``Runtime.callFunctionOn`` bodies,
@@ -229,7 +232,8 @@ def _browser_cdp_private_guard(*, method: str, params: dict[str, Any], endpoint:
return _blocked(template.format(literal), method)
# The cloud-metadata floor is unconditional for every method, as in browser_exec's _url_policy_error
# (#16234): with the private guard on or off, sidecar and local Chromium included.
- literals = _param_url_literals(params or {})
+ # Input.* only types text or dispatches key/mouse events; a URL in its text is never fetched by the call.
+ literals = [] if method.startswith(_TEXT_INPUT_METHOD_PREFIX) else _param_url_literals(params or {})
metadata = next((u for u in literals if is_always_blocked_url(u)), None)
if metadata:
return _blocked(f"Blocked: CDP {method} targets a cloud metadata endpoint ({metadata}).", method)