Repository navigation
Description
Severity: medium-high — attack-surface review of the paid delivery path. Sibling finding: corrupt-at-rest serving (filed as #1984); both trace to the same root — bytes are proven once, at an edge, always after money moves.
The gap
The buffered receive path pays for the whole stream before any byte is verified:
expected_wireis derived from the peer-signedtotal_bytesclaim (crates/client-pull/src/lib.rs:2056, fed by the signedStreamResponse). A hostile provider signs its own inflated claim — that signature proves attribution, not truth.receive_and_payreleases a reveal per 1 MiB chunk as bytes arrive and a closing residual voucher at end-of-stream (lib.rs:2352, 3281). BLAKE3 verification runs only after the loop completes (lib.rs:2116) on this path. Reveals already released are irreversible; nothing about them is refundable if decode then fails.- The progressive path (
open_progressive_pull→PullReader/sink feeding the bao decoder) decodes incrementally off the wire — there a corrupt group aborts within ~one chunk-group of arrival. The asymmetry is the point: exposure depends on which receive path a caller happens to use.
So on the buffered path (loopback fills / shared pulls), "valid-framed garbage billed up front" is a deliberate abuse of an otherwise accepted pay-before-prove design, not just generic corruption.
What already bounds it (corrections to the naive exploit)
| Bound | Effect |
|---|---|
max_received_wire = aligned wire size of cache.max_blob_size_mb (#1895, default 50 GB), enforced on bytes that actually arrive, aborting before paying the crossing chunk (lib.rs:2326) |
Caps the bleed even with a fully-inflated claim — unless the buyer sets max_blob_size_mb: 0 (= unlimited) |
Cumulative overrun guard vs expected_wire (lib.rs:2313) |
Over-billing scales exactly with the inflated claim, no further |
Per-capability spendingCap + pool spendable |
Hard on-chain bound; note genuine_exhaustion auto-prompts top-up (lib.rs:1911), letting a sharp attacker extend the bleed past the original deposit |
Rate inflation is already closed: the effective ceiling is min(probe quote, config absolute) and RateAboveCeiling aborts before the first voucher (lib.rs:2031); probe-relative binding makes completed deliveries non-challengeable |
Only bytes inflate |
Per-stream loss ≈ min(inflated_claim, 50 GB-wire) × rate; time-bound by throughput (~44 s at 10 Gbps). Fleet-wide, repeated per discovery attempt.
Impact
Pure billing-for-garbage on the buffered path: honest-rate payment for undelivered/undeliverable bytes, bounded by the buyer's own ceilings but shifted entirely onto victims before proof exists. Same economics as #1984 plus the inflation lever, minus persistence.
Refs: #1984, ADR 005 §Payment metering, ADR 038 §Receive side.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
thiras commentedon Sep 10, 2026
Recommendation
1. Unify both receive paths on incremental verification (the fix).
The end-of-stream whole-buffer decode (
decode_verified_rangeat lib.rs:2116, called only byfetch_inner_once) is the cascade origin: it exists solely because this path drains to aBytesMutinstead of decoding as frames arrive. The progressive path already has the machinery —PullReader+ sink feedingDecodeResponseIter, withclassify_decode_errorsplitting hash-mismatch from truncation. Route the buffered path's buffer through that same decoder as bytes land, then the distinct second decoder and its completeness special-cases collapse into one streaming implementation.Effect: hostile-provider overpayment drops from ≤ 50 GB-wire to ≈ one chunk group (16 KiB content + proof slack) on every path; detection latency becomes arrival latency, matching what the reveal cadence already implies. Wire format untouched; localised to
client-pull.2. Considered and kept out: deferring the closing residual voucher until after decode — recovers < 1 MiB of exposure for a new commit-ordering rule interacting with the throughput-floor pause window.
3. Considered and kept out: refund claims / per-stream escrow — node-cooperative refunds are voidable by exactly the party they'd constrain, and a new on-chain record fails the live-consumer gate today. The #1984 "false delivery" slash thread is the strict subset worth revisiting if measurements ever justify contract surface.
4. Document rather than build:
max_blob_size_mband the capabilityspendingCapare the intended per-channel exposure bounds ("0 = unlimited" deserves a loud warning); and the dispute window adjudicates watermarks/rate evidence, not content quality — buyers absorb failed-delivery losses by design.Tests to write
max_received_wire.total_bytes⇒ committed ≤ min(spendingCap remaining, ceiling-wire × quoted rate).yigitdot commentedon Sep 11, 2026
Verification against main (
8b437de5)Mechanism is valid; blast radius is wrong.
Holds:
expected_wirederives from the peer-signed, unboundedtotal_bytes(lib.rs:2045-2046; the comment at 2008-2015 already calls it "peer-controlled and unverified").receive_and_payreleases a reveal per 1 MiB as bytes land (lib.rs:2341-2350) plus the closing residual;decode_verified_rangeruns only after the loop atlib.rs:2105and is called only fromfetch_inner_once. Buffer-then-decode, not incremental.open_progressive_pull→PullReader→ResponseDecoder,ranged_store.rs:558-599,admit_store.rs:138-148) aborts at the first bad group. Asymmetry confirmed.max_received_wire(2054-2066, enforced at 2315-2320 before pay;0= unlimited), overrun guard (2302-2306),RateAboveCeiling(2020-2022),genuine_exhaustion(1900-1925). Effective default bound ismin(50 GB, cache_size_mb) × rate.Does not hold:
stream_fetch,stream_fetch_tracked,stream_fetch_tracked_with_progress,stream_fetch_sharedhave zero production callers incrates/node/srcorcrates/cli/src— only doc-comment mentions. Node cache-miss pulls (node_origin/pull_leg.rs:391,744,811,1100) and CLI fetch (commands/fetch.rs:1804,1865,1884,2067,2207) all useopen_progressive_pull/PeerSource/drive. The only code callers arecrates/e2e/src/client.rs(test-infrastructure crate) and integration tests undercrates/node/tests/.So on main no buyer is exposed to this today; the exposed surface is test scaffolding.
Two comments in
lib.rsare wrong and should be fixed regardless:lib.rs:1987-1993claims node-to-node loopback/shared-channel callers reachfetch_inner_once. None exist.lib.rs:2330-2333says a reveal is released "only AFTER the bytes it pays for have been received and verified, so the payer's exposure stays at zero." On this path the bytes are received but not verified when the reveal fires.Suggested rescope: keep open, narrow to one of: (a) delete the
stream_fetch*buffered path and movecrates/e2e+ the integration tests onto the progressive driver, so there is one receive implementation; or (b) unify as recommendation 1 describes. (a) is less code. Either way, fix the two comments above, and note that ADR 038's acceptance criterion "a corrupt chunk group is rejected at that group, not only at finalization" is what the surviving path must keep satisfying.