Skip to content

fix(dig-node): recompute the merkle root in the shared anchor-admit gate so admitted/pushed capsules are data-complete (#2246 #2240) - #197

Draft
MichaelTaylor3d wants to merge 2 commits into
mainfrom
fix/anchor-admit-merkle-recompute
Draft

fix(dig-node): recompute the merkle root in the shared anchor-admit gate so admitted/pushed capsules are data-complete (#2246 #2240)#197
MichaelTaylor3d wants to merge 2 commits into
mainfrom
fix/anchor-admit-merkle-recompute

Conversation

@MichaelTaylor3d

Copy link
Copy Markdown
Contributor

Closes #2246, Closes #2240 (super-repo DIG-Network/dig_ecosystem#2246 / #2240 — one deduped family; both are the same ChainAnchoredModuleVerifier code path).

Problem: the capsule-admit trust gate (ChainAnchoredModuleVerifier::rejection_reason, module_anchor.rs) today only byte-compares the module's committed CurrentRoot section against the chain-anchored root — it never proves that committed root is the merkle root of the DATA actually present. A header-matching-but-incomplete/tampered .dig is therefore admitted → cached → served → DHT-announced, turning an honest node into an authoritative source of corrupt content. Same gate backs both reshare-admit (#2246) and cache.pushCapsule land (#2240).

Fix: add a fail-closed rule to the shared verifier — recompute MerkleTree::from_leaves(decode_merkle_leaves(MerkleNodes)).root() from the parsed DataView and reject (NotAnchored) if it ≠ the committed CurrentRoot (or MerkleNodes is absent/undecodable). digstore recompute primitives are already available (no cross-repo cascade).

RED-first regression test (small in-memory fixture — committed root == chain root but MerkleNodes recompute to a different/absent root → must flip Anchored→NotAnchored) + a push-path twin. §5.1 backwards-compat: verified against golden .dig fixtures (the canonical read path already requires MerkleNodes). Version fix: patch 0.100.1→0.100.2.

Draft = loop salvage anchor; implementation in progress.


Generated by Claude Code

…ate so admitted/pushed capsules are data-complete (#2246 #2240)

The capsule-admit gate (ChainAnchoredModuleVerifier::rejection_reason) previously
only byte-compared the committed CurrentRoot section against the chain-anchored
root; it never proved that committed root is the merkle root of the data actually
present. A header-matching-but-incomplete/tampered .dig could be admitted, then
cached, served, and DHT-announced. Add a fail-closed rule that recomputes
MerkleTree::from_leaves(decode_merkle_leaves(MerkleNodes)).root() and rejects
(NotAnchored) on mismatch or absent/undecodable MerkleNodes. Covers both
reshare-admit and cache.pushCapsule land (shared verifier via
verify_capsule_integrity). §5.1-safe: any servable capsule already carries
MerkleNodes (the canonical serve path requires it). 0.100.1->0.100.2.

Closes #2246, Closes #2240.

Co-Authored-By: Claude <noreply@anthropic.com>
@MichaelTaylor3d
MichaelTaylor3d force-pushed the fix/anchor-admit-merkle-recompute branch from 40c2b9c to 7bfb15d Compare August 7, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants