Repository navigation
Description
Found by the multi-agent review of #1518, and independently by two reviewers. Pre-existing — #1518 did not introduce it — but #1518 is where the two deposit guards were brought into step, which is what makes the asymmetry visible.
The gap
serve_stream (crates/node/src/handlers/client/dispatch.rs) runs its cache-miss fill ladder before the channel is resolved, and three of the four tiers spend money with no deposit check:
| Site | Tier | Spends |
|---|---|---|
dispatch.rs try_range_pull_through |
origin range pull (#823) | S3/R2 egress |
dispatch.rs try_local_populate |
local origin (#1116) | operator's own origin egress |
dispatch.rs try_pull_through → cache.populate |
buffered node→node | real upstream USDC (the paid Peer origin) |
dispatch.rs → serve_via_window_pull_through |
window pull-through | guarded — window.rs checks headroom before open_progressive_pull |
The only thing in front of the first three is pull_authorized (crates/node/src/handlers/client/fill.rs), which checks a verified binding, channel existence, signer match, and funder denylist — not deposit. The #1516 direct-serve gate then runs after all of them.
Why it matters
A channel with 1 base unit of headroom satisfies pull_authorized perfectly. So:
- Open a dust-deposit channel.
- Request N distinct hashes the node does not hold, with
byte_offset = 1orbyte_len > 0(either disqualifies the window path, so the request lands on the buffered tier). - The node pays its upstream provider for each blob, then refuses delivery at the fix(node): refuse before serving when deposit can't cover the next interval #1516 gate.
The attacker gets nothing — #1516 closed the free-egress half — but the operator still pays. It is the same wallet drain with the payout removed. The leech-shed budget (leech_admit) does not help either: it lives only in window.rs.
What the operator sees is decdn_serve_stream_rejected_insufficient_deposit_total climbing. That reads as "the guard is working", and on this path it means the opposite: the pull already completed and the money is gone. #1518 corrected the metric doc and ADR 037 to say so, but the doc is the only mitigation right now.
Proposal
Hoist a cheap headroom floor to just after channel resolution — it needs no total_bytes, so it can run before the fill ladder:
headroom >= min_payment(credit_window(interval_bytes), rate)
i.e. "can this channel pay for anything at all". window.rs's guard is the shape to copy (whole-blob ceiling when max_blob_size_bytes is finite, else the speculative window). The existing span-capped gate stays where it is as the exact per-request check.
Note this requires moving the channel resolution above the fill ladder, or duplicating a cheap lookup — worth checking which reads better against the ADR-005 ordering comments in serve_stream.
Acceptance
- A 1-base-unit channel requesting an absent hash does not cause an origin fetch or an upstream dial.
- Test: seed a dust channel, configure a pull-through origin, request an absent hash, assert the origin/upstream was never contacted and the reject counter fired.
- The window path's existing guard is unchanged.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(node): refuse an underfunded channel before any fill tier spends
fix: address the multi-agent review of #1519/#1520/#1521
fix(node): refuse an underfunded channel before any fill tier spends
fix: address the multi-agent review of #1519/#1520/#1521
fix: close the three #1518 review follow-ups — pre-spend deposit floo…
fix(node,client): port node integration tests to lane credit, fix thr…
docs(adr)!: the payer fronts credit (#2877)