Repository navigation
Description
An unverified filter reply can cancel a live request
What goes wrong: The pump marks a filter batch as arrived based on its stop hash alone, even if the peer sent only the last filter or a CFHeaders reply with no hashes. The managers also release requests by hash even when the broker rejected the reply's sender, so an unsolicited or delayed reply can cancel a request assigned to another peer. A peer can keep sync from progressing while retries start over with fresh timeout and attempt state.
How to fix it, 11 places read, and 1 other check · confirmed with tools
How to fix it
Correlate replies with the specific request attempt in the broker and give the manager an acknowledgment that can release only that attempt. Keep incomplete or wrong-type replies on a peer-attributed failure path that preserves retry accounting, and settle CFilters only after the expected range has arrived.
Checked in the code
On the commented line: And 1335 create the arrival key from filter.block_hash or headers.stop_hash without checking the reply type field or range
Checks o.peer == peer || o.hedge == Some(peer) for an on-wire request, but the pump at dash-spv/src/network/manager.rs:1340 forwards the message regardless o…
rust-dashcore/dash-spv/src/network/broker.rs
Lines 201 to 205 in 51a854b
| match reqs.get(&key) { | |
| Some(ReqState::OnWire(o)) if o.peer == peer || o.hedge == Some(peer) => {} | |
| Some(ReqState::Queued(_)) => { | |
| reqs.remove(&key); | |
| self.drop_queued(&key, &reqs).await; |
Calls release_request before matching, and dash-spv/src/sync/filter_headers/pipeline.rs:245 rejects empty filter_hashes only afterward
rust-dashcore/dash-spv/src/sync/filter_headers/sync_manager.rs
Lines 51 to 55 in 51a854b
| if let NetworkMessage::CFHeaders(cfheaders) = &*msg { | |
| network.release_request(RequestKey::CfHeaders(cfheaders.stop_hash)).await; | |
| if self.pipeline.receive_below(cfheaders) { | |
| return self.store_lower_batches().await; | |
| } |
Treats height == tracker.end_height() as grounds to release an incomplete request, and dash-spv/src/sync/filters/sync_manager.rs:126 and 149 release on heade…
rust-dashcore/dash-spv/src/sync/filters/pipeline.rs
Lines 229 to 233 in 51a854b
| } | |
| return if height == tracker.end_height() { | |
| tracing::warn!( | |
| "Filter batch {} ended incomplete with {}/{} filters, requesting it again", | |
| batch_start, |
dash-spv/src/network/broker.rs:127: Removes the entry regardless of its state, and dash-spv/src/network/broker.rs:116 gives the next declarationReqState::Queued(0)dash-spv/src/network/manager.rs:1335:Some(RequestKey::CfHeaders(headers.stop_hash))dash-spv/src/network/manager.rs:1340:broker.arrived(peer, key).await;dash-spv/src/network/broker.rs:209:reqs.insert(key, ReqState::Arrived);dash-spv/src/network/broker.rs:116:reqs.insert(key, ReqState::Queued(0));dash-spv/src/sync/filter_headers/pipeline.rs:245:if cfheaders.filter_hashes.is_empty() {dash-spv/src/sync/filters/sync_manager.rs:149:network.release_request(RequestKey::CFilters(stop_hash)).await;- dashpay/dash:src/net_processing.cpp:3552 and 3558 load the filter range before sending its members, and dashpay/dash:src/net_processing.cpp:3594 and 3601 retur…
Not settled
Manki tried to disprove this by reading the code and could not decide. The pump marks a CFilters key as arrived when the cfilter for the stop hash comes from the request's own peer. The pipeline then returns the stop hash for… See dash-spv/src/network/manager.rs:1331, dash-spv/src/network/manager.rs:1332, dash-spv/src/network/manager.rs:1340, dash-spv/src/network/broker.rs:202, dash-spv/src/network/broker.rs:209, dash-spv/src/sync/filters/pipeline.rs:230, dash-spv/src/sync/filters/pipeline.rs:237, dash-spv/src/sync/filters/sync_manager.rs:148, dash-spv/src/sync/filters/sync_manager.rs:149, dash-spv/src/network/broker.rs:127.
Found by Manki in #1370 at dash-spv/src/network/manager.rs:1332. Requested by @xdustinface. See the review thread.
Activity
[-]An unverified filter reply can cancel a live request[/-][+]dash-spv: a peer that truncates `cfilter` replies is never kicked[/+]xdustinface commentedon Nov 21, 2026
Scope, after the discussion in the review thread: the
cfheaderspart does not stall sync. Attempts only decide whether a timeout still kicks the carrier, and an unmatched reply leaves the batch inbatch_starts, so the honest reply is still processed.The real gap is on the
CFilterspath. A peer that sends only the lastcfilterof a batch gets its key markedArrived, soexpirenever sees it and the peer is never kicked. The incomplete batch is then released and declared again asQueued(0), and can go back to the same peer. A fix needs the broker to keep the peer and attempts of an arrived request and a retry path that counts against that peer. A plain ban on an incomplete batch is wrong: afterreset_for_rescanthe tail of a reply already in flight ends the new batch incomplete, and an honest peer would be banned.