Skip to content

feat(gateway): auto-approve node pairing via SSH device-key verification - #104180

Merged
steipete merged 1 commit into
mainfrom
claude/ssh-auto-pairing-security-0693d3
Jul 11, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/ssh-auto-pairing-security-0693d3

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #104145

What Problem This Solves

Node device pairing is manual by default: every new node raises an approval prompt the operator must click. For an operator's own fleet, that friction buys little — if you can SSH to the machine you already own it. The one existing opt-in, gateway.nodes.pairing.autoApproveCidrs, keys trust off network locality (a private CIDR), which is a weak signal a hostile LAN shares. Separately, since #103120 retired the standalone node-pairing store, the macOS app's SSH-probe "silent approval" path went dormant (nothing marks the connect-path capability request silent), while docs/gateway/pairing.md still documented it as live.

Why This Change Was Made

Adds gateway.nodes.pairing.sshVerify (default enabled): for a fresh, scopeless role: node pairing from a private/CGNAT address, the gateway SSHes back to the pairing host (BatchMode, StrictHostKeyChecking=yes), runs openclaw node identity --json, and approves only on an exact device id + public-key match with the pending request. Trust binds to machine ownership (host key + authorized key + on-disk device identity), not network locality — NAT co-tenants, other users on a shared host, and LAN spoofing all fail the key match and fall through to the normal prompt. The probe runs detached off the handshake (the connection still closes with pairing-required; the node's retry loop picks up the approval), is bounded to private ranges, single-flighted per host+device, and cooled down after failures. sshVerify: false keeps every node manual; an object form tunes { user, identity, timeoutMs, cidrs }. The same change marks the first node capability-surface request silent when device pairing was non-interactive (reviving the macOS SSH-probe approval), auto-approves the first capability surface for ssh-verified devices on the same proof, and adds the openclaw node identity CLI the probe reads back.

Non-goals: no reachability-based approval, no blanket LAN mode, no change to autoApproveCidrs semantics. Owner boundary stays in the gateway connect/pairing path; ssh-verified is a new non-prune-eligible PairedDeviceApprovalKind.

Also fixes a latent store bug this surfaced: APPROVAL_KINDS in device-pairing-store.ts is the read-back allowlist for the approved_via SQLite column. It was typed readonly PairedDeviceApprovalKind[], which TypeScript does not exhaustiveness-check, so a new kind silently dropped to undefined on load. Replaced with a Record<PairedDeviceApprovalKind, true> that fails compilation if a kind is ever omitted.

User Impact

Operators who can SSH to their nodes (including via Tailscale SSH) get promptless node pairing by default, with no key management beyond what SSH already provides. Tailscale-reachable-but-not-SSH hosts still prompt, as does anything failing the key match. Hardeners set gateway.nodes.pairing.sshVerify: false to require manual approval for every node. New openclaw node identity [--json] prints the local node's device id and public key (read-only; never mints an identity).

Evidence

  • Focused suite green on a fresh remote box (typecheck core + core tests, then targeted tests): 154 passed across shards, including the end-to-end approves device pairing and the first capability surface on a key match, the key-mismatch fall-through, the sshVerify: false disable path, the trusted-CIDR auto-approve cases, node-connect-reconcile silent plumbing, and the openclaw node identity CLI (read-only / fail-closed).
  • pnpm check:changed green end-to-end: conflict/attribution/re-export/duplicate/dependency-pin/package-patch guards, typecheck core, typecheck core tests, and lint core all pass.
  • E2E uses a LAN self-connect harness with the SSH probe runtime mocked at the module boundary; the mismatch/disable cases assert the device stays unpaired and pending.
  • Root-cause of a stubborn approvedVia: undefined was traced to the SQLite read-back allowlist (approval wrote ssh-verified in memory; getPairedDevice read undefined) and fixed with the exhaustive Record guard above.

Docs updated: docs/gateway/pairing.md (new SSH-verified section + corrected macOS auto-approval note), configuration-reference.md, security/index.md (trust-boundary rows + not-a-vuln rationale), cli/node.md, cli/nodes.md, cli/devices.md, nodes/index.md.

@steipete
steipete requested a review from a team as a code owner July 11, 2026 04:49
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes security Security documentation plugin: file-transfer size: XL maintainer Maintainer-authored PR labels Jul 11, 2026
@steipete
steipete force-pushed the claude/ssh-auto-pairing-security-0693d3 branch from f58fc55 to e496e1c Compare July 11, 2026 04:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f58fc55264

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

| "owner"
| "silent"
| "trusted-cidr"
| "ssh-verified"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include ssh-verified approvals in node inventory UI

Adding this new persisted approvedVia value also needs the Nodes UI contract/classifier updated: device.pair.list returns paired records with approvedVia, but ui/src/lib/nodes/index.ts:59 still excludes "ssh-verified" and ui/src/lib/nodes/inventory.ts:157 only treats silent/trusted-cidr as autoApproved. SSH-verified nodes therefore lose the auto-paired chip and are omitted from the stale auto-approved duplicate cleanup even though this change makes them auto-approved on reconnect.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. 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 Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 1:09 AM ET / 05:09 UTC.

Summary
Adds default-on SSH device-key verification for automatic node pairing approval, a read-only node identity CLI, non-interactive first-surface approval plumbing, configuration/docs, and regression tests.

PR surface: Source +788, Tests +480, Docs +86. Total +1354 across 30 files.

Reproducibility: yes. at source level. Current main preserves manual pairing unless CIDR approval is explicitly configured, while the branch enables SSH verification when the new key is absent; ssh -G also reproduces effective-destination redirection through a matching HostName rule.

Review metrics: 2 noteworthy metrics.

  • Config/default surfaces: 1 option added; omitted value activates it. Every existing gateway without the new key changes its node-enrollment behavior after upgrade.
  • Automatic authorization decisions: 2 surfaces approved from one SSH result. A successful probe approves both the device and its first capability surface, increasing the security impact of verification mistakes.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/gateway/node-connect-reconcile.test.ts, serialized state: src/cli/node-cli/identity.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104145
Summary: This PR is the candidate implementation for the linked feature issue and includes a related repair prompted by the recent pairing-store refactor.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Preserve manual pairing by default or document an explicitly approved default migration.
  • [P1] Pin the effective SSH destination and add coverage for HostName redirection.
  • Post redacted real SSH match and mismatch pairing evidence.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The reported integration proof uses a real gateway harness but mocks the SSH process boundary; before merge, add redacted terminal/log or Crabbox evidence for a real key match and a real mismatch/manual fallback, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] Existing gateways with no new configuration would change from manual node pairing to automatic SSH-backed enrollment after upgrade.
  • [P1] OpenSSH client configuration can redirect the effective destination away from the observed WebSocket peer, so the returned identity is not necessarily proof about that peer.
  • [P1] A successful probe authorizes both device pairing and the first declared node capability surface, increasing the consequence of either trust-policy error.

Maintainer options:

  1. Require opt-in and bind the peer (recommended)
    Preserve manual pairing by default and force the SSH process to verify the observed peer address despite local destination-changing SSH configuration.
  2. Explicitly own default-on behavior
    Accept the changed upgrade behavior only after security/product approval and live fresh-install and upgrade evidence.
  3. Narrow the branch
    Remove the new enrollment path and retain only an independently reviewed repair for the dormant silent capability flow.

Next step before merge

  • [P1] Maintainers must decide the default enrollment policy, and the contributor must repair SSH peer binding and provide real behavior proof before another merge review.

Maintainer decision needed

  • Question: Should an omitted gateway.nodes.pairing.sshVerify setting enable automatic node enrollment and first-surface approval for existing gateways after upgrade?
  • Rationale: This changes the default authorization evidence and operator-consent model for a security boundary; code correctness cannot determine the intended product policy.
  • Likely owner: steipete — Recent merged history places this person closest to the current pairing architecture, adjacent auto-approval policy, and linked product proposal.
  • Options:
    • Require explicit opt-in (recommended): Keep manual pairing as the default and let operators enable SSH verification after reviewing its trust and SSH configuration prerequisites.
    • Approve default-on rollout: Retain default-on behavior only with explicit security-owner approval, upgrade communication, and fresh-install plus upgrade live proof.
    • Split the regression repair: Land only the dormant non-interactive capability-request repair and defer SSH-based enrollment policy.

Security
Needs attention: The implicit default authorization change and unpinned effective SSH destination are blocking security-boundary concerns.

Review findings

  • [P1] Preserve manual pairing when the setting is omitted — src/gateway/node-pairing-ssh-verify.ts:63-69
  • [P1] Bind SSH verification to the connecting peer address — src/gateway/node-pairing-ssh-verify.runtime.ts:30-68
Review details

Best possible solution:

Preserve manual pairing when the setting is absent, bind the SSH client's effective destination to the observed peer address while retaining only intentionally supported key and proxy configuration, add redirect regression coverage, and demonstrate real matched and mismatched gateway-to-node runs before merge.

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

Yes at source level. Current main preserves manual pairing unless CIDR approval is explicitly configured, while the branch enables SSH verification when the new key is absent; ssh -G also reproduces effective-destination redirection through a matching HostName rule.

Is this the best way to solve the issue?

No, not in its current form. Device-key comparison is a promising opt-in mechanism, but the rollout must preserve the shipped manual default and the subprocess must attest the actual peer rather than a client-configured destination.

Full review comments:

  • [P1] Preserve manual pairing when the setting is omitted — src/gateway/node-pairing-ssh-verify.ts:63-69
    Treating undefined as enabled changes every existing gateway from manual node enrollment to an automatic authorization path after upgrade. Keep the shipped manual behavior unless the operator explicitly opts in, or obtain explicit approval for a documented and proven default migration.
    Confidence: 0.98
  • [P1] Bind SSH verification to the connecting peer address — src/gateway/node-pairing-ssh-verify.runtime.ts:30-68
    The command still loads normal OpenSSH config, so a matching numeric Host entry can replace HostName and make this identity check query a different machine than the WebSocket peer. Pin the effective destination or otherwise isolate destination-changing options before using the output to approve pairing.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: This is a substantial but bounded gateway enrollment feature whose security-sensitive rollout needs normal-priority maintainer review before merge.
  • add merge-risk: 🚨 compatibility: Existing installations with no configuration change move from manual enrollment to automatic SSH verification after upgrade.
  • add merge-risk: 🚨 security-boundary: The patch adds new authorization evidence for device and capability approval, and the SSH destination is not fully bound to the connecting peer.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The reported integration proof uses a real gateway harness but mocks the SSH process boundary; before merge, add redacted terminal/log or Crabbox evidence for a real key match and a real mismatch/manual fallback, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P2: This is a substantial but bounded gateway enrollment feature whose security-sensitive rollout needs normal-priority maintainer review before merge.
  • merge-risk: 🚨 compatibility: Existing installations with no configuration change move from manual enrollment to automatic SSH verification after upgrade.
  • merge-risk: 🚨 security-boundary: The patch adds new authorization evidence for device and capability approval, and the SSH destination is not fully bound to the connecting peer.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The reported integration proof uses a real gateway harness but mocks the SSH process boundary; before merge, add redacted terminal/log or Crabbox evidence for a real key match and a real mismatch/manual fallback, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +788, Tests +480, Docs +86. Total +1354 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 16 812 24 +788
Tests 6 604 124 +480
Docs 8 95 9 +86
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 1511 157 +1354

Security concerns:

  • [high] Default-on enrollment authorization — src/gateway/node-pairing-ssh-verify.ts:66
    Gateways without the new key begin probing and auto-approving eligible node requests, changing the operator's authorization policy without explicit consent.
    Confidence: 0.98
  • [high] SSH target can be redirected by client config — src/gateway/node-pairing-ssh-verify.runtime.ts:30
    A matching OpenSSH Host rule can replace the numeric peer with another HostName, so the returned identity may not come from the connecting machine.
    Confidence: 0.97

What I checked:

Likely related people:

  • steipete: Authored and merged the device-backed node pairing refactor, reviewed and merged the adjacent CIDR policy, and dominates recent history in the central pairing files. (role: introduced current pairing architecture and recent area contributor; confidence: high; commits: f5806d08e2eb, f44759073b3c; files: src/gateway/server/ws-connection/message-handler.ts, src/gateway/node-connect-reconcile.ts, src/infra/device-pairing.ts)
  • sahilsatralkar: Authored the merged proposal that established the current explicit first-node auto-approval eligibility and security boundaries reused by this branch. (role: introduced adjacent trusted-CIDR policy; confidence: medium; commits: f44759073b3c; files: src/gateway/node-pairing-auto-approve.ts, src/gateway/server.node-pairing-auto-approve.test.ts, docs/gateway/pairing.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.

@steipete
steipete force-pushed the claude/ssh-auto-pairing-security-0693d3 branch from e496e1c to 4aafc62 Compare July 11, 2026 05:14
@steipete
steipete merged commit 58b0ec9 into main Jul 11, 2026
98 checks passed
@steipete
steipete deleted the claude/ssh-auto-pairing-security-0693d3 branch July 11, 2026 05:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
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. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security Security documentation size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: SSH-verified auto-approval for node device pairing

1 participant