Repository navigation
fix(openclaw-id): clients follow a re-bind, and a stolen Gateway key can't retire bindings - #196402
Conversation
… not blocked A retired Gateway key could have signed an inflated seq or a future issued_at; clients now restart snapshot order with the first snapshot of a newer binding's K_gw and keep the binding_seq high-water. Node hosts persist the K_gw of their freshness marker.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
…r R-signed binding A retired key's snapshot could claim the next binding_seq and keep the marker on that key, leaving the new key's snapshots unordered. The marker now records the R-signed binding its key verified under and moves to another key only for a higher one.
|
Codex review: needs maintainer review before merge. What this changesThis PR orders snapshots by Gateway signing key, rejects inflated binding claims, and migrates saved node freshness markers. Example: A retired Gateway key signed snapshot sequence 500 before a root-authorized replacement at binding 2 signs sequence 3.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main freshness defect. No actionable patch defects remain, and the updated native replay and SQLite upgrade evidence closes the prior proof requests. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDiscovery supplies untrusted signed binding and membership evidence; the shared protocol verifies freshness, the node SQLite owner retains trust, and the transport connects only after verification and persistence. flowchart LR
Discovery --> BindingVerification
SavedTrust --> BindingVerification
BindingVerification --> FreshnessAssessment
FreshnessAssessment --> SQLiteTrustOwner
SQLiteTrustOwner --> NativeTunnel
Technical reviewBest possible solution: Land the shared freshness repair and node persistence changes, with companion clients adopting the same per-key contract. Do we have a high-confidence way to reproduce the issue? Current main compares replacement-key snapshots against the retired key's global order and retains unverified binding claims; the committed regressions identify both failures, without running target code during this review. Is this the best way to solve the issue? The patch repairs the existing shared freshness owner, retains binding rollback protection, and updates the existing parser and SQLite merge boundary without adding a competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 83d832338dd8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +65, Tests +200, Docs +11, Other +2. Total +278 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed November 10, 2026, 12:13 PM ET / 17:13 UTC (Revision 4). |
… high-water (J5) A snapshot naming a binding_seq above the binding it verified under is refused as snapshot_ahead and nothing of it is stored, so a stolen K_gw can no longer retire every binding a client could verify. The per-key order now switches on the verified binding_seq alone; stored markers from before are capped at the pin's binding_seq on load (clampFreshnessState), as node hosts do.
A marker with k_gw always carries a verified binding_seq, even when the pin did not advance, so it is kept as stored. A marker without k_gw (before per-key order) is capped at the pin and loses its (seq, issued_at): attributed to the next K_gw, a retired key's inflated seq would block the replacement for good.
… markers do Unkeyed fixtures are legacy markers, which load capped and without order.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…can't retire bindings (openclaw#196402) * fix(openclaw-id): order membership snapshots per K_gw so a re-bind is not blocked A retired Gateway key could have signed an inflated seq or a future issued_at; clients now restart snapshot order with the first snapshot of a newer binding's K_gw and keep the binding_seq high-water. Node hosts persist the K_gw of their freshness marker. * test(openclaw-id): allocate test lines for per-K_gw snapshot order * fix(openclaw-id): switch snapshot order to a new K_gw only for a newer R-signed binding A retired key's snapshot could claim the next binding_seq and keep the marker on that key, leaving the new key's snapshots unordered. The marker now records the R-signed binding its key verified under and moves to another key only for a higher one. * fix(openclaw-id): only verified bindings raise a client's binding_seq high-water (J5) A snapshot naming a binding_seq above the binding it verified under is refused as snapshot_ahead and nothing of it is stored, so a stolen K_gw can no longer retire every binding a client could verify. The per-key order now switches on the verified binding_seq alone; stored markers from before are capped at the pin's binding_seq on load (clampFreshnessState), as node hosts do. * fix(openclaw-id): migrate only legacy freshness markers on load A marker with k_gw always carries a verified binding_seq, even when the pin did not advance, so it is kept as stored. A marker without k_gw (before per-key order) is capped at the pin and loses its (seq, issued_at): attributed to the next K_gw, a retired key's inflated seq would block the replacement for good. * test(openclaw-id): node-host freshness fixtures carry k_gw, as stored markers do Unkeyed fixtures are legacy markers, which load capped and without order. * test(openclaw-id): size the per-K_gw freshness test-line allocation to the change
Related: #196138 (re-bind design, statements.md "Freshness"), #196388 (re-bind ceremony)
What Problem This Solves
Fixes: after an OpenClaw ID claw moves to new keys, clients could refuse its honest snapshots as replays (
snapshot_replayed) whenever the retired Gateway key had signed a snapshot with an inflatedseqor a laterissued_at. A stolen key can do exactly that before the owner re-binds.User Impact
User impact: browsers (through the vendored protocol), node hosts and native apps follow a re-bind to a new Gateway key without being stuck refusing its snapshots. Rollback protection stays the same: the
binding_seqhigh-water carries across the key change, so the old binding and its key's snapshots are still refused.Why This Change Was Made
J5 (decided): only R-signed bindings the client verified raise its binding_seq high-water. A snapshot naming a binding_seq above the binding it verified under is refused with
snapshot_ahead, and nothing of it is stored. Before this change,mergeFreshnessStatestored the snapshot's claimed binding_seq, so a stolen K_gw could make every bindingstale_bindingforever. J1 always replaces K_gw, so an honest K_gw never names a binding beyond its own. With the cap, the per-key order switch uses the verified binding_seq alone, and the separatek_gw_binding_seqfield from the earlier review fix is gone. On load,clampFreshnessStatemigrates only legacy markers, the ones withoutk_gw: their binding_seq is capped at the pin, and their(seq, issued_at)is dropped because it can't be attributed to a key. Node hosts do this on parse, and the loader in claw-loader#12. Markers withk_gware kept as stored, because their binding_seq is always a binding this client verified, even when the pin didn't advance (review P1s). Accepted edge case: right after the upgrade, older snapshots of the current key aren't refused as replays until a new marker is stored. This lasts at most the 3 h freshness window.Compatibility: a Gateway on current
mainor the previous build always signs snapshots at its own binding_seq (1). Discovery refuses a snapshot for a binding it doesn't publish, sosnapshot_aheadcannot occur for them. After a re-bind, a snapshot read between descriptor writes is signed by the new K_gw and fails verification under the old binding (snapshot_invalid, transient), notsnapshot_ahead.The freshness marker records the K_gw that signed the accepted snapshot. Snapshots are ordered only among those signed by the same K_gw; a higher verified R-signed binding permits switching keys. Only verified bindings raise the retained binding high-water. The separate
k_gw_binding_seqfield is not part of the final implementation. Node hosts persist the keyed marker. Legacy keyless markers are capped at the pin and have their unattributable order dropped on load, as described above.Accepted upgrade tradeoff: until a keyed marker is stored again, otherwise-valid older snapshots can pass within the existing ≤3-hour freshness window. Live real-tunnel and stable-upgrade proof remain outstanding; helper and compatibility checks do not close those gates.
Evidence
J5: an inflated snapshot is refused and the stored state is unchanged; the honest binding then dials (protocol, node host transport). A legacy inflated high-water is capped on load and its order is dropped. A retired key's inflated legacy
seqno longer blocks the replacement key after a J1 re-bind; this test fails on the previous clamp. A keyed marker is never clamped. The honest J1 re-bind path still passes.freshness.test.ts: a retired key's inflated snapshot followed by a re-bind → the new key's snapshot is fresh. Order then continues within the new key (an older one issnapshot_replayed), and the old binding is stillstale_binding. The new test and the two marker-shape tests fail onmain.Independent review: a retired key's snapshot claiming the next binding could keep the marker on the old key and let Discovery replay the new key's older snapshots. Fixed, and the regression fails before the fix.
openclaw-id-target.test.ts: the saved marker keeps a validk_gwand refuses a malformed one.Node host transport, target and join suites are green, including "retains rollback evidence across restart".
tsgo:core, oxlint and format are clean.Discovery restarts order the same way (openclaw/discovery#11). The loader and native apps pick this up when they re-vendor the protocol.
J5 compatibility with existing Gateways (executed)
Honest histories were signed by the publisher and protocol code of current
main(a2fdc8d4cf08) and of the previous main build (245cbaf915c2). Each was taken from that ref withgit archiveand drivespublishClawwith a capturing Discovery client. The history covers a link at binding 1, an hourly republish, a membership change (snapshot seq 2→3), an honest K_srv rotation to binding 2 signed by R, and a republish. Each old build's ownassessFreshnessalso recorded the state it stores after every step, which is the legacy unkeyed marker.The new client code (openclaw
95bc5e5freshness, and claw-loader55e799avendored protocol, which is identical) then:verifyBindingForPinand runsassessFreshnessfrom an empty store;clampFreshnessState(state, pin.binding_seq), checks it was clamped only as designed (binding_seq unchanged, order dropped, nok_gw), and continues through the remaining steps.Result (both producers emitted byte-identical evidence):
There were no
snapshot_aheadverdicts and no refusals. Every loaded legacy marker kept its binding_seq: honest markers never exceed the pin, so the cap is a no-op. Only the unattributable (seq, issued_at) order was dropped, and the next honest snapshot restored a keyed marker.produce.mts (run inside each archived ref)
consume.mts (new code)
Output: producer main, consumer openclaw 95bc5e5 (the other three runs are identical)
Integrated staging acceptance and final cleanup — November 10
This closes the earlier pending same-claw staging run, not exact-head hosted CI or every PR-specific test gap. The isolated Gateway used combined source
f864514d93a08efda68c14eabc42768f081af854; the repaired registered CLI usedf08fea43c6979223ebf44f8b05020dd3033414ea. These are integrated proof refs, not the individual PR heads.studio-ui-rebind-v4-call-result.json).moved:true/published:true, and authenticated readback confirmed binding/published 4. Root, two owner certificates and membership remained intact (studio-cli4-owner-follow-call-result.json).system.which(uname)passed (studio-cli4-restart-call-result.json). This does not retroactively prove owner-browser following of each earlier rotation.snapshot_ahead, without advancing pin/freshness or connecting. This used an isolated signed HTTP fixture, not a malicious write to staging (studio-snapshot-ahead-native-result.json).readStoredClaw/publishClawused real old binding-3 SQLite and keys against staging: HTTP 409stale_bindingcarried binding 4, verified under the root, producing non-retryablebinding_superseded. Current-key authentication succeeded before/after; current Gateway/native/owner recovery then passed. This is persisted-state/publisher integration, not a full old-Gateway boot (studio-rollback3-publisher-result.json,studio-post-rollback4-recovery-call-result.json).Shipped older-writer limitation: the remotely verified latest stable
v2026.11.2and betav2026.11.5-beta.1examined here contain neithersrc/gateway/openclaw-idnorpackages/openclaw-id-protocol. A compatible shipped writer was not available in that bounded set, so a shipped-writer upgrade was not executed and cannot be claimed. This is not an exhaustive statement about every historical release. Seeshipped-old-writer-feasibility.json.Evidence files above are operator-local under
/tmp/ocid-rollout-evidence/, not downloadable GitHub attachments. Final receipts:studio-final-retirement-descriptor-result.json,studio-final-cleanup-result.json,studio-final-private-state-cleanup-result.json,studio-final-lock-release-result.json; full run chronology:studio-harness-integration-audit.md.Inspectable native replay and SQLite upgrade evidence — November 10
This update supplies public redacted excerpts for the earlier operator-local proof references and the previously pending native replay/SQLite cases. It supersedes the earlier pending-proof statements only within the boundaries below. IPs, keys, tokens, emails, private identities and non-public endpoints are omitted. No staging claw was recreated.
Existing integrated native re-bind/restart and snapshot_ahead traces
Historical combined Gateway source
f864514d93a08efda68c14eabc42768f081af854, repaired CLIf08fea43c6979223ebf44f8b05020dd3033414ea; these are not a fresh deployment of the PR head.Selected actual Gateway-restart receipt fields:
{ "passed": true, "bindingSeq": 4, "publishedBindingSeq": 4, "nativePersisted4": true, "sameNativeNodeReconnected": true, "harmlessCommand": true, "sameOwnerReconnected": true, "bindingUnchanged": true, "cleanupConfirmed": true }The production SQLite loader read saved binding-4 pin and keyed freshness before the same native node reconnected and completed
system.which. Stored root-signed binding endpoint/Gateway keys were checked against the current binding. The owner profile independently reconnected after that distinct Gateway process restart.Selected existing native snapshot-ahead receipt fields:
{ "passed": true, "stagingDiscoveryChanged": false, "requestSignatureVerified": true, "fixtureSignatureVerified": true, "descriptorBindingSeq": 3, "snapshotClaimedBindingSeq": 4, "refusal": "snapshot_ahead", "bridgeHttpStatus": 502, "descriptorRequests": 1, "persistedRefreshes": 1, "pinUnchanged": true, "freshnessUnchanged": true, "targetUnchanged": true, "noServerConnection": true, "cleanupConfirmed": true }This was actual native transport with copied real SQLite node trust and a signed local response fixture—not a malicious staging write. Refusal retained the saved trust and made no server connection. It is distinct from the new fully synthetic exact-head replay cases below.
New exact-head native replay and pre-PR SQLite writer qualification
Additional isolated native/SQLite runtime proof
Candidate
77f6c1e13c49b9897b08b303911986684480a6d7: 11 separate OS processes exited 0 using production node transport and production SQLite workers. Real native addon SHA-256:570ef4e7323a24b5afa373ec24abda7e89c7cee89367aef1333d7fa8e1d7d7e2; runtime loader reportednative, with the artifact observed inrequire.cache. Native source checkout8d20985e878b4eef195e040ea0fef6425536566dmatches the candidate's tracked addon source.rollback); replaying the retired-key snapshot under the current binding returned 502 (snapshot_invalid). Same-key lower sequence and older timestamp each returned 502 (snapshot_replayed). Every refusal had 0 native connect calls, 0 openBi calls, 0 peer accepts/streams/HEADs and 0 peer-addressed send syscall entries. Transparent counters delegated to real addon methods;straceand the real receiver corroborated them. Four accepted controls each completed one real QUIC request. Discovery signatures: 8 valid requests, 0 errors.nodeHost.configvalue JSON bytes stayed identical across the replays, including keyed trust and unrelated node settings.eaa8aebfb69368a748f4aaf39166a8bf339f70ecactually wrote a keyless legacy marker(seq=900, binding_seq=50)after a signed synthetic snapshot exceeded verified binding 1. Candidate production SQLite loading normalized it to(seq=0, issued_at=0, binding_seq=1), preserving pin, signed evidence and unrelated settings. A subsequent real-native refresh saved the new keyed marker; another OS process loaded the full config unchanged. This is an unreleased preview-writer upgrade, not an older-shipped/stable upgrade.Scope: isolated synthetic identities, loopback Discovery and framed-HTTP native peer, source-runtime modules rather than packaged-release qualification. No native/persistence mocks, live/personal profiles or staging identity. Endpoint binding/background relay attempts precede freshness validation; zero-effect claims concern target QUIC connect/stream/request I/O, not all native socket activity. The existing native binary was identified by hash, not rebuilt or reproducible-build qualified here. The synthetic endpoint seed was re-established with identical bytes before each child; this qualifies freshness/config restart behavior, not endpoint-key lifecycle. Legacy unowned snapshot order is intentionally dropped until a keyed marker is learned. Normal runner startup configuration was retained and asserted logically unchanged. Nonqualifying harness/setup attempts were preserved separately; the complete final run passed. All owned processes/endpoints were closed; raw evidence remains private and redacted artifacts contain no keys or routing addresses.
Selected terminal JSON lines from separate real client processes (no keys or addresses):
Production refusal messages were
rollback,freshness_unavailable (snapshot_invalid), andfreshness_unavailable (snapshot_replayed)for both same-key cases. Endpoint bind occurred once per transport process; target connect/openBi remained zero for refusals.Preview-written row:
(seq=900, binding_seq=50, k_gw absent). Candidate effective load:(seq=0, issued_at=0, binding_seq=1, k_gw absent). After successful native refresh:(seq=3, binding_seq=2, k_gw=[REDACTED_NEW_KEY]). The loader normalizes legacy state; the later ordinary refresh makes keyed storage durable. The preview profile was generated by unmodified production configure/assess/refresh calls, never SQL INSERT or database editing. Pin (including keyed trust), signed binding/root evidence and unrelated settings were compared exactly.Parent verification independently matched 18 candidate/preview source files to Git, verified the artifact-manifest hashes, inspected both harnesses and the raw assertions, and recounted all 11 address-specific syscall traces. The zero-send result matches both peer address and port, not merely port number.
Older shipped-writer upgrade: not applicable to these unshipped paths. The stable/beta absence evidence above is bounded; no shipped-upgrade execution is claimed. The newly demonstrated compatibility case is an actual pre-PR preview writer → production SQLite loader in a throwaway profile.
Exact-head hosted CI observed terminal with no failures and
openclaw/ci-gatesuccess. Hosted proof reassessment is still required; no merge or production deployment is authorized by this evidence.