Skip to content

dash-spv: a peer that truncates cfilter replies is never kicked #1464

Open

Description

@manki-review

⚠️ Warning · Correctness · Moderate

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…

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

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…

}
return if height == tracker.end_height() {
tracing::warn!(
"Filter batch {} ended incomplete with {}/{} filters, requesting it again",
batch_start,

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

  1. changed the title [-]An unverified filter reply can cancel a live request[/-] [+]dash-spv: a peer that truncates `cfilter` replies is never kicked[/+] on Nov 21, 2026
  2. xdustinface commented on Nov 21, 2026

    @xdustinface
    Collaborator

    Scope, after the discussion in the review thread: the cfheaders part does not stall sync. Attempts only decide whether a timeout still kicks the carrier, and an unmatched reply leaves the batch in batch_starts, so the honest reply is still processed.

    The real gap is on the CFilters path. A peer that sends only the last cfilter of a batch gets its key marked Arrived, so expire never sees it and the peer is never kicked. The incomplete batch is then released and declared again as Queued(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: after reset_for_rescan the tail of a reply already in flight ends the new batch incomplete, and an honest peer would be banned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions