Skip to content

fix(statesync): bound backfill backpressure, spare honest peers on extension-count mismatch, patch grpc CVE - #1451

Merged
lklimek merged 3 commits into
v1.7-devfrom
fix/statesync-backfill-hardening
Sep 9, 2026
Merged

lklimek merged 3 commits into
v1.7-devfrom
fix/statesync-backfill-hardening

Conversation

@lklimek

@lklimek lklimek commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

TL;DR: Fixes three security-hardening gaps found in an independent review: a new node backfilling history from peers could be pushed into unbounded memory growth, an honest peer could get needlessly disconnected during that same backfill, and the node's gRPC servers were running a version with a known remote-DoS vulnerability.

User story

As a node operator running or joining a Dash/Tenderdash network, I want backfill (the process a new or catching-up node uses to pull in historical blocks) to behave safely under adversarial or merely uneven peer conditions, and my node's gRPC servers to not carry known vulnerabilities, so that syncing a new node and running validator/signer infrastructure stays reliable and safe.

Scenario

Base flow

A node performing statesync backfill requests historical light blocks from peers, verifies each one (a real cryptographic cost), and persists it before advancing.

Actual behavior

  • Backfill's fetch loop has no awareness of how far behind verification is running. Peers that respond faster than this node can verify let the fetched-but-unverified backlog grow across the entire backfill span — on a long backfill (a new node joining an established chain) this is an unbounded memory-growth vector.
  • If a peer's view of vote-extension count legitimately disagrees with this node's (a normal consequence of differing extension configuration, not misbehavior), backfill disconnects that peer entirely, even though this exact disagreement is treated as non-fatal everywhere else in the codebase.
  • The node's gRPC servers (ABCI, privval remote signer) run google.golang.org/grpc v1.82.1, which is affected by CVE-2026-84304 (unauthenticated HTTP/2 DATA-frame-fragmentation heap exhaustion).

Expected behavior

  • Backfill bounds how far fetching may run ahead of verification, scaled to the configured fetcher count, without regressing throughput on the honest happy path.
  • A peer is no longer disconnected solely for a vote-extension count mismatch during backfill; it's excluded from that backfill attempt but keeps its connection, consistent with how the rest of the codebase treats this specific, expected disagreement.
  • google.golang.org/grpc is updated past the patched version.

Detailed discussion

What was done

  1. Bound backfill fetch-ahead of verification (internal/statesync/block_queue.go, reactor.go): blockQueue gained a maxFetchAhead bound (Fetchers × 4 by default). A new internal _allocate() hands out a fresh height to fetch only while verifyHeight - fetchHeight < maxFetchAhead; callers past the bound park on the existing waiter mechanism, woken by _resumeFetchers() as verification frees slots. Heights needing a re-fetch are deliberately exempt from the bound — every such height is one the verify loop is still waiting on, so withholding a re-fetch would deadlock the very run the bound protects.
  2. Don't disconnect a backfill peer over ErrVoteExtensionCountMismatch (internal/statesync/reactor.go): in backfill's commit-verification branch, errors.As(verr, &types.ErrVoteExtensionCountMismatch{}) now selects the non-fatal "exclude from this run" outcome instead of disconnecting, matching the severity classification this error already gets elsewhere. Scoped to exactly this error type — no change to any other verification-failure's severity.
  3. google.golang.org/grpc v1.82.1 → v1.83.2 (go.mod/go.sum), patching CVE-2026-84304. v1.83.2 (latest patch on the same minor) was chosen over the minimum-patched v1.83.1 after confirming no breaking API changes reach this repo's usage across every gRPC-importing package.

go.mod also shows large incidental churn unrelated to this PR's content: Go 1.27's toolchain restructures this repo's require blocks on any go mod tidy/go get, independent of any dependency version change (verified: running go mod tidy with zero version bumps on the pristine base already produces the same reformatting). Only the go.sum diff and the single grpc version line reflect an actual change.

Testing

  • New TestBlockQueueBoundsFetchAhead and TestBlockQueueRetriesOutrankFetchAheadBound (the latter guards the re-fetch-exemption deadlock invariant above) — both written red-first.
  • TestBackfillFetchVerifyBackpressure rewritten from documenting the unbounded gap to asserting the bound, plus asserting the happy path still completes and verifies every height (previously only logged). Measured over spans of 200/800/3200: peak fetch-ahead depth falls from tracking the span (159 at span 200) to a flat 16 regardless of span; run duration and blocks served on the happy path are unaffected.
  • New table row in TestReactor_Backfill_ReportsRefusalsBySeverity reproduces the count-mismatch scenario with a real wire payload (an appended VoteExtensionType_DEFAULT extension that passes validation but is excluded from threshold recovery) and asserts the peer is not disconnected, while the existing forged-signature row continues to prove other verification failures still are.
  • internal/statesync and types: full package tests pass, including with -race (no data races detected).
  • Every google.golang.org/grpc-importing package (abci/..., privval/..., cmd/priv_val_server) builds, vets clean, and its tests pass under both normal and -race runs.
  • go mod verify: all modules verified.

Breaking changes

None. All three changes are internal hardening / a dependency patch bump with no API or wire-protocol change.

Checklist

  • I have performed a self-review of my own code (3 review passes; see commit messages for what each caught and fixed)
  • I have commented my code, particularly in hard-to-understand areas (the re-fetch bound exemption and its deadlock rationale)
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation (CHANGELOG.md)

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Prior work

None directly overlapping — PR #1426 (open, fix/statesync-status-metrics) touches nearby statesync metrics wiring but a different concern (status reporting, not backfill backpressure or peer disconnection policy).

Attribution

🤖 Generated with Claude Code

lklimek and others added 3 commits September 9, 2026 11:37
blockQueue.nextHeight allocated the next height to fetch without reference
to how far verification had progressed, tracking only what had been fetched.
Fetching a light block costs a round trip while verifying one costs a BLS
commit check on a single serialized loop, so peers serving faster than this
node verifies grew the fetched-but-unverified backlog in the unbounded
pending map across the entire backfill span - a memory-exhaustion vector on
the long backfill a new node joining an established chain performs.

Bound the heights that may be allocated but not yet verified, scaled to the
fetcher count so the pipeline still saturates its workers. Heights needing a
re-fetch are exempt: they are already counted against the bound and the
verify loop cannot advance past them, so withholding one would deadlock the
run the bound exists to protect.

Measured with the backpressure probe over spans of 200, 800 and 3200: peak
fetch-ahead depth falls from 159 to 16 at span 200 and stays at 16 for every
larger span, where it previously tracked the span. Run duration and blocks
served over the span are unchanged, so the happy path pays nothing.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ismatch

backfill treated every error from ValidatorSet.VerifyCommit as grounds to
disconnect the peer that supplied the commit. types.ErrVoteExtensionCountMismatch
does not deserve that: an honest peer relaying a commit whose vote-extension
configuration differs from this node's reaches it, which is an application
disagreement rather than a forged signature.

verifyCommit already leaves that error untyped for exactly this reason, and
internal/consensus evicts only on the typed ErrInvalidCommitSignature. Backfill
is the error's only untrusted-input path, so disconnecting here defeated the
whole carve-out. Score the peer down instead, matching the severity the
neighbouring refusals already use for causes an honest peer can produce.

The peer is still withdrawn from the run, which is what keeps the run healthy,
and every other verification failure still costs the connection.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
v1.82.1 is affected by CVE-2026-84304: internal/transport stores each
fragmented HTTP/2 DATA frame as a separate recvMsg, so an unauthenticated
peer multiplexing streams of one-byte frames exhausts heap while staying
inside the flow-control windows. This repo exposes gRPC servers in
abci/server and privval/grpc, so the path is reachable.

Fixed upstream in v1.83.1 by receive-buffer compaction; v1.83.2 is the
latest patch of that minor and adds rejection of requests carrying neither
:authority nor Host. Release notes for v1.83.0 through v1.83.2 record no
breaking API changes, and this repo uses only NewServer, NewClient and
generated stubs.

Pulls in transitive updates to golang.org/x/crypto, x/net and x/text.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2512e3b3-655a-483d-880d-a328a94fa88a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lklimek
lklimek marked this pull request as ready for review September 9, 2026 11:46
@thepastaclaw

thepastaclaw commented Sep 9, 2026 •

Copy link
Copy Markdown

🕓 Queued for automated review — 22nd in line, estimated start in ~7 h (commit 4048065)
Estimated review time once started: ~40 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@lklimek lklimek left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lklimek
lklimek enabled auto-merge (squash) September 9, 2026 12:00
@lklimek
lklimek merged commit e8a57b2 into v1.7-dev Sep 9, 2026
20 checks passed
@lklimek
lklimek deleted the fix/statesync-backfill-hardening branch September 9, 2026 12:05
@lklimek lklimek mentioned this pull request Sep 9, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants