Repository navigation
Description
Problem
Integrity verification on cdn/client/v1 uses a flat, sequential blake3::Hasher over the assembled stream:
- Buffered: whole-blob re-hash after
StreamEnd—crates/node/src/client_requester.rs:509 - Progressive: incremental flat hasher fed chunk-by-chunk, finalized in
finish()—crates/node/src/client_requester.rs:756,:819
A flat hash is inherently sequential — you cannot verify byte N without bytes 0..N. Consequences:
- Resume fetches (
byte_offset > 0) skip whole-blob verification (client_requester.rs:495). A node can serve a corrupt tail on a resumed range and the receiver has no way to reject it on its own. - No parallel multi-source fetch. Disjoint ranges from different peers can't be independently verified against the content address, so we can't safely stitch a blob from multiple sources.
Insight
BLAKE3 is a Merkle tree, not a flat hash. The content hash we already store/advertise is the bao root. Given the bao outboard (the interior tree nodes), any range verifies independently against the root with an O(log n) proof — no earlier bytes needed. This closes the resume gap and unlocks parallel fetch with one mechanism.
The outboard is already materialized for free: every node imports blobs through FsStore::add_stream / add_bytes (crates/cache/src/engine.rs:1960, :2051), and iroh-blobs (0.100, bao-tree transitive) builds + persists the outboard as a byproduct. Nothing new to compute on the hot path; nothing to transmit as "trusted" (content-derived, self-validating). The publisher CLI stays flat-blake3 / iroh-blobs-free (#578) — the flat root is the bao root, so the first importing node derives a matching tree.
Approach: option 2 — bao interleaved encoding as payload
Carry bao's native interleaved verified-stream encoding (proof nodes inline, immediately before the data they authenticate) instead of bolting a separate boundary proof onto the StreamResponse header.
Rationale over the header-proof variant:
- Reuses the codec. bao-tree's decoder only consumes proof+data interleaved in tree order. A separate-header layout forces us to re-interleave or hand-roll the verifier — i.e. own the cryptographically-exact path while the tested dep sits unused.
- No two-chunk-size reconciliation. Our wire
ChunkDataframe size != bao's 16 KiB group size. Interleaved encoding makes the bao codec the source of truth; wire framing stays irrelevant to verification (partial last group, right-edge spine handled by the codec). - Composes into parallel fetch for free. Each source hands an independently-decodable interleaved range; bao-tree verifies each against the same root and we concatenate.
Scope / plan
cdn/client/v1 is not finalised (pre-testnet), so we change the format in place — no version bump, no backwards-compat shim.
- Wire (
crates/protocol) — change the delivery payload to a bao-encoded byte stream (still framed intoChunkData-sized pieces so payment vouchers stay interleaved as today). Keep theStreamResponse/ voucher /StreamEndenvelope. - Serve side (
crates/cache+crates/node/src/handlers/client.rs) — export verified ranges from the store (iroh-blobs range export overChunkRanges) instead ofget_bytes+ raw write. Outboard already on disk; read it, don't recompute. - Receive side (
crates/node/src/client_requester.rs) — replace the flatblake3::Hasherwith a bao-tree verifying decoder fed the reassembled stream, validating each group as it lands (early rejection) and onfinish(). Removes thebyte_offset > 0verification gap. - Tests — corrupt-tail-on-resume now rejected; verified range from offset > 0; (later) multi-range stitch verifies against root.
Conditional / non-goals
- Offset-0, single-source, contiguous fetch is untouched and pays zero proof overhead — the existing flat-hasher path already fully verifies that case; a proof there is redundant. Verified-range encoding applies only to resume / non-zero / multi-source.
- Origin-cold path (first pull straight from origin, outboard still being built) can't ship proofs for not-yet-imported bytes; it stays sequential single-source. Verified-range serving kicks in on every subsequent serve from a node holding the full blob.
- Parallel multi-source scheduler (which peer gets which range, stitching, re-dispatch on failure) is a separate, larger effort — out of scope here. This issue is the verification prerequisite that makes it safe. Likely warrants its own ADR.
Open decision
Payment metering. With interleaved encoding, paid bytes = data + proof (~0.4% overhead rides on the paid channel). The header-proof variant would have metered pure content with the proof free. Deliberate call needed — probably "yes, charge for it, it's bandwidth," but record the choice.
Suggested follow-up
Consider an ADR (next number 038) for the verified-range protocol change, and a second ADR for the multi-source fetch scheduler it unlocks.
Refs: crates/protocol/src/client.rs, crates/node/src/client_requester.rs, crates/node/src/handlers/client.rs, crates/cache/src/engine.rs. iroh-blobs 0.100 / bao-tree.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon Jun 15, 2026
🎯 Triage report
This issue identifies a concrete integrity gap in
cdn/client/v1: resumed fetches (byte_offset > 0) currently bypass whole-blob BLAKE3 verification, allowing a malicious upstream to serve a corrupt tail undetected. The fix is a protocol-layer switch to bao interleaved encoding, leveraging the outboard already materialized by iroh-blobs — no new cryptographic computation on the hot path. The proposal is well-scoped, references specific file/line locations, and correctly identifies a breaking wire-protocol version bump as the one unavoidable consequence.📊 Assessment
security,ADR,missing-decisionaddednodeandcli🔗 Similar issues
total_bytesin the sameclient_requester.rscode path; different attack vector, same attack surface, already fixed💡 Notes and suggestions
Pre-requisites before implementation starts
adr/first. The ADR should record the payment metering decision (issue's open question: "charge for proof bytes or not?"). The suggested answer ("yes, charge for it, it's bandwidth") is reasonable and worth locking down to avoid a second round-trip.Implementation notes
byte_offset > 0skip atclient_requester.rs:495is the immediate security gap. A targeted fix limited to that path (reject or down-grade unverifiable resumes until bao shipping) could be shipped as a short-term hardening before the full bao implementation lands.ExportRanges/get_verifiedAPIs expose the outboard-backed range export — no need to re-read the outboard manually.bao_tree::io::DecodeResponseIter/AsyncSliceDecoderconsume the interleaved stream and surface per-group errors, enabling early rejection well beforeStreamEnd.ChunkData-sized pieces can still wrap the interleaved bao output; the bao codec doesn't care about transport framing, so voucher interleaving is unaffected.Suggested sub-tasks
byte_offset > 0resumes until bao path is implemented (client_requester.rs:495)cdn/client/v1, document bao interleaved payload formathandlers/client.rsto export viaChunkRangesrange export, read outboard from iroh-blobs storeblake3::Hasherflat path withbao_treeverifying decoder inclient_requester.rsoffset > 0accepted; mismatched root rejectedAdd this agentic workflows to your repo
To install this agentic workflow, run
feat(cache,protocol): range origin pull-through — ADR decision + bao …
feat(protocol): bao verified-range streaming on cdn/client/v1 (#915)
fix(node,cache): rewire tee corruption verdict into reputation + erro…
docs(adr): withdraw ADR 038 from Accepted back to Draft
feat(protocol): bao verified-range streaming on cdn/client/v1 (#915) (#…
refactor(bao): defensive corruption routing + doc accuracy (#1060)
refactor(bao): type-design tightenings, deferred tests, doc sweep (#1060
fix(node): score decoupled serve-miss upstream corruption + drain on …
feat(node): decoupled serve-miss pull+serve legs (#1651)