Skip to content

get_ws_url() should fail CLOSED for a named/managed daemon instead of scanning the default Chrome profile #479

Description

@alipsky

Summary

get_ws_url() (src/browser_harness/daemon.py:104) falls back to scanning the default Chrome profiles and then probing ports 9222/9223 whenever BU_CDP_URL/BU_CDP_WS is unset. For a named/managed daemon (one started via ensure_daemon(name=...) to drive a dedicated, isolated automation Chrome), that fallback is a footgun: on any daemon respawn where the env doesn't carry BU_CDP_URL, the daemon silently attaches to the user's daily-driver Chrome — or pops the chrome://inspect "Allow remote debugging" dialog on Chrome 136+.

Why it matters

A managed caller sets BU_NAME + BU_CDP_URL to pin a daemon to an isolated Chromium. But ensure_daemon() re-runs on every helper invocation, and on a respawn (parent restart, session teardown, zombie Chromium) a caller that carried only BU_NAME loses the pin. get_ws_url() then:

  1. daemon.py:126 — scans PROFILES (the default user-data-dirs), attaching to the user's real Chrome;
  2. daemon.py:154 — probes 9222/9223, silently attaching to whatever is listening there.

Today this only appears safe because Chrome 136+ gates the default profile behind the "Allow" dialog — i.e. it fails closed by accident. If the user has a pre-authorized debug Chrome on 9222, it drives it silently. This bit us as a real cross-project daily-driver breach (a downstream broker's ADR-022 firewall).

Proposed fix

An opt-in fail-closed guard so a managed daemon never falls back to local discovery. Either:

  • honor a BU_NO_LOCAL_FALLBACK=1 env, or
  • infer it when the daemon was started with a name (managed daemons are, by definition, pinned).

When set, and BU_CDP_URL/BU_CDP_WS is absent or unreachable, get_ws_url() should raise rather than reach the PROFILES scan (daemon.py:126) or the 9222/9223 probe (daemon.py:154) — a loud, honest failure that says "the pinned endpoint is gone, relaunch the session," never a silent attach to the user's Chrome.

Related

Distinct from #291 (that was a /json/version 404 fallback for the BU_CDP_URL happy path). This is about refusing the default-profile fallback entirely for pinned daemons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions