Skip to content

fix(gateway): local devices stall on scope upgrade pending approval despite autoApproveLocal - #124589

Merged
steipete merged 3 commits into
mainfrom
steipete/local-silent-pairing-refactor
Aug 16, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/local-silent-pairing-refactor

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where local clients that pair a device — the openclaw CLI, the native desktop apps, and node hosts — would get permanently stuck on scope upgrade pending approval when a later command or app update needed a wider operator scope, even on the operator's own machine with autoApproveLocal at its default. A paired device is pinned to the scopes of its first connect, scope upgrades were always forced onto the manual-approval path, and no local surface could perform that approval (openclaw devices approve from the same machine is itself a device that can't approve its own upgrade). The docs for gateway.nodes.pairing.autoApproveLocal have promised "silently approves pairing, role upgrades, and scope upgrades from trusted local connections" all along — the code contradicted them.

Also fixes openclaw nodes list silently degrading: when its live-node enrichment read failed, the table quietly dropped connected/commands state with no indication anything was missing.

Why This Change Was Made

History: explicit upgrade approval was added in Feb (0bda0202fd1), silent loopback scope upgrades were deliberately enabled three days later (9165bd7f37f), then #54694 re-blocked them globally with an empty-template PR body and no articulated threat model. The block protects nothing locally: silent initial pairing grants a fresh identity arbitrary requested scopes (that is how the macOS app acquires operator.admin), so any local process wanting more scopes could simply mint a new keypair instead of upgrading. Meanwhile role upgrades (node→operator, a bigger escalation) remained silent — the matrix was incoherent.

Scope upgrades now ride the same silent-local rule as initial pairing, with one new restriction that encodes the boundary that actually matters: the connect must itself prove local-grade credentials (auth mode none, or the shared token/password). Identity-proxy connects (Tailscale, trusted-proxy) and bearer device tokens never proved that, so their pairing rows remain a durable scope cap — the Tailscale Control UI cap from #124545 is regression-tested and unchanged. autoApproveLocal: false still forces manual approval for every access grant. The silent self-grant approves the union of requested plus already-held scopes, since approval merges the existing row back in; without that, a client requesting only its missing scope failed the caller-authority check.

The decision surface shrinks with the fix: the scope-upgrade veto directly contradicted shouldAllowSilentLocalPairing's answer (the helper has returned true for local scope upgrades since February), the cli_container_local locality classifier was a byte-for-byte duplicate of the shared-secret-loopback predicate plus a client-class check, and three classifiers re-derived the same shared-secret-auth predicate.

User Impact

On your own machine, OpenClaw clients that need a wider scope just get it — no more scope upgrade pending approval dead ends for the CLI after its first narrow command, no stranded native apps after an update introduces a new operator scope, and dev rigs complete headlessly. Operators who want every grant reviewed keep exactly that with autoApproveLocal: false, and remote, proxied, and Tailscale clients keep today's manual-approval boundary. openclaw nodes list now says on stderr when it degrades to paired-only data instead of silently thinning the table.

Evidence

Live, on an isolated auth-none loopback gateway (own OPENCLAW_STATE_DIR, non-default port) with a rebuilt dist:

== 1. CLI pairs narrow:
cli|["operator.pairing"]
== 2. wider CLI request (gateway call node.list, needs operator.read; the exact pre-fix deadlock):
  "nodes": []          <- succeeds
== 3. row after:
cli|["operator.pairing","operator.read"]
== 4. audit trail:
device pairing auto-approved ... role=operator
device access upgrade requested reason=scope-upgrade ... scopesFrom=operator.pairing scopesTo=operator.read
device pairing auto-approved ... role=operator

The same sequence pre-fix returned gateway connect failed: scope upgrade pending approval and left the row unwidened (reproduced in this session before the change). The security audit: device access upgrade requested log line is retained.

Tests:

  • New integration regressions in src/gateway/server/ws-connection/connect-device-pairing.test.ts: an auth-none CLI client and a token-auth native-app client, each paired narrow, silently widen on reconnect — deliberately requesting a non-superset so the union self-grant is covered. Both verified failing pre-fix (expected true, received false on connect ok).
  • The fix(gateway): keep auth-none local clients connected after pairing #124545 Tailscale Control UI scope-cap test still passes unchanged (the negative lane).
  • New unit coverage: silent scope upgrades allowed for none/token/password, refused for tailscale/trusted-proxy/device-token/bootstrap-token (which keep not-paired/role-upgrade behavior unchanged), refused when authMethod is absent, and refused for every reason under autoApproveLocal: false.
  • Full src/gateway/server/ws-connection/ suite: 58 files / 593 tests green, plus server.device-scope-upgrade, trusted-proxy auto-approve, roles-allowlist, device-token-rotate authz, node-pairing auto-approve/ssh-verify, src/infra/device-pairing, and src/cli/devices-cli suites.
  • nodes list degradation notice covered in src/cli/program.nodes-basic.e2e.test.ts (stderr notice asserted, --json stdout stays clean).
  • tsgo core + gateway test shards clean (12 pre-existing AbortSignal-naming errors identical on baseline); type-aware oxlint clean on changed files.

Production LOC: net −44 (handshake-auth-helpers.ts −96, veto and duplicate-predicate deletions, against +comments and the union self-grant). Tests +90. Docs: configuration-reference.md gains the identity-proxy carve-out sentence on autoApproveLocal.

tryReadNodeList swallowed every enrichment failure, so the unfiltered nodes list silently rendered a table without connected/commands state. The fallback is now announced on stderr, keeping --json stdout parseable.
`autoApproveLocal` has documented "silently approves pairing, role upgrades,
and scope upgrades from trusted local connections" since the loopback
auto-approval landed, but a later hardening pass forced every scope-upgrade
pairing request non-silent. That block protected nothing locally — silent
initial pairing grants a fresh identity arbitrary requested scopes, so any
local process could mint a new keypair instead of upgrading — while it
stranded every row-authorized client (CLI, native apps, node hosts) on a
manual approval no local surface could perform.

Scope upgrades now ride the same silent-local rule as initial pairing, with
one new restriction that encodes the real boundary: the connect must itself
prove local-grade credentials (auth mode none, or the shared token/password).
Identity-proxy connects (tailscale, trusted-proxy) and bearer device tokens
never did, so their pairing rows remain a durable scope cap, and
`autoApproveLocal: false` still forces manual approval for everything.

The silent self-grant also approves the union of requested plus already-held
scopes: approval merges the existing row back in, so a client requesting only
its missing scope no longer fails the caller-authority check.

The decision surface shrinks with the behavior change: the scope-upgrade veto
contradicted shouldAllowSilentLocalPairing's answer, the CLI-container
locality was a duplicate of the shared-secret-loopback predicate, and three
classifiers re-derived the same shared-secret auth check.

Live-verified on an isolated auth-none loopback gateway: a CLI identity
paired at operator.pairing silently widens to operator.read on the next wider
command, with the scope-upgrade security audit line still emitted.
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 13:09
@steipete
steipete requested a review from a team as a code owner August 16, 2026 13:09
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:41 AM ET / 13:41 UTC.

ClawSweeper review

What this changes

The PR lets locally authenticated paired Gateway devices silently widen scopes under the documented default, retains manual approval for proxy and bearer-token paths, and reports CLI node-list fallback on stderr.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness findings. Keep this protected maintainer PR open for ordinary exact-head CI completion; the updated head addresses both prior findings and preserves the stated local versus proxy/bearer-token boundary.

Priority: P1
Reviewed head: 8f5f01ebe9fc91ff8203796c0538d4d2299ecf2f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong real behavior proof and focused owner-boundary coverage with no actionable defect found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body includes an after-fix isolated Gateway terminal trace showing a narrow-to-wider CLI reconnect and persisted scope widening, alongside the stated pre-fix failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes an after-fix isolated Gateway terminal trace showing a narrow-to-wider CLI reconnect and persisted scope widening, alongside the stated pre-fix failure.
Evidence reviewed 7 items Current-main defect: Current main passes scope-upgrade into the silent-local helper but unconditionally forces that request non-silent, while the configuration reference promises silent scope upgrades for trusted local connections.
Owner-boundary repair: The branch supplies the authentication method to the existing pairing-policy owner, permits silent scope upgrades only for none/token/password, and uses that result when creating the pairing request.
Boundary regression coverage: The changed integration test proves narrow-to-wider local reconnect success, while the retained Tailscale test verifies an existing narrow row remains a scope cap.
Findings None None.
Security None None.

How this fits together

Gateway device pairing evaluates a connection’s locality, authentication method, and requested scopes before admitting it or creating an approval request. The node-list CLI combines stored pairing rows with live Gateway state and now reports when live enrichment is unavailable.

flowchart LR
  Client[Gateway client] --> Connect[WebSocket connection]
  Connect --> Policy[Pairing policy]
  Policy --> Auth[Locality and authentication]
  Auth --> Decision[Silent or manual approval]
  Decision --> Store[Persisted device scopes]
  Store --> Session[Admitted Gateway session]
  Gateway[Live Gateway node state] --> CLI[Node-list CLI]
  CLI --> Operator[Operator output]
Loading

Before merge

  • Resolve merge risk (P1) - Existing clean-loopback devices using none, token, or password authentication will move from manual to silent scope widening under the documented default; exact-head Gateway tests and required CI should confirm the retained opt-out and proxy/bearer-token caps.
  • Complete next step (P2) - No repair lane is appropriate: this protected maintainer PR has no actionable review finding, and exact-head CI is the remaining ordinary merge gate.
Agent review details

Security

None.

PR surface

Source -81, Tests +96, Docs 0. Total +15 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 117 198 -81
Tests 4 97 1 +96
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 215 200 +15

Review metrics

Metric Value Why it matters
Production versus test delta production +87/-117 (net -30); tests +127/-82 (net +45); docs +1/-1 The repair removes the obsolete veto and duplicate locality logic while adding owner-boundary success and denial coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/server/ws-connection/connect-device-pairing.ts, migration/backfill/repair: src/gateway/server/ws-connection/handshake-auth-helpers.test.ts, migration/backfill/repair: src/gateway/server/ws-connection/handshake-auth-helpers.ts, serialized state: src/gateway/server/ws-connection/connect-device-pairing.test.ts, vector/embedding metadata: src/gateway/server/ws-connection/handshake-auth-helpers.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #124589
Summary: This PR is the focused remaining repair for local paired-client scope upgrades after the related auth-none reconnect work.

Members:

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

Merge-risk options

Maintainer options:

  1. Land with boundary coverage (recommended)
    Proceed once exact-head Gateway tests and required CI confirm local widening while preserving the explicit opt-out and proxy/bearer-token denials.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require exact-head Gateway pairing boundary tests and required CI to be green.

Technical review

Best possible solution:

Keep the decision in the shared pairing-policy owner: widen only clean local connections authenticated with none, token, or password, while retaining manual approval for autoApproveLocal: false, proxy identities, and bearer device tokens.

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

Yes—current main contains the unconditional scope-upgrade veto, and the branch adds focused owner-boundary reconnect coverage; this read-only review did not execute the suite.

Is this the best way to solve the issue?

Yes—the change repairs the shared pairing decision rather than adding a CLI-only bypass, and it keeps explicit negative boundaries for proxy and bearer-token authentication.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes an after-fix isolated Gateway terminal trace showing a narrow-to-wider CLI reconnect and persisted scope widening, alongside the stated pre-fix failure.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The PR fixes a local Gateway authorization dead end on the default pairing path.
  • merge-risk: 🚨 compatibility: Existing paired local devices change from manual approval to automatic widening under the documented default.
  • merge-risk: 🚨 security-boundary: The patch changes which authentication methods can silently expand persisted device scopes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes an after-fix isolated Gateway terminal trace showing a narrow-to-wider CLI reconnect and persisted scope widening, alongside the stated pre-fix failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix isolated Gateway terminal trace showing a narrow-to-wider CLI reconnect and persisted scope widening, alongside the stated pre-fix failure.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current pairing-policy patch and the closely related merged reconnect exemption repair. (role: current policy author and recent area contributor; confidence: high; commits: 5301f348c641, 6e7b1e2215b3; files: src/gateway/server/ws-connection/handshake-auth-helpers.ts, src/gateway/server/ws-connection/connect-device-pairing.ts)
  • drobison00: The historical merged Gateway change is the policy restriction this PR narrows. (role: author of the earlier global scope-upgrade restriction; confidence: high; commits: 81ebc7e0344f; files: src/gateway/server/ws-connection/connect-device-pairing.ts)

Rank-up moves

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

  • Wait for exact-head required CI before merging.

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 (1 earlier review cycle)
  • reviewed 2026-08-16T13:14:31.099Z sha 5301f34 :: found issues before merge. :: [P1] Update the retained scope-upgrade regression | [P2] Document the trusted-proxy auto-approval exception

Five control-ui pairing suite cases and the silent-scope-upgrade poc locked
the removed non-silent veto. The suite cases now assert the new invariant
(local shared-auth upgrades widen silently, malformed and legacy-shaped rows
are repaired by the fresh approval, node-then-operator grants complete
without a stranded prompt), and the poc case now exercises the surviving
manual-approval gate by disabling autoApproveLocal after its watcher
connects, keeping the pairing-request broadcast and remediation-hint
assertions alive on a real remaining path. The voice-node bootstrap failure
was leakage from the aborted sibling tests, and passes again once they
complete their flows.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 16, 2026
@steipete
steipete merged commit 086f591 into main Aug 16, 2026
244 checks passed
@steipete
steipete deleted the steipete/local-silent-pairing-refactor branch August 16, 2026 14:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…espite autoApproveLocal (openclaw#124589)

* fix(cli): announce when nodes list degrades to paired-only data

tryReadNodeList swallowed every enrichment failure, so the unfiltered nodes list silently rendered a table without connected/commands state. The fallback is now announced on stderr, keeping --json stdout parseable.

* fix(gateway): silently widen local pairing scopes as documented

`autoApproveLocal` has documented "silently approves pairing, role upgrades,
and scope upgrades from trusted local connections" since the loopback
auto-approval landed, but a later hardening pass forced every scope-upgrade
pairing request non-silent. That block protected nothing locally — silent
initial pairing grants a fresh identity arbitrary requested scopes, so any
local process could mint a new keypair instead of upgrading — while it
stranded every row-authorized client (CLI, native apps, node hosts) on a
manual approval no local surface could perform.

Scope upgrades now ride the same silent-local rule as initial pairing, with
one new restriction that encodes the real boundary: the connect must itself
prove local-grade credentials (auth mode none, or the shared token/password).
Identity-proxy connects (tailscale, trusted-proxy) and bearer device tokens
never did, so their pairing rows remain a durable scope cap, and
`autoApproveLocal: false` still forces manual approval for everything.

The silent self-grant also approves the union of requested plus already-held
scopes: approval merges the existing row back in, so a client requesting only
its missing scope no longer fails the caller-authority check.

The decision surface shrinks with the behavior change: the scope-upgrade veto
contradicted shouldAllowSilentLocalPairing's answer, the CLI-container
locality was a duplicate of the shared-secret-loopback predicate, and three
classifiers re-derived the same shared-secret auth check.

Live-verified on an isolated auth-none loopback gateway: a CLI identity
paired at operator.pairing silently widens to operator.read on the next wider
command, with the scope-upgrade security audit line still emitted.

* test(gateway): rewrite veto-era pairing locks for silent local widening

Five control-ui pairing suite cases and the silent-scope-upgrade poc locked
the removed non-silent veto. The suite cases now assert the new invariant
(local shared-auth upgrades widen silently, malformed and legacy-shaped rows
are repaired by the fresh approval, node-then-operator grants complete
without a stranded prompt), and the poc case now exercises the surviving
manual-approval gate by disabling autoApproveLocal after its watcher
connects, keeping the pairing-request broadcast and remediation-hint
assertions alive on a real remaining path. The voice-node bootstrap failure
was leakage from the aborted sibling tests, and passes again once they
complete their flows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant