From 4b62248bdc0a99dd15f4ff4005f60595aab81bcf Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 11:45:18 -0600 Subject: [PATCH] fix(id): unmask MissingBlob in verify_import and repair hosted_export fixtures (#13444) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two defects from e7888eb8616 (#13289 citation binding): 1. Production: verify_import compared declared blob_refs against citation-resolved refs before checking whether a cited blob was carried at all, so an object whose references name a blob the export does not carry was refused as BlobCitationMismatch instead of MissingBlob. A declared reference naming no carried blob is now the plain MissingBlob refusal, checked before citation binding. The #13289 regression tests (decoy, missing cited blob, extra reference) keep their verdicts. 2. Tests: three honest-export fixtures built exports no honest producer emits under the binding semantics — document.put envelopes citing content the carried blobs did not contain, or citing content the export did not carry at all. The fixtures now carry exactly the cited content (delayed-rebind and canonical/wire tests) or cite nothing (fast-path history test, which exercises step-2 history only). cargo test --all-features --lib in pkgs/id: 253 + 756 + 561 passed, 0 failed (previously 4 hosted_export failures). --- pkgs/id/src/hosted_export.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pkgs/id/src/hosted_export.rs b/pkgs/id/src/hosted_export.rs index 5dbcb15008..348d619c12 100644 --- a/pkgs/id/src/hosted_export.rs +++ b/pkgs/id/src/hosted_export.rs @@ -631,6 +631,15 @@ pub fn verify_import( // source `cited_content_hashes` reads): the references // must name exactly the carried blobs whose bytes hash to // the cited contents — no decoy, no extra, none omitted. + let declared_refs: std::collections::HashSet = + object.blob_refs.iter().cloned().collect(); + // A reference naming a blob the export does not carry at + // all is the plain missing-blob refusal, checked before + // citation binding so a dangling reference is not masked + // as a citation mismatch (#13444). + if declared_refs.iter().any(|r| !carried_blobs.contains(r)) { + return Err(ExportError::MissingBlob); + } let cited: Vec = match &event.header.extensions.document { Some(document) => vec![document.content.to_hex()], None => Vec::new(), @@ -643,8 +652,6 @@ pub fn verify_import( resolved_count += 1; } } - let declared_refs: std::collections::HashSet = - object.blob_refs.iter().cloned().collect(); if declared_refs != resolved_refs { return Err(ExportError::BlobCitationMismatch); } @@ -1240,13 +1247,9 @@ mod tests { // Objects from both sides of the rotation stay verifiable: the // binding chain in step 2 admits every key in the history. - let blob = ExportBlob::new(b"shared blob".to_vec()); - let old_object = signed_object( - &old_key, - b"written before the rebind", - vec![blob.hash.clone()], - ); - let new_object = signed_object(&new_key, b"written after", Vec::new()); + let blob = ExportBlob::new(b"written before the rebind".to_vec()); + let old_object = document_object(&old_key, &blob, b"written before the rebind"); + let new_object = message_object(&new_key); let export = build_export( &svc, &binding, @@ -1273,7 +1276,7 @@ mod tests { assert_eq!(binding.history[0].via, "old-key-signature"); // The fast path is the old key's signature over the transfer, // checked at publication: the export carries no backing record. - let object = signed_object(&old_key, b"pre-rotation", Vec::new()); + let object = message_object(&old_key); let export = build_export( &svc, &binding, @@ -1483,8 +1486,8 @@ mod tests { fn export_is_canonical_and_survives_the_wire() { let mut svc = service(); let binding = bind(&mut svc, 21, None); - let blob_b = ExportBlob::new(b"second".to_vec()); - let blob_a = ExportBlob::new(b"first".to_vec()); + let blob_b = ExportBlob::new(b"bbb".to_vec()); + let blob_a = ExportBlob::new(b"a".to_vec()); let obj_b = signed_object(&root_key(21), b"bbb", vec![blob_b.hash.clone()]); let obj_a = signed_object(&root_key(21), b"a", vec![blob_a.hash.clone()]); // Deliberately scrambled input order.