Skip to content

fix(relay): tolerate wall-clock skew in host-proof validation - #10474

Merged
brennanb2025 merged 2 commits into
stablyai:mainfrom
innocarpe:fix/relay-host-proof-clock-skew
Jul 28, 2026
Merged

brennanb2025 merged 2 commits into
stablyai:mainfrom
innocarpe:fix/relay-host-proof-clock-skew

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Mobile Relay host-proof validation used raw local Date.now() with zero skew tolerance against a ≤10s challenge window
  • A few seconds of clock lag made issuedAt look "in the future", so every handshake failed and Relay looped connecting → unavailable with no useful UI reason
  • Allow ±30s wall-clock skew while still enforcing the server challenge window length (≤10s)

Closes #10401

Root cause

From the issue: with local clock ~4.4s behind NTP, server-issued issuedAt always failed issuedAt <= now, so the desktop rejected host-proof itself. Broker retries could not recover until the clock was corrected.

Change

In validateTranscript (relay-host-proof.ts):

issuedAt - SKEW <= now && now <= challenge.expiresAt + SKEW
// SKEW = 30_000 ms
// still require challenge.expiresAt - issuedAt <= 10_000

Test plan

  • Unit: accepts ~4.4s behind / ahead clocks
  • Unit: rejects beyond ±30s
  • Unit: still rejects oversized challenge windows
  • Existing relay-control-client host-proof flow passes
  • Manual (optional): set clock ~5s slow → Relay pairing succeeds without NTP fix

Notes

UI/logging for host-proof failures (also requested in the issue) is left as follow-up so this PR stays a minimal handshake fix.

ELI5

Mobile Relay handshakes failed when the phone clock was a few seconds off the server, looping connect → unavailable. Host-proof validation allows a small clock skew so normal lag no longer blocks pairing.

A few seconds of local clock lag made challenge issuedAt appear in the
future, so host-proof rejected every handshake and Mobile Relay looped
connecting forever. Allow ±30s skew while keeping the 10s challenge window (stablyai#10401).
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6edbda7d-baad-4aa0-a2df-ad255ee78b9e

📥 Commits

Reviewing files that changed from the base of the PR and between c261d63 and 2caac18.

📒 Files selected for processing (2)
  • src/main/runtime/relay/relay-host-proof.test.ts
  • src/main/runtime/relay/relay-host-proof.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/runtime/relay/relay-host-proof.test.ts
  • src/main/runtime/relay/relay-host-proof.ts

📝 Walkthrough

Walkthrough

Relay host proof transcript validation now uses named clock-skew and maximum-window constants. Timestamp checks allow bounded differences between the local clock and challenge issuance or expiration while retaining challenge ordering and lifetime constraints. A Vitest suite adds binary transcript helpers, encrypted challenge fixtures, expected HMAC proof generation, and accepted and rejected clock-skew, oversized-window, and invalid-order cases.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding wall-clock skew tolerance to relay host-proof validation.
Description check ✅ Passed The description is mostly complete, but it omits the template's Screenshots, AI Review Report, and Security Audit sections.
Linked Issues check ✅ Passed The code and tests match #10401 by allowing ±30s skew while still enforcing the 10s challenge window.
Out of Scope Changes check ✅ Passed The changes stay focused on relay host-proof validation and tests, with no clear unrelated or extra scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/main/runtime/relay/relay-host-proof.test.ts (1)

140-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Good coverage of the skew boundaries; consider adding exact-limit (inclusive) cases.

Current tests exercise "well within skew" (4.4s) and "1ms past the skew/window limit" (rejected), but there's no test asserting the exact boundary (localNow exactly issuedAt - SKEW or expiresAt + SKEW, and window exactly MAX_HOST_PROOF_CHALLENGE_WINDOW_MS) is accepted. Since the production checks use <=, an inclusive-boundary test would guard against a future off-by-one regression at the edges.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d231ba4e-9706-4aa8-b51d-ddf284c99cbc

📥 Commits

Reviewing files that changed from the base of the PR and between b4718dd and c261d63.

📒 Files selected for processing (2)
  • src/main/runtime/relay/relay-host-proof.test.ts
  • src/main/runtime/relay/relay-host-proof.ts

@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
@brennanb2025
brennanb2025 merged commit f10b6de into stablyai:main Jul 28, 2026
22 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the focused fix — the bounded skew tolerance preserves the signed challenge window, and the regression coverage gives us good confidence. Merged!

@innocarpe

Copy link
Copy Markdown
Contributor Author

Thanks @brennanb2025 — glad the bounded skew + regression tests were enough to land cleanly. Appreciate the merge!

@innocarpe
innocarpe deleted the fix/relay-host-proof-clock-skew branch July 29, 2026 08:07
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ai#10474)

* fix(relay): tolerate wall-clock skew in host-proof validation

A few seconds of local clock lag made challenge issuedAt appear in the
future, so host-proof rejected every handshake and Mobile Relay looped
connecting forever. Allow ±30s skew while keeping the 10s challenge window (stablyai#10401).

* fix(relay): preserve host-proof challenge bounds

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile Relay host-proof silently rejects every handshake when the local clock is a few seconds off (no skew tolerance)

3 participants