fix(control-ui): share gateway token scope across loopback hosts#73987
fix(control-ui): share gateway token scope across loopback hosts#73987openclaw-clownfish[bot] wants to merge 1 commit into
Conversation
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
Greptile SummaryThis PR normalizes gateway token scope so that
Confidence Score: 3/5Not safe to merge as-is — IPv6 loopback token sharing is silently broken and the test masking the bug should also be corrected. Two related P1 findings: the [::1] bracket mismatch in normalizeGatewayTokenScopeHost (a definite present defect on the changed code path) and the companion test that doesn't catch it. The fix is a single-character change but the test infrastructure also needs adjustment. Multiple P1s pull the score below the 4/5 ceiling. ui/src/ui/storage.ts line 33 (IPv6 check) and ui/src/ui/storage.node.test.ts setTestLocation hostname derivation for IPv6 hosts.
|
|
|
||
| function normalizeGatewayTokenScopeHost(hostname: string): string { | ||
| const normalized = hostname.toLowerCase(); | ||
| if (normalized === "localhost" || normalized === "[::1]" || isIpv4LoopbackLiteral(normalized)) { |
There was a problem hiding this comment.
[::1] IPv6 loopback check never matches
normalizeGatewayTokenScopeHost receives parsed.hostname from the WHATWG URL API. For a URL like ws://[::1]:18789/openclaw, URL.hostname returns "::1" (brackets stripped), but the condition compares against "[::1]" (with brackets). The check normalized === "[::1]" is therefore always false, so IPv6 loopback addresses are never normalized to "localhost" and the stated same-machine token sharing for [::1] is silently broken.
| if (normalized === "localhost" || normalized === "[::1]" || isIpv4LoopbackLiteral(normalized)) { | |
| if (normalized === "localhost" || normalized === "::1" || isIpv4LoopbackLiteral(normalized)) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/storage.ts
Line: 33
Comment:
**`[::1]` IPv6 loopback check never matches**
`normalizeGatewayTokenScopeHost` receives `parsed.hostname` from the WHATWG `URL` API. For a URL like `ws://[::1]:18789/openclaw`, `URL.hostname` returns `"::1"` (brackets stripped), but the condition compares against `"[::1]"` (with brackets). The check `normalized === "[::1]"` is therefore always `false`, so IPv6 loopback addresses are never normalized to `"localhost"` and the stated same-machine token sharing for `[::1]` is silently broken.
```suggestion
if (normalized === "localhost" || normalized === "::1" || isIpv4LoopbackLiteral(normalized)) {
```
How can I resolve this? If you propose a fix, please make it concise.|
Codex review: found issues before merge. Reviewed July 3, 2026, 4:13 PM ET / 20:13 UTC. Summary PR surface: Source +31, Tests +84, Docs +1. Total +116 across 3 files. Reproducibility: yes. by source inspection: current main keys gateway tokens and per-gateway session selection by exact parsed host, while the linked discussion documents localhost versus 127.0.0.1 token fragmentation. I did not run a live browser reproduction. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof path suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a refreshed Control UI storage fix only after maintainers confirm the accepted loopback alias boundary, preserve isolation for distinct loopback gateways, add same-origin or browser-real proof, and remove the changelog edit. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main keys gateway tokens and per-gateway session selection by exact parsed host, while the linked discussion documents localhost versus 127.0.0.1 token fragmentation. I did not run a live browser reproduction. Is this the best way to solve the issue? No as submitted. The Control UI storage layer is a plausible owner path, but the broad 127/8 alias boundary, browser-origin proof gap, changelog edit, and conflicting uneditable branch state need resolution first. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5361e5a0b455. Label changesLabel justifications:
Evidence reviewedPR surface: Source +31, Tests +84, Docs +1. Total +116 across 3 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
Repair the existing #43254 branch rather than replacing it. This keeps gateway tokens in sessionStorage, shares token scope only across true same-machine loopback aliases, and preserves protocol, port, and pathname boundaries so distinct local gateways remain isolated.
This repair addresses the hydrated bot findings by avoiding broad 127.* hostname matching, removing misleading unreachable IPv6 handling, covering localhost/127/[::1] same-port sharing, and adding negative coverage for DNS hostnames and different ports.
Credit: original implementation and reproduction analysis by @ssdiwu in #43254. #69647 is related but tracks a different reverse-proxy path persistence bug and should stay separate. Security-routed linked issues remain out of this fix path.
ProjectClownfish replacement details:
! [remote rejected] HEAD -> fix/control-ui-loopback-token-scope (refusing to allow a GitHub App to create or update workflow
.github/workflows/auto-response.ymlwithoutworkflowspermission)error: failed to push some refs to 'https://github.com/ssdiwu/openclaw.git'