Skip to content

fix(gateway): preserve local access for specific binds - #98479

Merged
steipete merged 4 commits into
openclaw:mainfrom
haruaiclone-droid:codex/fix-dashboard-tailnet-loopback
Jul 11, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
haruaiclone-droid:codex/fix-dashboard-tailnet-loopback

Conversation

@haruaiclone-droid

@haruaiclone-droid haruaiclone-droid commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

gateway.bind: "custom" could expose the Gateway only on the configured interface while local clients still connected to 127.0.0.1. The dashboard then either failed or selected a non-loopback URL carrying the control token. gateway --force could also miss an interface-specific listener, and invoking dashboard from a dirty watched checkout could rebuild the shared dist tree under the running Gateway.

Closes #98476.

Why This Change Was Made

  • Claim 127.0.0.1 as a required same-process alias before a specific IPv4 listener; fail startup on alias or primary-listener collisions.
  • Preserve the existing loopback fallback for tailnet binds, but reject tailnet-to-wildcard fallback.
  • Deliver dashboard credentials only after the configured endpoint is reachable and listener inspection proves the selected IPv4 address plus loopback belong to the same PID.
  • Inspect concrete listeners before generic bind probes in gateway --force, so interface-specific stale processes are found.
  • Treat dashboard as a stamped Gateway client in run-node, including a post-lock recheck, so it does not destructively rebuild a dirty watched checkout.
  • Document that a supervised installed Gateway must be stopped before a watcher owns the same port.

The change removes one fallback surface (tailnet to wildcard) and adds no config or default surface. Existing gateway.bind values and the loopback fallback remain supported.

User Impact

Custom IPv4 binds keep local dashboard and approval clients on loopback while preserving the configured network listener. Credential-bearing dashboard URLs fail closed when listener ownership cannot be proven. Watch mode remains stable when dashboard commands run, and --force now finds interface-specific listeners.

Evidence

  • Blacksmith Testbox: 786 focused tests passed across Gateway, dashboard, force-port, watcher, and launcher shards on the current PR head.
  • Blacksmith Testbox: exact changed-surface gate and build run on the PR head.
  • Live macOS watch: TERM=dumb pnpm gateway:watch remained alive with exactly 127.0.0.1:18789 and the configured private IPv4 listener owned by one PID.
  • Two consecutive pnpm openclaw dashboard --no-open --yes runs exited 0, emitted no build output, returned only the loopback URL, kept the token out of terminal output, and preserved the same listener topology for 34 seconds.
  • Fresh Codex autoreview: no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 10, 2026, 10:14 PM ET / July 11, 2026, 02:14 UTC.

Summary
The PR updates Gateway listener startup, dashboard target selection, port cleanup and diagnostics, watch-mode launching, tests, and documentation so specific IPv4 binds retain same-host loopback access.

PR surface: Source +153, Tests +515, Docs +10, Other +4. Total +682 across 35 files.

Reproducibility: yes. from source inspection. Start a tailnet-configured Gateway while no Tailnet IPv4 is bindable so it falls back to loopback, make Tailscale available without restarting Gateway, then run openclaw dashboard; the command probes the newly resolved Tailnet address rather than the running loopback listener.

Review metrics: 2 noteworthy metrics.

  • Existing bind modes: 2 behavior changes. Tailnet and specific custom binds gain a mandatory loopback listener, affecting existing startup and upgrade behavior.
  • Fallback behavior: 1 fallback removed. Tailnet-to-wildcard fallback is now rejected, so unavailable-interface behavior must be reviewed as an intentional compatibility change.

Stored data model
Persistent data-model change detected: migration/backfill/repair: docs/gateway/security/index.md, vector/embedding metadata: docs/gateway/security/index.md, vector/embedding metadata: src/infra/ports-format.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98476
Summary: This PR is the linked candidate fix for the issue's insecure plaintext Tailnet dashboard and missing loopback listener behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🐚 platinum hermit
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Fix and test dashboard behavior when Tailscale appears after a tailnet Gateway started on loopback-only fallback.
  • Obtain Gateway and security-owner acceptance for the mandatory-loopback upgrade behavior.

Risk before merge

  • [P1] Existing tailnet installations that started while Tailscale was unavailable can lose access through openclaw dashboard once a Tailnet address appears, until the Gateway is restarted.
  • [P1] Specific tailnet and custom binds now require the same port to be free on 127.0.0.1, so an upgrade can intentionally turn a previously usable network listener into a startup failure; that compatibility impact needs explicit owner acceptance and upgrade guidance.

Maintainer options:

  1. Repair fallback topology before merge (recommended)
    Select the readiness endpoint from inspected active listeners, add the post-start Tailnet appearance regression test, and document the intentional occupied-loopback upgrade failure.
  2. Pause for Gateway and security review
    Hold the PR if owners do not accept making a free loopback listener mandatory for existing specific-bind installations.

Next step before merge

  • The contributor should address the concrete dashboard fallback finding, after which the assigned Gateway and security owners should review the intentional startup compatibility change.

Security
Cleared: The patch does not weaken the credential boundary: authenticated loopback URLs remain withheld unless listener inspection proves the configured interface and loopback belong to the same process.

Review findings

  • [P2] Keep dashboard usable after tailnet falls back to loopback — src/commands/dashboard.ts:90
Review details

Best possible solution:

Determine readiness from the running Gateway's inspected listener topology: use loopback for a loopback-only fallback, probe the configured interface when that listener is present, and retain same-PID ownership verification before delivering an authenticated loopback URL.

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

Yes, from source inspection. Start a tailnet-configured Gateway while no Tailnet IPv4 is bindable so it falls back to loopback, make Tailscale available without restarting Gateway, then run openclaw dashboard; the command probes the newly resolved Tailnet address rather than the running loopback listener.

Is this the best way to solve the issue?

No, not in the current head. Adding a loopback alias and proving same-process ownership are appropriate, but endpoint readiness must reflect the listener topology established at Gateway startup rather than current interface discovery alone.

Full review comments:

  • [P2] Keep dashboard usable after tailnet falls back to loopback — src/commands/dashboard.ts:90
    When a tailnet Gateway starts without a bindable Tailnet address, it runs on loopback only. If Tailscale appears later, this line probes the newly resolvable Tailnet address before returning the loopback dashboard URL, so readiness reports the healthy Gateway as stopped. Choose the probe from the active listener topology and add this fallback regression case.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 availability: The current dashboard readiness logic can report a healthy loopback-only fallback Gateway as unavailable after Tailscale appears.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body reports an after-fix live macOS watch with the specific IPv4 and loopback listeners owned by one PID, plus repeated dashboard runs that returned only loopback without rebuild or token output.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The updated PR body reports an after-fix live macOS watch with the specific IPv4 and loopback listeners owned by one PID, plus repeated dashboard runs that returned only loopback without rebuild or token output.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: The PR addresses an important Gateway/dashboard bug but the remaining regression affects a specific tailnet fallback sequence rather than the core runtime generally.
  • merge-risk: 🚨 compatibility: Existing tailnet and custom configurations can newly fail startup when their port is already occupied on loopback.
  • merge-risk: 🚨 availability: The current dashboard readiness logic can report a healthy loopback-only fallback Gateway as unavailable after Tailscale appears.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The updated PR body reports an after-fix live macOS watch with the specific IPv4 and loopback listeners owned by one PID, plus repeated dashboard runs that returned only loopback without rebuild or token output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body reports an after-fix live macOS watch with the specific IPv4 and loopback listeners owned by one PID, plus repeated dashboard runs that returned only loopback without rebuild or token output.
Evidence reviewed

PR surface:

Source +153, Tests +515, Docs +10, Other +4. Total +682 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 15 234 81 +153
Tests 10 546 31 +515
Docs 9 25 15 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 0 +4
Total 35 809 127 +682

What I checked:

  • Blocking fallback regression: For plaintext tailnet mode, the branch derives a currently resolvable Tailnet host and uses it as the readiness probe before returning the loopback dashboard URL; if the running Gateway previously started on loopback-only fallback, that probe fails even though the intended dashboard endpoint is healthy. (src/commands/dashboard.ts:90, 8067cc5fb71a)
  • Fallback remains an explicit contract: The bind resolver returns 127.0.0.1 when no Tailnet address is bindable, and the PR documentation tells users this loopback-only fallback remains supported until Gateway restart. (src/gateway/net.ts:266, 8067cc5fb71a)
  • Missing regression case: Dashboard tests cover a live specific Tailnet listener and its loopback alias, but not a Gateway that started loopback-only before a Tailnet address appeared. (src/commands/dashboard.test.ts:163, 8067cc5fb71a)
  • Prior review finding resolved: The branch now recognizes a same-process specific IPv4 plus loopback topology in shared port diagnostics and includes focused tests, addressing the previous listener-diagnostics finding. (src/infra/ports-format.ts:174, 8067cc5fb71a)
  • Finding is new to this review cycle: The affected dashboard readiness and listener-ownership implementation was added after the previously reviewed head, so this is not a late finding on unchanged code. (src/commands/dashboard.ts:90, 8067cc5fb71a)
  • Validation state: The exact PR head has green CI, build, type, security, CodeQL, and real-behavior-proof checks; these checks do not exercise the post-start Tailnet appearance scenario identified from source. (8067cc5fb71a)

Likely related people:

  • steipete: Commit b5fd66c introduced explicit tailnet binding, later commits maintained Gateway network helpers, and the live PR is currently assigned to this handle after their substantive branch update. (role: introduced bind behavior, recent gateway contributor, and current assignee; confidence: high; commits: b5fd66c92dc5, f4c6c0aec49e, 3ad7049cba9d; files: src/gateway/net.ts, src/gateway/server-runtime-state.ts, src/config/types.gateway.ts)
  • BinHPdev: Commit b9d1485 changed the dashboard command to use localhost URLs, directly overlapping the command behavior under review. (role: dashboard localhost behavior contributor; confidence: medium; commits: b9d14855d02f; files: src/commands/dashboard.ts, src/commands/dashboard.test.ts)
  • SARAMALI15792: Commit 978bc53 updated resolveGatewayListenHosts and its tests, the helper now expanded by this PR. (role: Gateway listen-host helper contributor; confidence: medium; commits: 978bc53e80cc; files: src/gateway/net.ts, src/gateway/net.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-01T07:48:32.909Z sha d14cbc8 :: needs real behavior proof before merge. :: [P2] Accept the new listener alias in diagnostics

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 1, 2026
@steipete steipete self-assigned this Jul 11, 2026
@steipete steipete changed the title fix: prefer loopback for local tailnet dashboard fix(gateway): preserve local access for specific binds Jul 11, 2026
@steipete
steipete marked this pull request as ready for review July 11, 2026 02:02
@steipete
steipete requested a review from a team as a code owner July 11, 2026 02:02
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes security Security documentation scripts Repository scripts size: L and removed size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8067cc5fb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/dashboard.ts
token,
includeTokenInUrl,
dashboardUrl,
probeUrl: loopbackAliasHost ? configuredLinks.wsUrl : links.wsUrl,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep dashboard usable after tailnet falls back to loopback

When gateway.bind=tailnet starts while no Tailnet address is bindable, startup intentionally falls back to 127.0.0.1 only (resolveGatewayBindHost returns loopback in that case). If Tailscale comes up later, resolveControlUiLinks will now produce the current Tailnet IP, so this line probes ws://<tailnet-ip>:<port> before delivering the loopback dashboard URL; readiness then treats that refused Tailnet probe as a stopped/unhealthy gateway even though the running gateway is available on loopback. Use the loopback probe until listener/status evidence proves the Tailnet listener exists, or the dashboard regresses for this documented fallback path.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head 8067cc5fb71a20d3ea95c19bb6a12cfe7e9639e2:

  • scripts/pr prepare-run 98479 verified hosted exact-head CI/Testbox gates at 2026-07-11 02:17 UTC.
  • Blacksmith Testbox focused proof passed 786 tests across Gateway, dashboard, force-port, watcher, and launcher shards.
  • Blacksmith Testbox check:changed passed the core, core-test, docs, and tooling lanes in 8m51s; pnpm build passed in 1m50s.
  • Real macOS watch proof used TERM=dumb pnpm gateway:watch with the installed supervised Gateway stopped. One Gateway PID owned exactly 127.0.0.1:18789 plus the configured private IPv4 listener.
  • Two consecutive pnpm openclaw dashboard --no-open --yes runs exited 0, emitted no build output, returned only the loopback URL, and kept the token out of terminal output. The same listener topology persisted for 34 seconds across 31 samples.
  • The earlier listener-diagnostics finding is fixed in src/infra/ports-format.ts with same-PID specific-address-plus-loopback coverage.
  • Fresh local and branch Codex autoreviews reported no accepted/actionable findings.

Known proof gap: the existing Chrome bridge was unavailable, so this has real CLI, clipboard, listener, and process-lifetime proof but no browser screenshot. No token or private address is included here.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit c2301d8 into openclaw:main Jul 11, 2026
225 of 244 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security Security documentation size: L 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.

[Bug]: local tailnet dashboard opens insecure non-loopback URL

2 participants