Skip to content

feat(browser): standalone extension relay daemon with native-host wake-up - #128379

Merged
steipete merged 10 commits into
mainfrom
steipete/standalone-extension-relay-daemon
Aug 30, 2026
Merged

steipete merged 10 commits into
mainfrom
steipete/standalone-extension-relay-daemon

Conversation

@steipete

@steipete steipete commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a Chrome extension with a direct-loopback pairing loses browser automation when no local Gateway or browser node is serving its relay. A tunnel to a remote Gateway does not supply that same-host listener.

Installed testing also exposed two broken supported flows: a native-woken daemon prevented later Gateway browser control with EADDRINUSE, and Gateway-owned browser evaluation could hang after a successful tab listing because an execution-context event overtook its initialization response. Both are repaired and now pass real installed Chrome proof.

Why This Change Was Made

The browser plugin owns an on-demand standalone daemon, and Gateway now distinguishes owning a listener from borrowing authenticated access to its real bridge. Each configured profile/port has one authoritative bridge in either startup order. Ordinary browser work remains CDP/Playwright; a narrow, existing-v2-authenticated owner channel supplies readiness, bounded connection-local operation references, and forwarding of authenticated Gateway extension ingress. Closing Gateway's lease does not stop the daemon or unrelated external clients.

The native host validates the reconnecting extension's saved port against configured extension profiles before waking it. Automatic wake accepts only the canonical 127.0.0.1 address the daemon serves. The new daemon defaults to mutual v2 authentication; the existing explicit browser.extensionRelay.allowLegacyAuth=true opt-in remains available. Normal automatic bootstrap retains its Gateway route.

Connected repairs preserve the same ownership boundaries: descriptor-owned POSIX relay-secret reads; guarded discovery of both Chromium Preferences and Secure Preferences; raw/WebSocket error ownership through close; immediate/coalesced legacy ingress admission; and cleanup acknowledgement distinct from best-effort final notification delivery. Runtime initialization now waits for earlier frame-tree replies on the exact logical session without serializing unrelated clients, Fetch responses, dialog handling, or other CDP commands.

User Impact

With a supporting extension/native-host build, a configured direct-loopback pairing can recover its local relay on reconnect without a running Gateway. External authenticated CDP clients can use it directly. Core openclaw browser actions still use a Gateway, which can now join an already-running daemon safely. Access revocation, opt-out, exact origins, profile/session generations, and real native cleanup remain authoritative.

The daemon and Gateway both need a build supporting owner access. No new configuration/environment option, dependency, SQLite schema, persistent store, SDK API, or protocol-version bump is introduced. The native request union is IPC framing, not a persistent data-model change. No v3 path, direct-DevTools fallback, remote-secret copying, or Gateway service installation is added. Windows retains manual setup. The unpacked source build was tested; Store v2.2.0 must not be assumed to contain this unpublished feature.

See Chrome extension setup and browser CLI.

Evidence

Published CI head: 4f47b95ffe4218f874da0df1cc576ea80bec6702. Its parent c79e3399c8c91add8019fc5ee954135cb56b00fb is the built/live-tested commit. Both have exactly source tree f389993641a5ff1341c68d105db09ed3aa22a762: the intervening commit is empty and only refreshes CI. No source file changed after review or installed proof. Fresh exact-head CI run 33340376759 and OpenGrep run 33340376753 both passed on attempt 1. Required openclaw/ci-gate succeeded, with zero failed or pending checks. Actual CI checkout eb88e616b3f1f2ed72b3f5cf9ae2644260617e18 contains the published head and repaired main. Source, installed proof, and CI are ready for the native landing workflow; no merge is claimed yet.

Installed real-Chrome proof

All required installed behavior clauses passed on Blacksmith Testbox, lease tbx_01m1abng2m81wkaac18f2kzcn1, run 33338491413. The canonical packer built a self-contained tarball, which was installed into a fresh task HOME with umask 022. CLI: OpenClaw 2026.8.1 (c79e339). Artifact SHA-256: 70c6172999e3e928a0e93ec01859255482786f329f023d0b16000bd8e6099588 (62,047,957 bytes).

Chrome for Testing 152.0.7977.54 loaded the managed unpacked copy through the visible Extensions UI and native directory chooser, after native-host registration. Installed dependencies were independently checked: Playwright 1.62.1, ws 8.21.3. External control used MCPorter 0.13.8 and chrome-devtools-mcp 1.8.0, explicit --autoConnect, require relay policy, and the default discovery budget. No storage injection, fabricated Chrome record, manual daemon launch, relay-URL pin, or discovery-timeout override supplied this proof. The setup driver disconnected before relay-driven actions.

Flow Observed result
Natural installation Normal install discovers the exact managed ID/path in real Preferences, with manualSetupRequired=false and no issues.
Gateway first Native Gateway bootstrap connects; the listener belongs to Gateway. Core tabs/evaluate/snapshot/Doctor pass. Core changes the counter 0→1; external v2 control changes it 1→2. The previously stalled evaluation completes in 1.109 s.
Standalone first, then Gateway With Gateway absent, visible direct pairing and native messaging wake the daemon. External control changes 2→3. Gateway subsequently lists, evaluates 3→4, snapshots, and diagnoses the same bridge without replacing its listener. The same external client performs another action.
Borrowed navigation Gateway navigates the exact existing target through a captured owner reference. The reloaded fixture accepts Core 0→1 and external 1→2, with no Chrome restart. Only the fixture's exact 127.0.0.1 hostname is allowlisted.
Gateway-forwarded ingress Visible Gateway pairing forwards the extension into the daemon's same bridge. Core and external actions/snapshots/Doctor pass; direct pairing is then restored through the visible form.
Independent Gateway cleanup Stopping Gateway leaves the same daemon, Chrome, and external MCP child alive. That unchanged external client performs counter 6→7 afterward.
Native recovery The external consumer is explicitly stopped, then the owned daemon is stopped. Native messaging replaces the listener in 2.608 s; a fresh client's actual action proves readiness and changes the same page 7→8. Chrome is unchanged. Creating and closing a new page also pass.
Cleanup Exact task-owned processes stop, all proof ports close, and the lease is independently observed completed. The operator's Chrome/Gateway and protected Copilot pairing/recovery state are untouched.

Seventeen captures were inspected and verified synthetic-only. The directory chooser needed two observed activations; the first dismissed path completion. The initial 120-second installer waiter ended before UI setup finished and correctly still requested manual setup; after actual visible loading, the normal idempotent install command discovered the plugin. That setup timing is not hidden as a first-attempt success or fixed with a longer timeout.

This proves cold-client recovery after daemon replacement, not retained-client crash reconnection. Protected existing-profile recovery, live non-first-profile configuration, background screenshot capture, and the ten-minute idle expiry were not exercised. Non-first/pinned-port selection has focused regression coverage. No package or Store release was performed.

Regression and local verification

  • Canonical-address and descriptor-swap regressions failed before their repairs; general pairing and concurrent first-writer controls remain covered.
  • Real installed testing first exposed the Chromium backing-store miss and daemon-first EADDRINUSE; current installed proof above demonstrates both repairs.
  • The later execution-context race was captured on the installed predecessor: the default Runtime context arrived before the frame-tree reply, and no user evaluation command was dispatched. A deterministic test using the real extension command handler, relay sockets, and Playwright fails before the repair and passes afterward for both owned and borrowed relays.
  • Socket EPIPE/ECONNRESET, malformed frames, immediate/coalesced legacy hello, cancellation, stale references, and delayed/native-cleanup failures have boundary regressions. A failed final retirement notification cannot retroactively fail completed cleanup; borrowers still require the actual acknowledgement.
  • Latest full Node 24 browser replay: 3,601 passed, 24 skipped (222 files passed, five skipped). Focused ordering/ownership batch: 115 passed. Proportional formatting/type/lint/guard checks and full build passed. The final test-helper naming cleanup also passed focused tests and changed checks. Earlier test-only type-library and max-lines failures were repaired using the existing deferred helper and a fixture extraction, not suppressions or configuration changes.
  • Fresh whole-candidate autoreview completed scoped-clean with no accepted/actionable findings at the configured P0 threshold. This is not a P1/P2 certificate.

Principal commands (Node 24; full exact command/exit/hash receipts retained locally):

node scripts/run-vitest.mjs extensions/browser/src/browser/extension-relay/relay-bootstrap.integration.test.ts
node scripts/check-changed.mjs -- extensions/browser/src/browser/extension-relay/relay-bridge.ts extensions/browser/src/browser/extension-relay/relay-session-owner.ts extensions/browser/src/browser/extension-relay/relay-runtime.test.ts extensions/browser/src/browser/extension-relay/relay-coexistence.test-support.ts extensions/browser/src/browser/extension-relay/relay-bootstrap.integration.test.ts extensions/browser/src/browser/extension-relay/relay-runtime.test-support.ts
CI=true NODE_OPTIONS=--max-old-space-size=8192 OPENCLAW_VITEST_MAX_WORKERS=2 OPENCLAW_NODE_TEST_CONFIGS_JSON='["test/vitest/vitest.extension-browser.config.ts"]' OPENCLAW_NODE_TEST_VITEST_ARGS_JSON='[]' OPENCLAW_VITEST_SHARD_NAME=changed-extensions-config-6 node --import tsx scripts/ci-run-node-test-shard.mts
node --import ./scripts/tsx.mjs scripts/build-all.mts
node scripts/package-openclaw-for-docker.mjs --allow-unreleased-changelog --output-dir /tmp/openclaw-relay-autonomous-128379/artifacts

CI and review follow-through

The behavioral commit's browser shard and OpenGrep run 33337441900 passed. CI run 33337441820 failed only the docs release-navigation assertion. The independently owned navigation expectation fix landed as 7504a3b3c453. A draft/ready refresh still checked out the old merge input, so one CI-only empty commit forces a fresh synchronize event. The source tree remains identical; the old failed/stale checks are not being relabeled green.

The latest substantive ClawSweeper review reviewed the earlier 1a8f89cb head. Its ownership finding, architectural decision, and rank-up request are addressed by the single real-bridge owner model, both startup-order regressions, and the installed daemon-first/Gateway proof above. The v2-only daemon default with existing explicit legacy opt-in is accepted. The stored-data-model classification of native IPC framing is not a SQLite/schema change. A new review has been queued by the ready-for-review event; its arrival is separate from required CI and verified behavior.

Production: +2,559/-844, net +1,715; tests/support: +3,140/-579, net +2,561; docs: +90/-18; tooling/config: +2/-1. Raw churn includes authentication/target-info/fixture extractions and finally indentation, not additional capabilities. Production growth supplies the standalone lifecycle and authenticated cross-process ownership, generation fencing, bounded operation references, and acknowledged cleanup; the final ordering repair itself is net +23 production lines. Release-owned CHANGELOG.md is unchanged; release-note context is in this PR.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 30, 2026, 4:39 AM ET / 08:39 UTC.

ClawSweeper review

What this changes

This PR adds a standalone browser-extension relay daemon that an authenticated native host can wake for a paired direct-loopback Chrome extension.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep open: the new daemon can own a relay port before Gateway starts, but Gateway still unconditionally creates its own in-process relay, causing the documented EADDRINUSE browser-control failure. This maintainer-owned, protected PR needs an explicit lifecycle resolution before merge.

Priority: P1
Reviewed head: 1a8f89cb5633d8860febb49d0f38b59f84f23580
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The isolated live proof is strong, but it exposes a blocking relay-lifecycle defect in a supported startup order.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.
Evidence reviewed 7 items Introduced independent relay owner: The PR spawns a detached process for the configured relay port, creating a relay that is not registered in Gateway's in-memory lifecycle state.
Gateway always binds the same port: Gateway startup starts configured extension relays, whose lifecycle calls the relay-server bind directly unless its own in-process map already contains a handle.
Affected browser-control entrypoint: Browser control starts configured relays during service startup, and local-extension availability also requires an in-process relay handle and bridge.
Findings 1 actionable finding [P1] Reconcile daemon-owned relays before Gateway startup
Security None None.

How this fits together

The browser plugin connects Chrome to authenticated loopback relay servers used by OpenClaw browser control and CDP clients. The native host can now start a relay when Chrome reconnects, while Gateway later attempts to manage relays for the same browser profiles.

flowchart LR
  A[Paired Chrome extension] --> B[Native messaging host]
  B --> C[Standalone relay daemon]
  C --> D[Loopback relay port]
  E[Gateway browser control] --> F[Relay lifecycle]
  F --> D
  D --> G[CDP and browser-control clients]
Loading

Decision needed

Question Recommendation
Which component should own an extension relay when the standalone daemon starts before Gateway browser control? Unify relay ownership: Land only after Gateway and the standalone daemon coordinate a single authenticated relay owner across both startup orders.

Why: Gateway currently requires an in-process relay bridge, while the new daemon owns an independent bridge on the same port; choosing a safe handoff or canonical owner is an architectural decision.

Before merge

  • Reconcile daemon-owned relays before Gateway startup (P1) - This new detached spawn can bind the configured relay port without registering an in-process handle. Gateway later creates its own relay for that port, so the daemon-first sequence reported in the PR makes browser control fail with EADDRINUSE. Establish a coordinated handoff or canonical owner and cover daemon-first Gateway startup with a browser-control regression.
  • Resolve merge risk (P1) - Merging leaves a supported daemon-first sequence in which later Gateway browser control cannot acquire the configured relay port, so normal browser commands fail until the daemon exits.
  • Complete next step (P2) - A concrete blocker exists, but selecting the correct cross-process relay ownership and handoff boundary needs maintainer architectural judgment.

Findings

  • [P1] Reconcile daemon-owned relays before Gateway startup — extensions/browser/src/browser/extension-relay-daemon-spawn.ts:61-68
Agent review details

Security

None.

PR surface

Source +431, Tests +568, Docs +52, Other +1. Total +1052 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 13 464 33 +431
Tests 7 569 1 +568
Docs 1 66 14 +52
Config 0 0 0 0
Generated 0 0 0 0
Other 3 2 1 +1
Total 24 1101 49 +1052

Review metrics

Metric Value Why it matters
Production versus test delta production +464/-33 (net +431); tests +569/-1 (net +568) The substantial new relay lifecycle warrants complete startup-order and ownership proof before merge.

Stored data model

Persistent data-model change detected: serialized state: extensions/browser/src/browser/extension-native-protocol.ts, unknown-data-model-change: extensions/browser/src/browser/extension-native-protocol.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair daemon-first coexistence (recommended)
    Add a coordinated handoff or shared relay owner, with daemon-first then Gateway browser-control proof before merging.
  2. Pause the standalone path
    Keep the PR open but defer the independent daemon until Gateway can safely consume or replace its relay ownership.

Technical review

Best possible solution:

Give daemon-first and Gateway-first startup one coordinated relay ownership model, then prove both orders preserve authenticated browser control without weakening the existing port or authentication boundary.

Do we have a high-confidence way to reproduce the issue?

Yes on this PR head: wake the direct-loopback daemon, then start Gateway and invoke browser control. The PR's isolated live evidence reports that result and the source confirms the competing bind path; this read-only review did not rerun it.

Is this the best way to solve the issue?

No. The standalone daemon is viable, but its independent ownership is incomplete because Gateway cannot adopt or coordinate the daemon's relay bridge.

Full review comments:

  • [P1] Reconcile daemon-owned relays before Gateway startup — extensions/browser/src/browser/extension-relay-daemon-spawn.ts:61-68
    This new detached spawn can bind the configured relay port without registering an in-process handle. Gateway later creates its own relay for that port, so the daemon-first sequence reported in the PR makes browser control fail with EADDRINUSE. Establish a coordinated handoff or canonical owner and cover daemon-first Gateway startup with a browser-control regression.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f2cc4f1a0f4b.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.
  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 availability.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The new daemon-first flow makes a normal Gateway browser-control command fail with a relay-port bind error.
  • merge-risk: 🚨 availability: A detached relay introduced by this PR can occupy the endpoint Gateway later requires to serve browser control.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body links an isolated real-Chrome Testbox run that exercised the changed native-host entrypoint, standalone daemon, authenticated relay control, and relay recovery after the fix; it also records the unresolved daemon-first Gateway failure, so proof is sufficient for the successful path but not a merge pass.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Implement one coordinated relay ownership path and demonstrate daemon-first followed by Gateway browser control.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-23T21:43:42.718Z sha d80247a :: needs changes before merge. :: [P1] Honor the configured legacy-auth policy in the daemon | [P2] Start the relay for the paired extension profile
  • reviewed 2026-08-23T23:11:30.877Z sha 7f97e77 :: needs changes before merge. :: [P2] Select the relay port for the requesting extension profile | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-24T05:11:59.987Z sha 7cf6b78 :: found issues before merge. :: [P2] Target the relay that requested wake-up | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-24T05:27:42.137Z sha 7cf6b78 :: needs changes before merge. :: [P2] Target the relay that requested wake-up
  • reviewed 2026-08-27T05:06:21.864Z sha 6637eb2 :: found issues before merge. :: [P1] Restore formatter-owned iframe reference matching | [P2] Make wake-up honor the accepted loopback address
  • reviewed 2026-08-27T05:24:37.920Z sha 6637eb2 :: found issues before merge. :: [P2] Restrict wake-up to an address the daemon serves
  • reviewed 2026-08-30T02:15:43.610Z sha 1a8f89c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T02:26:44.866Z sha 1a8f89c :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Adversarial security pass (5 parallel reviewers)

Ran five adversarial subagents against distinct trust boundaries — native-host ensure_relay, daemon + auth model, extension wake-up path, before/after risk delta, and spawn/env mechanics — plus a Codex autoreview. No P0/P1 found except one operator-config regression, now fixed in 7f97e77.

Fixed: standalone daemon was not v2-only

The daemon called startExtensionRelayServer({ port, token }) with no allowLegacyAuth, inheriting the ?? true default and silently re-enabling legacy one-directional auth (Bearer/Basic/token-subprotocol) even where an operator set extensionRelay.allowLegacyAuth=false — which the gateway path honors. Because legacy auth sends the secret to whoever holds the port, a local process squatting the relay port could harvest the credential from a legacy client (v2 mutual-proof clients like the extension and mcporter were never exposed — they verify the server proof before sending anything). The daemon now defaults to v2-only, honoring an explicit allowLegacyAuth=true opt-in. Verified live: legacy Bearer <real-secret> → 401; v2 mcporter still drives Chrome through the daemon.

Confirmed safe (attackers could not break these)

  • ensure_relay gating — runs the identical origin + manifest + launcher-ownership validation as bootstrap before the op branch; only the allow-listed extension can invoke it (Chrome native-messaging model), no web page reaches it.
  • No injection — spawn uses an argv array with no shell; port/entryPath/execPath are host-derived, not from the frame; the frame carries only a validated nonce, echoed and never reaching the spawn.
  • Spawn storm — the port bind is the single-instance lock (EADDRINUSE → losers self-exit); the daemon idle-exits after 10 min; concurrent spawns are harmless.
  • v2 port-squatting — mutual HMAC means a squatter without the secret cannot forge the server proof, so it cannot drive the extension or harvest from a v2 client (squatting reduces to local DoS).
  • No secret leakage — not in logs, argv, /json/version, or the per-process internal token.
  • DNS-rebinding — hasLoopbackHostHeader gates HTTP and upgrades.

Noted, pre-existing (not introduced here — for separate follow-up)

  • The secret-file read path (readExtensionRelayToken → plugin-sdk tryReadSecretFileSync, unchanged by this PR and shared with the gateway) enforces symlink/hardlink/inode checks but does not re-verify 0600/owner-uid on read; confidentiality rests on the dir mode set at write time. Worth hardening the shared reader in its own PR.
  • The install-generated native-host launcher execs node without scrubbing NODE_OPTIONS/NODE_V8_COVERAGE; same-user only, and it predates this PR (the launcher already runs the bootstrap op). Worth scrubbing in the launcher generator.
  • Extension-side rate-limit (lastRelayEnsureAtMs) and requestRelayEnsure lack cross-restart persistence / in-flight coalescing; bounded to one live daemon by the port lock, so defense-in-depth only.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 23, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up: secret-file read hardening now included

The "pre-existing" item from the security pass above — the relay secret's confidentiality resting only on the directory mode set at write time, with no owner/mode re-check on read — is now fixed in this PR (7cf6b78), since it's the load-bearing assumption behind the whole loopback-plus-secret trust model.

readExtensionRelayToken now classifies the secret file before trusting it: refuse a foreign-owned or non-regular/symlinked file, self-heal a too-broad mode on our own file back to 0600, otherwise accept. The concurrent-creation reread in ensureExtensionRelayToken routes through the same hardened read so a foreign-owned file can't be adopted there either. This protects both the standalone daemon and the gateway path (both authorize via this reader). Windows (ACL-based) and unknown-uid cases pass through unchanged.

Verified live: a secret manually loosened to 0644 is tightened back to 0600 on the next read (tightened extension relay secret permissions to 0600), legacy Bearer stays rejected (401), and v2 mcporter keeps driving Chrome. Pure-classifier unit tests cover the owner/mode/platform branches; integration tests cover self-heal and symlink refusal. Full extensions/browser suite green (2,644 tests), autoreview clean.

Remaining follow-ups (genuinely out of scope, unchanged from above): scrub NODE_OPTIONS/NODE_V8_COVERAGE in the install-generated native-host launcher, and persist the extension-side ensure-relay rate limit across MV3 worker restarts. Both are same-user / port-lock-bounded.

@steipete steipete self-assigned this Aug 27, 2026
@steipete
steipete force-pushed the steipete/standalone-extension-relay-daemon branch from 7cf6b78 to 6637eb2 Compare August 27, 2026 04:59
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: L labels Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The wrong-target finding and both rank-up moves are addressed in the refreshed candidate: ensure_relay carries the stored direct pairing port, the native host validates it against current extension profiles after exact-origin validation, and real boundary regressions cover non-first automatic and pinned targets. Invalid, stale, and non-extension targets fail closed. The previous assertion/dead-export CI failures are also repaired without weakening guards.

The refreshed build, whole-PR changed gate, and focused suite passed (299 tests, one skipped). A fresh full-PR Codex autoreview found no actionable defects at its P0 threshold. The PR body now records the exact commands and the original failing/passing regressions.

Not ready to merge yet: one complete CLI-first native/daemon proof passed, but a second fresh-state run and a profiled diagnostic timed out at the unchanged 30-second CLI bound. Existing-profile source-blind Chrome UI verification is also blocked by refused/indeterminate native GUI targeting. These gaps are explicit in the updated evidence; no native-first warm-up, longer timeout, remote-secret copy, direct DevTools fallback, or historical live run is being substituted for current proof. Native prepare/merge remains on hold, and exact-head hosted CI still needs to complete.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 27, 2026
Use the existing relay payload cap for the teardown fixture WebSocketServer.

Refs: #128379
Await authoritative cleanup and retirement-notice write settlement without
letting delivery failure retroactively fail completed cleanup. Actual
cleanup failures remain fatal, and missing borrower receipts remain fenced.

Refs: #128379
Keep Gateway browser evaluation from timing out when Chrome sends its
default Runtime context before the frame-tree reply. Wait for earlier
frame replies in the same logical CDP session before Runtime.enable,
retaining disable and lifetime checks while unrelated commands stay concurrent.

Refs: #128379
@steipete
steipete marked this pull request as draft August 30, 2026 22:41
@steipete
steipete marked this pull request as ready for review August 30, 2026 22:42
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete

steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Installed browser proof completed

The daemon-first ownership finding and the requested startup-order demonstration are resolved. Real Chrome now passes Gateway-first and native-daemon-first Core actions, snapshots, diagnostics, navigation, Gateway-forwarded ingress, and unchanged external-client operation after Gateway shutdown. Native messaging also replaces the stopped daemon while preserving the same Chrome/page; a deliberately restarted external client then changes the preserved counter 7→8 and creates/closes a new page.

This was built and installed from c79e339. The current CI-only commit has exactly the same source tree (f389993641a5ff1341c68d105db09ed3aa22a762); it changes no source bytes. Blacksmith Testbox run 33338491413, lease tbx_01m1abng2m81wkaac18f2kzcn1, completed the proof, and all owned processes/ports and the lease were cleaned up. Package SHA-256: 70c6172999e3e928a0e93ec01859255482786f329f023d0b16000bd8e6099588.

The images below are inspected captures of a synthetic fixture in the real isolated browser, not generated mockups. The before image is the predecessor's stalled Gateway evaluation; the remaining images show the repaired Gateway-first flow, daemon-first navigation, external control after Gateway stop, and native recovery. The PR body contains commands, regression evidence, process-identity checks, and the full scope/limitations. Protected operator state was not touched. Cold-client daemon recovery is proved; retained-client reconnection after daemon replacement and the ten-minute idle expiry are not claimed.

Land-ready verification: CI 33340376759 and OpenGrep 33340376753 passed on attempt 1 for exact head 4f47b95ffe4218f874da0df1cc576ea80bec6702. Required openclaw/ci-gate succeeded; zero failed or pending checks. Actual checkout eb88e616b3f1f2ed72b3f5cf9ae2644260617e18 contains the published head and repaired main. Together with the source-tree-identical installed proof above, verification is complete for native prepare/merge. No merge is claimed yet. The latest substantive ClawSweeper ownership/rank-up request is addressed; the queued rating refresh is separate from these completed gates.

Before: Gateway-first evaluation stalled; counter stayed zero

After: Gateway-owned Core and external v2 actions completed

Daemon-first: Gateway navigation and external client use the same page

Gateway stopped: unchanged external client still increments the counter

Native recovery: same Chrome and page after daemon replacement

@steipete
steipete merged commit ebca214 into main Aug 30, 2026
251 checks passed
@steipete
steipete deleted the steipete/standalone-extension-relay-daemon branch August 30, 2026 23:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Aug 31, 2026
Remove duplicate profile admission and terminal handling, reuse RPC result
schemas and deferred completion, and make announcement recipients and
request-local action guards explicit. Preserve authentication, asynchronous
ownership checks, cleanup acknowledgements, and action error precedence.

Make the Gateway upgrade-head fixture deterministic at its existing input
boundary instead of depending on TCP coalescing. Keep its assertions.

Maintainer-requested follow-up to the standalone relay in #128379.
Production LOC -75; test LOC -11. Validated with 203 focused tests, changed
checks, full build, and fresh scoped-clean Codex autoreview at P0.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…e-up (openclaw#128379)

* feat(browser): standalone extension relay daemon with native-host wake-up

Host the extension relay outside the Gateway: a new relay-daemon-entry
serves the existing relay server on the configured port, the native
messaging host learns an origin-validated ensure_relay op that spawns it
detached when nothing serves the port, and the extension asks for it
(rate-limited) when a direct loopback /extension pairing cannot connect.
Chrome becomes the supervisor: the daemon defers to a hosting Gateway on
EADDRINUSE and idle-exits once both the extension and all CDP clients
are gone, so browser control no longer depends on Gateway boot.

* fix(browser): make standalone relay daemon v2-only by default

The daemon previously called startExtensionRelayServer without
allowLegacyAuth, inheriting the permissive ?? true default and silently
re-enabling legacy one-directional auth (Bearer/Basic/token-subprotocol)
even where an operator set extensionRelay.allowLegacyAuth=false. Because
legacy auth sends the secret to whoever holds the port, a process that
squats the relay port could harvest the credential from a legacy client.

Default the standalone daemon to v2-only (mutual HMAC, which the
extension and mcporter both speak), honoring an explicit
allowLegacyAuth=true opt-in read from the raw config. Adversarial review
via subagents surfaced this as the one operator-config regression the PR
introduced.

* fix(browser): enforce owner + 0600 on relay secret reads

The relay secret is the entire auth model and loopback is not a trust
boundary on a multi-user host, but the fs-safe reader only rejected
symlinks/hardlinks — a secret whose mode drifted group/other-readable
(loosened umask, restore, shared home) was still trusted. Re-check owner
and mode on every read at the relay boundary: self-heal a too-broad mode
on our own file back to 0600, refuse a foreign-owned or non-regular
file, and route the concurrent-creation reread through the same hardened
path so a foreign secret is never adopted. Verified live: a 0644 secret
is tightened to 0600 on read while v2 control keeps working.

* fix(browser): wake the paired extension relay

* fix(browser): share standalone relay ownership with Gateway

Let Gateway authenticate and borrow an existing standalone relay without
rebinding its port. Fence operations to the exact owner, profile, and tab
generation, and acknowledge shutdown only after owned cleanup completes.

Discover native extension IDs from Chromium Preferences and Secure
Preferences, including non-first profiles, while retaining explicit repair.

Refs: openclaw#128379

* fix(browser): preserve relay ingress through setup and teardown

Keep raw socket error ownership until close so late write errors remain
handled after wrapper destruction. Retain WebSocket error handling through
authentication and the full ingress lifetime.

Pause legacy ingress during asynchronous preparation to preserve immediate
and coalesced hello frames, then resume after admission or rejection.

Refs: openclaw#128379

* test(browser): bound relay teardown fixture payloads

Use the existing relay payload cap for the teardown fixture WebSocketServer.

Refs: openclaw#128379

* fix(browser): separate retirement delivery from cleanup

Await authoritative cleanup and retirement-notice write settlement without
letting delivery failure retroactively fail completed cleanup. Actual
cleanup failures remain fatal, and missing borrower receipts remain fenced.

Refs: openclaw#128379

* fix(browser): order relay runtime bootstrap after frame replies

Keep Gateway browser evaluation from timing out when Chrome sends its
default Runtime context before the frame-tree reply. Wait for earlier
frame replies in the same logical CDP session before Runtime.enable,
retaining disable and lifetime checks while unrelated commands stay concurrent.

Refs: openclaw#128379

* ci: refresh relay checks against repaired main
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Remove duplicate profile admission and terminal handling, reuse RPC result
schemas and deferred completion, and make announcement recipients and
request-local action guards explicit. Preserve authentication, asynchronous
ownership checks, cleanup acknowledgements, and action error precedence.

Make the Gateway upgrade-head fixture deterministic at its existing input
boundary instead of depending on TCP coalescing. Keep its assertions.

Maintainer-requested follow-up to the standalone relay in openclaw#128379.
Production LOC -75; test LOC -11. Validated with 203 focused tests, changed
checks, full build, and fresh scoped-clean Codex autoreview at P0.
steipete added a commit that referenced this pull request Oct 13, 2026
Consolidate image traversal, request observation ownership, bus waiters,
Slack response classification, Node selection and WebSocket decoding.
Retire the generic Windows executable export after its Node caller moved;
keep trusted taskkill/PowerShell paths and all environment validation.
Remove duplicate planner validation and unsupported private lifecycle guards.
Keep external evidence validation, security authority, resource limits and
ordinary write-capable shutdown settlement.

Also preserve WhatsApp audio preflight when enabling message actions and
avoid recording a POSIX pipe-drain failure during the normal TERM grace.

Best-effort tradeoffs accepted:
- Bus cloning trusts its private typed event union. 0ebeee8 added the
  unsupported-kind throw only for lint; fabricated internal kinds now fail
  naturally, and a new typed variant must update this owner at compile time.
- Overlapping private QA driver transitions are unsupported; callers await
  them. #113855 introduced synthetic interleavings, not a human incident.
- Canonical smoke selection is trusted instead of revalidated; #114055 was
  an ownership cutover. A future selector defect belongs at that owner.
- Wire image inputs are parsed JSON trees. #71311 introduced no human
  cyclic-input incident; unsupported internal cyclic objects are best effort.
- Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming
  empty evidence. 195e721 added stabilization, not a human incident.
- Reinstalling the private AIMock mount is unsupported. bdc9c60 added
  speculative guards; the actual owner installs it once before start.
- Obsolete repeated observer disposal after port reuse can remove the newer
  QA lookup. 6386dc4 was an affinity repair, not a disposal incident;
  normal unique-port ownership and stop ordering prevent that lifecycle.
- Local non-federated Matrix joins fail immediately on setup errors; #64489
  added initial coverage, not a reported transient-join incident. Rerun the
  QA command after an unusual setup fault.
- Artifact publication is trusted after its awaited atomic writer. #92606
  added suite execution, not a missing-write incident; deletion afterward
  is reported by normal readers.
- Native browser JSON needs no branded rawJSON surrogate workaround.
  #140882 added that generality without a human incident; a future branded
  producer must own its serialization contract.
- Insertion-only pending caches clear directly on settlement. #113926 and
  #128379 supplied no human successor-eviction incident; no replacement can
  precede these finalizers. Real close-time successor checks stay.
- Re-registering the identical private borrowed-relay handle is unsupported.
  #128379/#133706 introduced no such incident; the owner creates fresh handles
  and current authority and distinct-successor comparisons remain.
- Inconclusive Linux process snapshots conservatively stay alive until the
  next check. #132230/#131643 used controlled fault injection, not a human
  actual-use incident. Final unconfirmed settlement retains state for retry.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…0889)

Consolidate image traversal, request observation ownership, bus waiters,
Slack response classification, Node selection and WebSocket decoding.
Retire the generic Windows executable export after its Node caller moved;
keep trusted taskkill/PowerShell paths and all environment validation.
Remove duplicate planner validation and unsupported private lifecycle guards.
Keep external evidence validation, security authority, resource limits and
ordinary write-capable shutdown settlement.

Also preserve WhatsApp audio preflight when enabling message actions and
avoid recording a POSIX pipe-drain failure during the normal TERM grace.

Best-effort tradeoffs accepted:
- Bus cloning trusts its private typed event union. f993a27 added the
  unsupported-kind throw only for lint; fabricated internal kinds now fail
  naturally, and a new typed variant must update this owner at compile time.
- Overlapping private QA driver transitions are unsupported; callers await
  them. openclaw#113855 introduced synthetic interleavings, not a human incident.
- Canonical smoke selection is trusted instead of revalidated; openclaw#114055 was
  an ownership cutover. A future selector defect belongs at that owner.
- Wire image inputs are parsed JSON trees. openclaw#71311 introduced no human
  cyclic-input incident; unsupported internal cyclic objects are best effort.
- Fabricated cyclic/BigInt tool outputs now fail clearly instead of becoming
  empty evidence. 5929e9a added stabilization, not a human incident.
- Reinstalling the private AIMock mount is unsupported. e98e098 added
  speculative guards; the actual owner installs it once before start.
- Obsolete repeated observer disposal after port reuse can remove the newer
  QA lookup. ace0e05 was an affinity repair, not a disposal incident;
  normal unique-port ownership and stop ordering prevent that lifecycle.
- Local non-federated Matrix joins fail immediately on setup errors; openclaw#64489
  added initial coverage, not a reported transient-join incident. Rerun the
  QA command after an unusual setup fault.
- Artifact publication is trusted after its awaited atomic writer. openclaw#92606
  added suite execution, not a missing-write incident; deletion afterward
  is reported by normal readers.
- Native browser JSON needs no branded rawJSON surrogate workaround.
  openclaw#140882 added that generality without a human incident; a future branded
  producer must own its serialization contract.
- Insertion-only pending caches clear directly on settlement. openclaw#113926 and
  openclaw#128379 supplied no human successor-eviction incident; no replacement can
  precede these finalizers. Real close-time successor checks stay.
- Re-registering the identical private borrowed-relay handle is unsupported.
  openclaw#128379/openclaw#133706 introduced no such incident; the owner creates fresh handles
  and current authority and distinct-successor comparisons remain.
- Inconclusive Linux process snapshots conservatively stay alive until the
  next check. openclaw#132230/openclaw#131643 used controlled fault injection, not a human
  actual-use incident. Final unconfirmed settlement retains state for retry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: browser maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants