Repository navigation
Description
Summary
Local CLI Gateway calls can leave the CLI paired device/token at a read-only scope after a read probe, then reject the next write-scoped CLI agent call with scope upgrade pending approval.
This is a stable-release blocker unless we decide the affected local state is intentionally expected, because the embedded fallback can hide the failure while the primary Gateway agent path is blocked.
Affected Surface
- Local Gateway auth with shared token/password.
- CLI clients using Gateway RPCs before an agent run, especially
gateway healthor other read-scoped probes followed byagentor another write-scoped call. - Observed during
2026.6.10beta release smoke, but the failing path is present on currentmain.
Steps to Reproduce
- Start a local Gateway with token auth enabled.
- Run a CLI read-scoped RPC such as
gateway healthwith the shared token. - Run a CLI write-scoped agent command with the same local Gateway/session.
- Watch the Gateway close the primary agent connection with pairing scope-upgrade state.
Expected
Local CLI shared-token/password calls should not persist or reuse a durable read-scoped paired-device baseline that blocks later local CLI write/admin calls.
The security rule still needs to hold: an already-paired device reconnecting with a device identity must not silently widen scopes. Remote CLI/device-token paths should keep requiring explicit scope-upgrade approval.
Actual
The read probe can persist or reuse the CLI paired device at operator.read. A later agent run needs operator.write, so the server treats it as a paired-device scope upgrade and rejects the primary Gateway path.
Redacted audit shape:
security audit: device access upgrade requested reason=scope-upgrade auth=token roleFrom=operator roleTo=operator scopesFrom=operator.read scopesTo=operator.write client=cli
Observed client close:
1008 pairing required: device is asking for more scopes than currently approved
Root Cause
- CLI calls derive least-privilege scopes per method.
healthmaps tooperator.read;agentmaps tooperator.write. - The client path carried a durable CLI device identity even when the caller already used loopback shared-token/password auth.
- The server clears self-declared scopes for generic device-less shared-token clients, but had only a backend gateway-client exception for local shared-auth scope preservation.
- Result: read-only CLI device state could become the baseline for later write-scoped local CLI calls.
Provenance
- Scope-upgrade protection was introduced by
81ebc7e0344fd19c85778e883bad45e2da972229/ PR fix(gateway): block silent reconnect scope-upgrade escalation #54694 to block silent reconnect escalation. - Backend scope-upgrade enforcement tightened in
d3d8e316bd819d3c7e34253aeb7eccb2510f5f48/ PR gateway: require pairing for backend scope upgrades #55286. - Local bootstrap behavior changed around
69fe999373fd8cd99def18c9796d4fc769b46202/ PR fix(pairing): restore qr bootstrap onboarding handoff #58382. - Gateway client shared-token/device-token persistence was extracted in
b1117d98622f0bf93aba4380e3a4337e56f5add5/ PR refactor: extract gateway client package #87797. - The direct-local backend carve-out was carried forward by
65b460f2345a135f22df7631598643002605aad6/ PR fix(nodes): surface pending reapproval diagnostics #92547.
The broken behavior is the interaction between those pieces, not the scope-upgrade guard itself.
Fix Shape
- Keep paired-device scope-upgrade enforcement unchanged.
- Omit durable device identity for loopback CLI shared-token/password calls.
- Preserve declared scopes server-side only for local, non-browser CLI shared-token/password auth.
- Keep generic device-less shared-token/password clients scope-cleared.
- Add regression coverage for client identity omission, server scope preservation, and the stale read-scoped CLI baseline.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 23, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 23, 2026, 3:59 PM ET / 19:59 UTC.
Summary
Keep open: this is a protected maintainer issue with a source-backed current-main bug and an open draft closing PR. Current main still only omits durable device identity for the backend gateway-client local path, while the linked fix commit is not contained in main or the latest release.
Reproducibility: yes. at source level with high confidence: health resolves to operator.read, agent resolves to operator.write, current CLI shared-token calls still carry device identity, and the server preserves missing-device scopes only for backend gateway-client. I did not run the live Gateway sequence in this read-only review.
Root-cause cluster
Relationship:
canonicalCanonical: #95997
Summary: This issue is the canonical tracker for the local CLI shared-auth read-probe poisoning path; the linked draft PR is the candidate fix, while broader CLI scope-upgrade deadlock reports remain adjacent rather than exact duplicates.
Members:
fixed_by_candidate: fix(gateway): keep local CLI shared auth off device scopes #96002 - The PR uses closing syntax for this issue and changes the exact client/server gateway auth paths named in the report.partial_overlap: Gateway pairing scope deadlock: CLI cannot approve/reject auto-reissued over-scoped repair requests #74484 - That open issue tracks broader CLI/Gateway pairing scope deadlock and recovery behavior, but this issue has a narrower local CLI shared-token read-probe root cause and a dedicated fix PR.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
No new repair job: this protected maintainer issue already has an open closing PR for the exact fix path.
Security
Needs attention: This issue is auth-boundary-sensitive; any fix must keep remote, browser, and device-token scope-upgrade approval intact.
Review details
Best possible solution:
Review and land the linked draft PR, or an equivalent narrow fix, that omits durable device identity only for loopback CLI shared-token/password calls and preserves scope-upgrade enforcement elsewhere.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level with high confidence: health resolves to operator.read, agent resolves to operator.write, current CLI shared-token calls still carry device identity, and the server preserves missing-device scopes only for backend gateway-client. I did not run the live Gateway sequence in this read-only review.
Is this the best way to solve the issue?
Yes, the linked PR's shape is the narrow maintainable fix: move only loopback CLI shared-token/password calls out of durable device identity and add a server-side CLI scope-preservation exception, without weakening remote or device-token scope-upgrade checks.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against fcedd37067ec.
Label changes
Label changes:
P1: The issue blocks the primary local Gateway agent path after common read-scoped CLI probes and was reported as a stable-release blocker.impact:security: The fix must preserve the paired-device scope-upgrade authorization boundary while changing local shared-auth behavior.impact:auth-provider: The bug is in Gateway token/password auth, durable device identity, and operator scope resolution for CLI calls.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:linked-pr-open: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-security-review: Current issue advisory state selects this label.Label justifications:
P1: The issue blocks the primary local Gateway agent path after common read-scoped CLI probes and was reported as a stable-release blocker.impact:security: The fix must preserve the paired-device scope-upgrade authorization boundary while changing local shared-auth behavior.impact:auth-provider: The bug is in Gateway token/password auth, durable device identity, and operator scope resolution for CLI calls.Evidence reviewed
Security concerns:
src/gateway/server/ws-connection/message-handler.ts:1422The current bug is local CLI shared-auth poisoning, but the security rule in message-handler.ts intentionally prevents silent scope widening for already-paired devices and should remain covered by regression tests.
Confidence: 0.88
What I checked:
src/gateway/call.ts:482, fcedd37067ec)src/gateway/server/ws-connection/message-handler.ts:1053, fcedd37067ec)src/gateway/server/ws-connection/handshake-auth-helpers.ts:257, fcedd37067ec)src/gateway/methods/core-descriptors.ts:22, fcedd37067ec)src/gateway/server.silent-scope-upgrade-reconnect.poc.test.ts:251, fcedd37067ec)Likely related people:
src/gateway/call.ts,src/gateway/server/ws-connection/handshake-auth-helpers.ts,src/gateway/server/ws-connection/message-handler.ts)src/gateway/server/ws-connection/message-handler.ts,src/gateway/server/ws-connection/handshake-auth-helpers.ts)src/gateway/client.ts,packages/gateway-client)src/gateway/server/ws-connection/message-handler.ts,src/gateway/server.silent-scope-upgrade-reconnect.poc.test.ts)src/gateway/server/ws-connection/message-handler.ts,src/gateway/server.silent-scope-upgrade-reconnect.poc.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.