You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(node): refuse before serving when deposit can't cover the next interval #1516
kind:bugSomething does not behave as documentedkind:securitySecurity impact; report a vulnerability to [email protected], not hereprio:highNext uprustDependabot: a Cargo update; use area: labels for Rust code otherwise
Off-by-one fix. The seller signs a success StreamResponse and ships up to one voucher interval (~1 MB) before the per-voucher deposit ceiling can fire, so a channel that can't cover even the first interval still gets ~1 interval served.
Change: in the serve path before signing (crates/node/src/handlers/client/dispatch.rs:515-603, sign at :584, deliver at :589), compute next-interval cost = interval_bytes × rate_per_mb; if the cached channel deposit is below it, refuse rather than sign+serve.
Refusal signaling: prefer InsufficientDeposit
The per-voucher ceiling check (crates/incentive/src/channel.rs:401) stays as the mid-stream backstop.
Out of scope: interval size / rate logic.
Acceptance: a request against a channel that can't cover one interval serves zero bytes; a channel that covers ≥1 interval serves normally.
The seller-side dispatch path signs a StreamResponse and delivers up to one voucher interval (~1 MB) before the per-voucher ceiling in incentive/src/channel.rs:401 fires, meaning a channel whose deposit can't cover even the first interval still receives ~1 MB of service gratis. The fix is a pre-flight check in node/src/handlers/client/dispatch.rs (around line 515–584) that computes next_interval_cost = interval_bytes × rate_per_mb and refuses with InsufficientDeposit before signing if the cached deposit is below that threshold.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
Off-by-one in deposit sufficiency check — economically exploitable correctness defect
Labels
bug, security, rust, high
Economic exploit; underfunded channels get ~1 MB free; fix is pure Rust in node + incentive crates
Coding agent
Suitable
Requirements are precise: add a pre-flight deposit check before signing at dispatch.rs:584, return InsufficientDeposit if deposit < interval_bytes × rate_per_mb. Scope is explicitly bounded (no changes to interval size/rate logic). Acceptance criteria stated.
crates/node/src/handlers/client/dispatch.rs lines 515–603 — serve path; signing happens at ~584, delivery at ~589. The pre-flight check belongs here, before the sign.
crates/incentive/src/channel.rs:401 — existing per-voucher ceiling check; this stays as the mid-stream backstop.
Implementation checklist:
Read channel.cached_deposit (or equivalent) at the start of the serve path.
Compute next_interval_cost = interval_bytes * rate_per_mb / 1_000_000 (confirm unit convention in the crate).
If cached_deposit < next_interval_cost, return InsufficientDeposit error before calling sign.
Ensure the refusal path does not sign or ship any bytes.
Add a unit test: channel with deposit = next_interval_cost - 1 must serve 0 bytes; channel with deposit = next_interval_cost must serve normally.
Anti-panic note: The workspace denies unwrap_used/expect_used — use checked_mul or saturating_mul for the cost arithmetic, and handle the None branch.
Acceptance criteria (from issue): a request against a channel that can't cover one interval serves zero bytes; a channel that covers ≥1 interval serves normally.
Generated by Agentic Triage for #1516 · sonnet46 · 23.6 AIC · ⌖ 8.44 AIC · ⊞ 6.2K · ◷
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
kind:bugSomething does not behave as documentedkind:securitySecurity impact; report a vulnerability to [email protected], not hereprio:highNext uprustDependabot: a Cargo update; use area: labels for Rust code otherwise
Activity
github-actions commentedon Jul 29, 2026
🎯 Triage report
The seller-side dispatch path signs a
StreamResponseand delivers up to one voucher interval (~1 MB) before the per-voucher ceiling inincentive/src/channel.rs:401fires, meaning a channel whose deposit can't cover even the first interval still receives ~1 MB of service gratis. The fix is a pre-flight check innode/src/handlers/client/dispatch.rs(around line 515–584) that computesnext_interval_cost = interval_bytes × rate_per_mband refuses withInsufficientDepositbefore signing if the cached deposit is below that threshold.📊 Assessment
bug,security,rust,highInsufficientDepositifdeposit < interval_bytes × rate_per_mb. Scope is explicitly bounded (no changes to interval size/rate logic). Acceptance criteria stated.🔗 Similar issues
💡 Notes and suggestions
Key locations:
crates/node/src/handlers/client/dispatch.rslines 515–603 — serve path; signing happens at ~584, delivery at ~589. The pre-flight check belongs here, before the sign.crates/incentive/src/channel.rs:401— existing per-voucher ceiling check; this stays as the mid-stream backstop.Implementation checklist:
channel.cached_deposit(or equivalent) at the start of the serve path.next_interval_cost = interval_bytes * rate_per_mb / 1_000_000(confirm unit convention in the crate).cached_deposit < next_interval_cost, returnInsufficientDepositerror before calling sign.next_interval_cost - 1must serve 0 bytes; channel with deposit =next_interval_costmust serve normally.Anti-panic note: The workspace denies
unwrap_used/expect_used— usechecked_mulorsaturating_mulfor the cost arithmetic, and handle theNonebranch.Acceptance criteria (from issue): a request against a channel that can't cover one interval serves zero bytes; a channel that covers ≥1 interval serves normally.
Add this agentic workflow to your repo
To install this agentic workflow, run
feat(node): refuse a stream when the deposit cannot cover the first c…
fix(node): price the deposit gate on the aligned span, stop double-cl…
fix(node): refuse an underfunded channel before any fill tier spends
fix(node): refuse an underfunded channel before any fill tier spends
fix: close the three #1518 review follow-ups — pre-spend deposit floo…