Skip to content

feat(gateway): connect approved trusted-proxy CLI and TUI devices within their grant - #199699

Merged
hannesrudolph merged 27 commits into
openclaw:mainfrom
daniel-lxs:gateway-narrow-to-device-grant
Nov 21, 2026
Merged

hannesrudolph merged 27 commits into
openclaw:mainfrom
daniel-lxs:gateway-narrow-to-device-grant

Conversation

@daniel-lxs

@daniel-lxs daniel-lxs commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Related to #199692. Stacked on #199698.

What problem this solves

A CLI or TUI guest approved only for session access can ask for broader operator scopes on its first connection. That files a scope-upgrade request for access the administrator already chose to withhold.

How it works

Set gateway.auth.trustedProxy.narrowToDeviceGrant to let a paired CLI or TUI connect with the intersection of the requested scopes and its approved grant. The Gateway checks the trusted-proxy identity, paired device key, and effective operator role. The connection must have no browser Origin. The hello response reports the admitted scopes, so the client can use its session permissions on the first connection. A request for broader scopes with no overlap still follows the scope-upgrade flow. An administrator can use this option with manual enrollment or configure enrollment separately through trustedProxy.deviceAutoApprove.

The option defaults to false and applies only to devices with a current grant. Device enrollment and browser connections follow their existing policies. The TUI can store a device token under this opt-in. Human operators governed by named-role policy still receive no device token. Reserved Session Share grants use the dedicated publication-transport admission path.

Device tokens can authenticate a direct connection until revoked. openclaw security audit reports gateway.trusted_proxy_narrow_to_device_grant when this option is on. Keep the trusted proxy as the only Gateway ingress and remove a guest device when access ends. The core configuration baseline gains one boolean key, from 2,666 to 2,667. The trusted-proxy guide documents the option and its token behavior.

Evidence

  • Main vs. PR head. On 53fe7a0b11bd, an approved session-only guest's broad TUI request files a scope-upgrade request. On 013f2b4e0e8f with the opt-in enabled, the TUI receives only its paired session scope and a device token, with no pending upgrade. A CLI requesting operator.read receives operator.sessions.read when its grant covers session access. The option-off test on the PR head still files the upgrade. These cases run against the Gateway WebSocket server. The main run uses the option-off case from the PR test suite. Exact base-to-head diff
  • Checks on 013f2b4e0e8f. 275 focused tests passed on macOS arm64. Separate suites covered the opt-in Cloudflare Access JWT verifier, trusted-proxy grant narrowing, Session Share publication request admission, CLI and TUI scope selection, config, and audit behavior. Core typecheck and all 12 baseline ratchets passed.
  • Shipped TUI and stable upgrade. The runtime run at a5b50ef7ff73 upgrades two paired guests and their Gateway from the published 2026.11.6 package. It preserves the settings, credentials, and grants. One guest reuses its stable-issued token. The other receives a token on the first connection and reuses it on restart. Both can run /sessions on the admitted WebSocket after identity resolution. The Access and GitHub responses came from test fixtures. Upgrade evidence

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds an opt-in setting that connects approved trusted-proxy terminal devices within their grants and permits TUI device-token issuance.

Example: A trusted-proxy TUI requests operator.admin but its device has only operator.sessions.write.

  • Before: The connection creates a scope-upgrade request before the client retries.
  • After: With narrowToDeviceGrant enabled, it connects immediately with operator.sessions.write.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and supported by integration coverage; independently inspectable shipped-runtime evidence remains limited, without creating a proof blocker for this maintainer-authored PR.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored proof exemption applies; relevant coverage uses the real Gateway WebSocket harness, while the shipped-TUI upgrade is described in a public report without a matching runtime capture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Approved session-only guests generate requests for broader permissions before their terminal learns its grant.
Reason: The maintainer-authored direction removes approval noise through an explicit opt-in while preserving existing enrollment and default behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR adds useful behavior beyond the merged client fix, and review found no actionable correctness defect.

Priority: P2
Reviewed head: 376e83bef27c3327529fa1c90cd258bfcfb08ec8

Before merge

  • Await maintainer action - An eligible maintainer must review head 376e83b and post a fresh /allow-security-sensitive-change approval.

Findings

None.

Agent review details

How this fits together

The Gateway WebSocket handshake combines authenticated identity, signed device proof, approved scopes, and connection caps to produce admitted RPC permissions and optional device credentials.

flowchart TD
  A[CLI or TUI] --> B[Trusted proxy authentication]
  B --> C[Signed device verification]
  C --> D[Existing pairing grant]
  D --> E[Scope intersection and proxy cap]
  E --> F[Identity and token policy]
  F --> G[Hello response and RPC access]
Loading

Technical review

Best possible solution:

Retain the focused opt-in implementation in the existing pairing and token owners with default behavior and publication isolation preserved.

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

Current-main pairing admission still routes an over-requesting paired terminal through scope-upgrade handling; the option-off regression exercises that path without executing target code during this review.

Is this the best way to solve the issue?

The change addresses the remaining first-connection refusal using existing scope intersection, pairing authority, proxy caps, and credential policy without introducing another state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 423ae0907203.

Provenance checked

  • Trusted-proxy reconnect narrowing changes intended behavior with a stated reason (91cc37b: fix(gateway): stop fabricating scope-upgrade requests on trusted-proxy reconnects #129563 removed fabricated browser upgrade requests while preserving actual widening; this PR explicitly extends grant-bounded admission to terminal clients under a separate option.)
  • Trusted-proxy token suppression changes intended behavior with a stated reason (unknown: Suppression is already present in the handler split at 24ad248; git log -S encountered an unavailable historical blob, leaving its earlier introduction unknown, while the PR explicitly explains durable terminal credentials and preserves current person-bound suppression.)
  • Publication-transport rejection keeps the original intent (39bcc3c: feat: prepare restricted connections for Session Share steering #202654 distinguishes disabled publication purposes from invalid admission; moving rejection into the existing transport module preserves those outcomes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 91cc37b adds src/gateway/server/ws-connection/connect-pairing-approval-plan.ts:107 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 91cc37b788cd; files: src/gateway/server/ws-connection/connect-pairing-approval-plan.ts)

PR surface

Source +90, Tests +77, Docs +62, Generated 0. Total +229 across 18 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 114 24 +90
Tests 4 78 1 +77
Docs 4 70 8 +62
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 18 265 36 +229

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Configuration surface 1 new default-off boolean gateway.auth.trustedProxy.narrowToDeviceGrant selects grant narrowing and TUI token issuance.

Root-cause cluster

Relationship: partial_overlap
Canonical: #199692
Summary: The canonical report separates client scope adaptation from the optional Gateway admission behavior implemented here.

Members:

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: Removes unnecessary approval requests in an advanced remote guest workflow with limited blast radius.
  • merge-risk: 🚨 security-boundary: The opt-in delivers durable TUI credentials usable without proxy identity, an explicitly documented and audited maintainer-accepted tradeoff.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-11-20T23:08:02.867Z sha b1652c2 :: blocked before merge. :: none
  • reviewed 2026-11-20T23:44:43.497Z sha 449e813 :: blocked before merge. :: none
  • reviewed 2026-11-21T00:15:00.373Z sha b42b01e :: blocked before merge. :: none
  • reviewed 2026-11-21T01:35:21.291Z sha 985408c :: blocked before merge. :: none
  • reviewed 2026-11-21T02:12:51.106Z sha b5b6b6c :: blocked before merge. :: none
  • reviewed 2026-11-21T03:13:16.673Z sha c6b89c4 :: blocked before merge. :: none
  • reviewed 2026-11-21T03:52:51.015Z sha 013f2b4 :: blocked before merge. :: none
  • reviewed 2026-11-21T09:32:45.156Z sha e5eaaf4 :: blocked before merge. :: none

Reviewed November 21, 2026, 10:06 AM ET / 15:06 UTC (Revision 17).

@daniel-lxs
daniel-lxs force-pushed the gateway-narrow-to-device-grant branch from 0f26434 to 4cce580 Compare November 15, 2026 21:07
@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 15, 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 maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. 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. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 15, 2026
@daniel-lxs
daniel-lxs force-pushed the gateway-narrow-to-device-grant branch from 4cce580 to 30c1228 Compare November 16, 2026 02:39
@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@hannesrudolph

Copy link
Copy Markdown
Member

/allow-security-sensitive-change

Resolve conflicts from openclaw#199698 and openclaw#202616 landing on main: keep this
branch's trustedProxy.narrowToDeviceGrant docs and, in the session-only
Access guest test, keep main's hardened close/waitFor structure with this
branch's sessions.list admission check.
@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Nov 21, 2026
Resolve the generated config-baseline conflict by regenerating
docs/.generated/config-baseline.* with scripts/generate-config-doc-baseline.ts
--write, so the hashes cover both this branch's narrowToDeviceGrant key and
main's newer plugin keys.
@daniel-lxs

Copy link
Copy Markdown
Member Author

Thanks! I merged main to pick up #199698 and #202616; the conflicts were docs wording and one test, no behavior change, and the focused suites (grant narrowing, device-token revocation, audit) pass on the merged head. That moved the head to 376e83bef27, so the approval above is bound to the old revision: could you post a fresh /allow-security-sensitive-change once CI on the new head finishes?

@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Nov 21, 2026
Resolve the generated config-baseline conflict by regenerating
docs/.generated/config-baseline.* with scripts/generate-config-doc-baseline.ts
--write. The zod-schema.gateway.ts auto-merge combines main's templates
comment change with this branch's narrowToDeviceGrant option.
@daniel-lxs

Copy link
Copy Markdown
Member Author

Thanks! I merged main to pick up #199698 and #202616; the conflicts were docs wording and one test, no behavior change, and the focused suites (grant narrowing, device-token revocation, audit) pass on the merged head. That moved the head to 60fa54fc3a4, so the approval above is bound to the old revision: could you post a fresh /allow-security-sensitive-change once CI on the new head finishes?

@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@hannesrudolph

Copy link
Copy Markdown
Member

/allow-security-sensitive-change

@hannesrudolph
hannesrudolph merged commit 2821214 into openclaw:main Nov 21, 2026
114 checks passed
@daniel-lxs

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper could not start a re-review for this item.
Reason: re-review requires an open issue or PR.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants