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
node: unknown/absent payment channel is not validated before bytes are served — free egress of the first voucher interval #848
kind:bugSomething does not behave as documentedkind:securitySecurity impact; report a vulnerability to [email protected], not hereprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
serve_stream looks up the payment channel as an Option and proceeds to sign ok: true and stream bytes even when the channel is None (unknown / never-opened). The channel is only validated at the first voucher boundary, by which point up to one full voucher interval (clamped to a 1 MB floor) — or the entire blob, if smaller — has already been delivered for free.
Where
crates/node/src/handlers/client.rs:525-582 (serve_stream): let channel = self.channels.lock().await.get(&channel_id).cloned(); — a None is not rejected before delivery.
The owner-binding check at :536-544 runs only when both verified_client and channel are Some, so it does not close the unknown-channel case.
:570-582 signs ok: true and calls deliver, which streams all chunks up to interval_bytes.
crates/node/src/handlers/client.rs:589-665 (deliver): the closing/interval voucher is collected only after unvouchered >= interval_bytes; interval_mb is clamped self.voucher_interval_mb.min(proposed).max(1) (1 MB floor at :549-552).
Rejection happens only in collect_voucher (Some(channel) else { write_reject(WrongChannel); return Rejected }).
Impact
A remote peer with no payment channel at all receives min(blob_size, ~1 MB) of any blob the node caches, for free, per stream — repeatable across streams/connections, bounded only by the dispatch limiter and the 100-stream cap. Blobs smaller than the interval are served in full before the closing voucher is even requested. This is more permissive than the "channels must be pre-persisted" model documented in the module header (#327).
Suggested fix
Reject with StreamError/WrongChannel (before signing ok: true) when the channel lookup returns None. Optionally combine with the on-chain NodeId → client address lookup noted as out-of-scope in #327 to also close the unbound-peer residual.
Notes
Found during a full-repo audit; verified by reading serve_stream/deliver. Related: per-region bandwidth accounting also omits this first-interval traffic (client.rs:781-783), so the leech egress is invisible in regionStats — worth fixing alongside.
serve_stream in crates/node/src/handlers/client.rs signs ok: true and begins streaming bytes before verifying that a payment channel exists. Because the None channel path bypasses the owner-binding guard (line 536 only fires when both verified_clientandchannel are Some), any peer that omits channel setup receives up to min(blob_size, ~1 MB) per stream for free — repeatable and invisible in regionStats. The fix is a targeted early-reject when channel.is_none().
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
Logic defect: validation gate fires after bytes are already delivered
Labels
bug, security, medium, technical
Economic exploit with clear reproduction path; medium severity per author
Coding agent
Suitable
Precise line references, self-contained fix, well-defined acceptance criteria
serve_stream (:525–582) fetches channel as Option<Arc<Mutex<ChannelDeliveryState>>>. The guard at :536–544 only fires when bothverified_client and channel are Some. When channel is None the guard is silently skipped, ok: true is signed at :556–565, and deliver is called with channel: None. In deliver, voucher collection only happens at the interval boundary; for blobs ≤ the interval the closing voucher is the only payment gate — but bytes are already gone by then.
Suggested fix (two changes)
After :527, add an early reject:
// Reject immediately if no channel is registered — do not deliver any bytes.if channel.is_none(){returnself.respond_error(&mut send,&req,StreamError::WrongChannel).await;}
This is the critical fix. It aligns runtime behaviour with the module-doc invariant from #327 and closes the free-egress window before any bytes leave the node.
Secondary (worth fixing alongside per the issue notes): per-region bandwidth tracking at :781–783 (regionStats) does not account for traffic from None-channel streams. Once fix (1) lands this becomes moot for the exploit path, but the accounting gap may still exist for legit streams that hit an error before the first voucher — worth auditing.
Sub-task checklist
Add channel.is_none() early-reject before sign_response in serve_stream
Add a unit/integration test: open a stream with an unknown channel_id, assert the connection receives WrongChannel and zero payload bytes
Consider a tracing::warn! on the rejection to surface abuse attempts in operator logs
Dispatch limiter note: The existing dispatch limiter and 100-stream cap provide partial blast-radius control today, but they do not prevent the leak — they only bound per-connection concurrency. The fix must be at the protocol gate.
kind:bugSomething does not behave as documentedkind:securitySecurity impact; report a vulnerability to [email protected], not hereprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
Activity
github-actions commentedon Jun 9, 2026
🎯 Triage report
serve_streamincrates/node/src/handlers/client.rssignsok: trueand begins streaming bytes before verifying that a payment channel exists. Because theNonechannel path bypasses the owner-binding guard (line 536 only fires when bothverified_clientandchannelareSome), any peer that omits channel setup receives up tomin(blob_size, ~1 MB)per stream for free — repeatable and invisible inregionStats. The fix is a targeted early-reject whenchannel.is_none().📊 Assessment
bug,security,medium,technical🔗 Similar issues
💡 Notes and suggestions
Root cause (confirmed by code reading)
serve_stream(:525–582) fetcheschannelasOption<Arc<Mutex<ChannelDeliveryState>>>. The guard at:536–544only fires when bothverified_clientandchannelareSome. WhenchannelisNonethe guard is silently skipped,ok: trueis signed at:556–565, anddeliveris called withchannel: None. Indeliver, voucher collection only happens at the interval boundary; for blobs ≤ the interval the closing voucher is the only payment gate — but bytes are already gone by then.Suggested fix (two changes)
:527, add an early reject:This is the critical fix. It aligns runtime behaviour with the module-doc invariant from #327 and closes the free-egress window before any bytes leave the node.
:781–783(regionStats) does not account for traffic fromNone-channel streams. Once fix (1) lands this becomes moot for the exploit path, but the accounting gap may still exist for legit streams that hit an error before the first voucher — worth auditing.Sub-task checklist
channel.is_none()early-reject beforesign_responseinserve_streamchannel_id, assert the connection receivesWrongChanneland zero payload bytesregionStatsegress accounting covers the error-path bytes (secondary, lower priority)tracing::warn!on the rejection to surface abuse attempts in operator logsDispatch limiter note: The existing dispatch limiter and 100-stream cap provide partial blast-radius control today, but they do not prevent the leak — they only bound per-connection concurrency. The fix must be at the protocol gate.
Add this agentic workflows to your repo
To install this agentic workflow, run
fix(node): reject unknown payment channel before serving any bytes (#848
feat(node): meter refused serve_stream paid-delivery requests (#876) (#…