Skip to content

Use Gateway challenge time for node authentication - #1067

Merged
shanselman merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-node-auth-challenge-timestamp
Jul 30, 2026
Merged

shanselman merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-node-auth-challenge-timestamp

Conversation

@bkudiess

@bkudiess bkudiess commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Related to #677

Current head: 17f9e618aad128168f4ef575382bb00b0402cd0f

Root cause

The reporter's new WSL Gateway clock was consistently about 130 seconds behind Windows. Operator pairing signed with the Gateway connect.challenge.ts, but WindowsNodeClient discarded that supplied timestamp and signed device.signedAt with Windows host UTC. The Gateway correctly rejected the stale node signature with DEVICE_AUTH_SIGNATURE_EXPIRED, so operator pairing succeeded while node pairing failed deterministically.

Regression provenance: node host-clock signing originated in e3eeef33 (feat: add Windows node mode capabilities). PR #117 / 1d836390 later added Gateway challenge-timestamp signing only to the operator path, leaving the node/operator asymmetry in place.

Behavior and invariants

  • A shared positive-int64 timestamp selector makes a valid Gateway challenge timestamp authoritative for both operator and node authentication. Host UTC remains only the defensive fallback for an absent or invalid challenge timestamp.
  • Serialized device.signedAt and the signed payload use the same selected timestamp for both protocol v2 and v3.
  • Nonce ordering, token precedence, identity fields, platform, and device family behavior remain unchanged.
  • Structured DEVICE_AUTH_SIGNATURE_EXPIRED is terminal and overrides generic invalid-signature text, so it cannot trigger blind reconnect or v2 fallback. The emitted failure remains classifiable as authentication failure.
  • Malformed, incomplete, and nested error detail objects are parsed safely on a per-field basis, including code, reason, and validated pairing request IDs.
  • Gateway freshness validation is not weakened or bypassed.
  • Current main changes from Keep Windows device metadata stable across reconnects #1064 and Fail closed when persisted device identity cannot load #1065 are preserved. The merge resolution retains stable Windows metadata, fail-closed identity loading, and the current-main invariant that reconnectable server errors do not emit terminal connection failures.

Scope

Setup rollback behavior remains unchanged by product decision. This PR includes no WSL lifecycle changes, destructive cleanup, setup rollback changes, or credential migration behavior.

Validation

Current merged head:

  • ./build.ps1: 5 projects built, 0 failed, 0 warnings
  • Shared: 3,307 passed, 0 failed, 31 skipped
  • Tray: 1,958 passed, 0 failed
  • Connection: 457 passed, 0 failed
  • SetupEngine: 700 passed, 0 failed
  • WinNode CLI: 126 passed, 0 failed
  • Focused auth proof: 31 passed, 0 failed
  • git diff --check upstream/main: clean
  • PR scope relative to current main: exactly 6 intended files
  • Hosted Build and Test run 30502700540: all executed jobs passed

Real behavior proof

Deterministic 130-second skew proof: Credential-free in-memory handshake proof modeled the reporter's approximately 130-second Windows/Gateway skew. The fake Gateway accepted the node connect request because serialized signedAt used the challenge time instead of host UTC. Tests independently recomputed and matched v2 and v3 signatures, covered challenge timestamps without nonce, and verified terminal structured expiry across direct, nested, malformed, incomplete, and mixed generic-message shapes. The current-main reconnectable-error invariant also passed.

Real current-Gateway protocol compatibility: Hosted CI used fresh isolated WSL distros and pinned Gateway 2026.6.11 on the current PR head.

  • Initial setup reached Connected with nodeConnected=true and nodePaired=true; FullSetup_TrayConnects_OperatorAndNode passed.
  • Revocation recovery removed the paired device through the real Gateway, observed the expected validation failure, approved the replacement, then recovered with both operator and node tokens and nodeConnected=true, nodePaired=true.
  • Network recovery stopped/restarted the real Gateway and passed three repeated recovery cycles; the node transitioned out of Connected and returned to nodeConnected=true, nodePaired=true each time.
  • Inspectable artifacts: setup-connect, revocation-recovery, and network-recovery.
  • The two MXC system.run tests skipped because AppContainer/MXC is unavailable on GitHub-hosted runners. They are unrelated to the timestamp selector; initial pairing and both recovery lanes executed against the real Gateway.

Naturally skewed host proof: Not verified. No naturally skewed Windows/WSL host is available. The deterministic test injects the exact 130-second skew without weakening Gateway freshness checks.

No real user credentials, live user Gateway, user settings, or user WSL state were modified. Local real-Gateway E2E was not run because this host already has four leftover OpenClawE2E-* distros and one is the default, so another destructive fixture run would not satisfy the isolation requirement.

Review

Independent review findings covering terminal-code precedence, downstream auth classification, malformed and incomplete detail fallback, per-field pairing detail extraction, and nonce-independent timestamp parsing were fixed. Current-head rubber-duck re-review found no significant issues after merging main.

Structured autoreview command: python .agents\skills\autoreview\scripts\autoreview --mode branch --base upstream/main --stream-engine-output. Codex gpt-5.6-sol at high reasoning was blocked before findings by HTTP 401 Unauthorized.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 8:52 PM ET / July 30, 2026, 00:52 UTC.

ClawSweeper review

What this changes

This PR makes Windows node device-auth signatures use a valid timestamp from the Gateway's connect challenge, matching the operator path, and adds coverage for timestamp selection and terminal authentication errors.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this collaborator-authored PR open for explicit maintainer merge review. The proposed shared timestamp selection fixes the operator/node authentication asymmetry, has focused regression coverage, and the supplied current-head Gateway setup and recovery proof is substantive; no concrete patch defect was identified in the reviewed change context.

Priority: P1
Reviewed head: 17f9e618aad128168f4ef575382bb00b0402cd0f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has strong current-head Gateway proof and a focused repair with meaningful regression coverage; it remains open solely for collaborator/maintainer protocol approval.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR provides current-head real Gateway setup, revocation-recovery, and network-recovery evidence with linked hosted artifacts; the deterministic skew test directly demonstrates the corrected signed-at behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR provides current-head real Gateway setup, revocation-recovery, and network-recovery evidence with linked hosted artifacts; the deterministic skew test directly demonstrates the corrected signed-at behavior.
Evidence reviewed 6 items Shared timestamp authority: The branch adds a single positive-int64 challenge-timestamp reader and signed-at resolver, keeping host UTC only as the fallback for missing or invalid challenge values.
Node handshake now consumes Gateway time: The node connect-challenge handler reads the Gateway payload timestamp and passes it into node-connect signing instead of eagerly using Windows host UTC.
Operator and node paths share selection policy: The operator connect path changes from an inline timestamp fallback to the same shared resolver, preventing the two device-auth paths from drifting again.
Findings None None.
Security None None.

How this fits together

Gateway connection setup receives a challenge containing a nonce and timestamp, then both the operator client and Windows node sign an authentication payload. The Gateway validates that signature before pairing and keeping the node connected, so a host-clock mismatch can otherwise make only node authentication fail.

flowchart LR
  A[Gateway connect challenge] --> B[Challenge timestamp selection]
  B --> C[Operator authentication signature]
  B --> D[Windows node authentication signature]
  C --> E[Gateway signature validation]
  D --> E
  E --> F[Pairing and connection state]
Loading

Decision needed

Question Recommendation
Should the repository accept Gateway challenge time as the authoritative signed-at value for both operator and Windows node authentication across the supported Gateway compatibility range? Confirm and merge: Accept the shared challenge-time policy because the focused tests and current Gateway setup and recovery proofs cover the reported failure while preserving invalid-value fallback behavior.

Why: The patch is narrowly implemented and proof-positive, but choosing the permanent device-auth compatibility contract is a maintainer-owned protocol decision.

Before merge

  • Resolve merge risk (P2) - Merging changes the timestamp source used in device signatures. The supplied proof covers the current Gateway release and invalid-value fallback, but maintainers should confirm that authoritative challenge time remains the intended compatibility contract for supported Gateway versions.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Authentication surface 6 files affected; 653 added, 58 removed The change is concentrated in shared authentication clients and their tests, which makes the protocol compatibility review tractable.
Gateway proof lanes 3 real Gateway E2E lanes passed Initial setup, revocation recovery, and network recovery exercised pairing and reconnect behavior on the current PR head.

Merge-risk options

Maintainer options:

  1. Confirm protocol contract before merge (recommended)
    Approve the change after confirming that a positive Gateway challenge timestamp is the supported source of truth for all supported Gateway versions.
  2. Preserve host-time compatibility instead
    If older supported Gateways require host-clock signing, pause this PR and define an explicit versioned compatibility path rather than merging an unconditional source change.

Technical review

Best possible solution:

Keep one shared Gateway-challenge timestamp policy for operator and node signatures, retain the invalid-or-absent host-time fallback, and land it once a maintainer confirms the supported Gateway compatibility contract.

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

Yes. A controlled Gateway challenge whose timestamp differs from the Windows host clock provides a high-confidence source-level reproduction: current node signing uses host UTC while the Gateway validates challenge-relative freshness; the PR's deterministic 130-second-skew coverage exercises that boundary.

Is this the best way to solve the issue?

Yes. Sharing one validated timestamp selector between operator and node authentication is the narrowest maintainable repair because it removes the split source of truth while preserving host-time fallback for absent or invalid challenge data.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The change addresses an authentication regression that can leave a successfully configured Windows node unable to pair when host and Gateway clocks differ.
  • merge-risk: 🚨 compatibility: Existing device-authentication behavior changes from host time to Gateway challenge time, so supported Gateway-version compatibility must remain explicit.
  • merge-risk: 🚨 auth-provider: The patch directly changes the signed authentication payload and terminal classification for Gateway device authentication.
  • 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 (linked_artifact): The PR provides current-head real Gateway setup, revocation-recovery, and network-recovery evidence with linked hosted artifacts; the deterministic skew test directly demonstrates the corrected signed-at behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides current-head real Gateway setup, revocation-recovery, and network-recovery evidence with linked hosted artifacts; the deterministic skew test directly demonstrates the corrected signed-at behavior.

Evidence

What I checked:

Likely related people:

  • bkudiess: Recent merged work on the same Windows device-identity and reconnect paths is referenced by the PR, and this PR continues that authentication compatibility work. (role: recent authentication and reconnect contributor; confidence: medium; commits: 80f35d074876, c04c5fb06238; files: src/OpenClaw.Shared/WindowsNodeClient.cs, src/OpenClaw.Shared/OpenClawGatewayClient.cs)
  • sytone: The related merged gateway/tunnel work introduced the operator-side challenge timestamp signing that this PR mirrors for the Windows node path. (role: original operator authentication-path contributor; confidence: medium; commits: 1d836390e9ee; files: src/OpenClaw.Shared/OpenClawGatewayClient.cs)

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 (2 earlier review cycles)
  • reviewed 2026-07-29T19:37:46.554Z sha efeeda0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T00:30:56.596Z sha 17f9e61 :: needs maintainer review before merge. :: none

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	src/OpenClaw.Shared/WindowsNodeClient.cs
#	tests/OpenClaw.Shared.Tests/WindowsNodeClientTests.cs
@bkudiess

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 30, 2026
@shanselman
shanselman merged commit b46e91e into openclaw:main Jul 30, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants