Repository navigation
fix(signing): canonicalize signed/hashed JSON explicitly, not via serde_json map order - #2297
Merged
Merged
Conversation
…de_json map order Six sign/hash inputs built a `json!` object and serialized it with `serde_json::to_vec`, relying on `serde_json::Map` being a sorted BTreeMap. That holds only while no crate in the build enables `serde_json/preserve_order`. Cargo unifies features workspace-wide, so one dependency turning it on (lancedb 0.41.0 does) silently switches every `Map` to insertion order and changes these bytes: existing channel signatures stop verifying and HITL action pins drift. Route them through the existing `mur_common::canonical::canonical_json` (recursive key sort, no whitespace), which is byte-identical to the current output in a default build: - mur-channel: event sign_input / sign_input_v2, Head::sign_input - mur-common: hitl::pin::action_hash, signal sign_input, memory proposal - mur-agent-runtime: Slack inbound bridge envelope payload Typed structs (license, fleet bundle, audit action) serialize in field declaration order and are unaffected; JCS callers already sort. Adds a golden-bytes test for the channel sign input with keys inserted out of order at two depths. Verified: mur-channel + mur-common 1662 passed both default and with `--features serde_json/preserve_order`; control run without this change under preserve_order fails 2 (head_sign, hitl pin). CI clippy + fmt clean.
karajanchang
added a commit
that referenced
this pull request
Nov 6, 2026
0.38-0.40 failed to compile without the `remote` feature (lancedb/lancedb#4142); 0.41.0 fixes it (#4233), so move the exact pin. lancedb 0.41 enables serde_json's `preserve_order`, which has two effects: - Object key order now follows insertion order. Signing/hashing paths that relied on BTreeMap ordering were moved to canonical_json in the parent PR (#2297), so signed bytes are unchanged. - `serde_json::Value` grows, pushing `TaskError` past clippy's `result_large_err` limit. Box `TaskError.details`; Box is transparent to serde, so the A2A wire format is unchanged (pinned by a new test). lance no longer pulls tantivy transitively, so the tantivy pin comment is updated: our direct use is now free to move independently.
karajanchang
added a commit
that referenced
this pull request
Nov 6, 2026
0.38-0.40 failed to compile without the `remote` feature (lancedb/lancedb#4142); 0.41.0 fixes it (#4233), so move the exact pin. lancedb 0.41 enables serde_json's `preserve_order`, which has two effects: - Object key order now follows insertion order. Signing/hashing paths that relied on BTreeMap ordering were moved to canonical_json in the parent PR (#2297), so signed bytes are unchanged. - `serde_json::Value` grows, pushing `TaskError` past clippy's `result_large_err` limit. Box `TaskError.details`; Box is transparent to serde, so the A2A wire format is unchanged (pinned by a new test). lance no longer pulls tantivy transitively, so the tantivy pin comment is updated: our direct use is now free to move independently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Six sign/hash inputs build a
json!object and serialize it withserde_json::to_vec, relying onserde_json::Mapbeing a sortedBTreeMap. That only holds while nothing in the build enablesserde_json/preserve_order. Cargo unifies features workspace-wide, so a single dependency turning it on switches everyMapto insertion order and silently changes these bytes.lancedb 0.41.0 does exactly that (
serde_json ^1 ['preserve_order']; 0.37.1 had[]). Trying the bump brokemur-channel::head_sign— existing channel signatures would stop verifying and HITLaction_hashpins would drift. This PR removes the dependency on map order so the lancedb bump can land separately.What
Route these through the existing
mur_common::canonical::canonical_json(recursive key sort, no whitespace). Its output is byte-identical to the current output in a default build, so nothing already on disk changes:sign::sign_input,sign::sign_input_v2,Head::sign_inputhitl::pin::action_hash,signalsign input, memory proposal sign inputDoc comments that claimed "
serde_jsonsorts object keys (no preserve_order)" are rewritten.Not changed, on purpose:
OfficialLicense, fleetBundleManifest, conversationAuditAction) serialize in field declaration order, whichpreserve_orderdoes not affect.fleet_dispatch_request, git-brokeraction_hash, entitlements pin) already sort.rotation.rsand the Telegram bridge each carry a private copy of the same canonicalizer; logic is identical tocanonical.rs. Deduplicating is a follow-up, not a behavior change.Tests
sign_input_bytes_are_key_sorted_at_every_depth(keys inserted out of order at two depths, v1 and v2).cargo nextest run -p mur-channel -p mur-common: 1662 passed, default build.--features serde_json/preserve_order: 1662 passed.preserve_orderrun without this change fails 2 (head_sign::sign_input_is_the_sorted_key_object_without_sig_or_ts,hitl::pin::tests::hash_is_stable_and_order_independent).cargo clippy --all --all-targets --no-deps --locked -- -D warningsandcargo fmt --checkclean; Slack/Telegram bridge tests pass.Generated with MUR