# browser-use SecurityWatchdog patch for real Comet profiles browser-use 0.13.x closes existing `file://` tabs as "disallowed" on attach. This destroys the user's open local-file tabs in their real Comet profile. ## Patch (call before `BrowserSession.start()`) ```python def patch_browser_use_security_watchdog(): """Do not let browser-use close existing local/browser-scheme tabs on attach.""" try: from browser_use.browser.watchdogs.security_watchdog import SecurityWatchdog if getattr(SecurityWatchdog, '_comet_agent_file_scheme_patch', False): return original = SecurityWatchdog._is_url_allowed def patched(self, url: str) -> bool: if isinstance(url, str) and url.startswith(('file://', 'chrome://', 'devtools://', 'edge://', 'comet://')): return True return original(self, url) SecurityWatchdog._is_url_allowed = patched SecurityWatchdog._comet_agent_file_scheme_patch = True except Exception as e: print(f'WARN: browser-use security patch skipped: {e}') ``` ## Why it happens `SecurityWatchdog.on_TabCreatedEvent` checks every tab URL against `_is_url_allowed`. When `allowed_domains` is None (default), `_is_url_allowed` allows `about:blank`, `chrome://new-tab-page/`, `chrome://newtab/`, `data:`, and `blob:` — but NOT `file://`. So any existing `file://` tabs in the real Comet profile get detected as "disallowed" and closed. The patch adds `file://`, `chrome://`, `devtools://`, `edge://`, `comet://` to the allowlist. ## Alternative Pass `allowed_domains=['*']` to `BrowserSession` — but this enables glob-pattern matching which has its own caveats. The monkeypatch is more surgical.