fix(gateway): auto-approve scope upgrades for loopback clients#23708
Closed
widingmarcus-cyber wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(gateway): auto-approve scope upgrades for loopback clients#23708widingmarcus-cyber wants to merge 1 commit intoopenclaw:mainfrom
widingmarcus-cyber wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When a device previously paired with a narrower scope (e.g. operator.read) reconnects from localhost requesting broader scopes (e.g. operator.admin), the gateway now auto-approves the upgrade via silent pairing — matching the existing auto-approve behavior for initial pairing of local clients. This fixes subagent sessions failing with 'pairing required' when spawned on a loopback gateway. The subagent's callGateway uses sessions.patch which requires operator.admin scope, but the gateway-client was initially paired with only operator.read. On localhost this scope upgrade is safe and should not require manual approval. Role upgrades (e.g. operator → node) still require explicit approval regardless of client location, preserving the security boundary between different trust levels. All 36 auth tests pass. Fixes openclaw#23661
Contributor
|
Thanks for the fix and discussion here. This has now landed on |
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes subagent sessions failing with
pairing requirederror when spawned on a loopback gateway.Problem
When a device previously paired with a narrower scope (e.g.
operator.read) reconnects from localhost requesting broader scopes (e.g.operator.admin), the gateway triggers the full pairing flow — requiring manual approval even though the client is local and trusted.This breaks subagent sessions because
sessions.patchrequiresoperator.adminscope, but the initialgateway-clientconnection was paired with onlyoperator.read. The scope upgrade triggersrequirePairing("scope-upgrade")which rejects the connection with1008: pairing required.Root Cause
The silent auto-approve check in
message-handler.tsonly applied tonot-pairedreason:Scope upgrades from local clients were treated identically to remote clients — requiring explicit manual approval.
Fix
Extend the silent auto-approve to include
scope-upgradefor local clients:Role upgrades (e.g.
operator→node) still require explicit approval regardless of client location, preserving the security boundary between different trust levels.Testing
requires pairing for scope upgradestest →auto-approves scope upgrades for local clientsFixes #23661
Greptile Summary
Extends silent auto-approval for loopback clients from just initial pairing (
not-paired) to also include scope upgrades (scope-upgrade). This fixes subagent sessions that previously failed with "pairing required" errors when escalating fromoperator.readtooperator.admin.The change modifies the condition in
message-handler.ts:641from:to:
Key security properties preserved:
isLocalDirectRequest()(checks IP is loopback AND host is localhost/127.0.0.1/::1/ts.net AND no untrusted proxy headers)operator→node) still require manual approval regardless of client locationroleScopesAllow()before pairingTests updated to verify auto-approval works for both normal scope upgrades and legacy metadata (devices paired before scopes field existed).
Confidence Score: 5/5
isLocalClientcheck requires both loopback IP AND local hostname AND absence of untrusted proxy headers. Role upgrades still require manual approval, preserving the security boundary between operator and node roles. The fix directly addresses the documented issue without introducing new attack surface.Last reviewed commit: 41a0aff