Skip to content

fix(blocksync): prevent maxPeerHeight poisoning by peers with inflated base#40

Merged
fridrik01 merged 2 commits intobera-v1.xfrom
fix-blocksync-maxpeerheight-poisoning
Apr 21, 2026
Merged

fix(blocksync): prevent maxPeerHeight poisoning by peers with inflated base#40
fridrik01 merged 2 commits intobera-v1.xfrom
fix-blocksync-maxpeerheight-poisoning

Conversation

@fridrik01
Copy link
Copy Markdown

@fridrik01 fridrik01 commented Apr 21, 2026

Each peer advertises a (base, height) range in StatusResponse declaring the contiguous blocks it can serve. base is the oldest block it still has (moves up if the peer prunes), height is the newest. A malicious peer can advertise something like base=100_000_000, height=100_000_100 to poison maxPeerHeight with a value no peer can serve, which can deadlock blocksync. The attack window opens on any validator restart, not just on genesis sync.

This is a minimal fix while we wait for the upstream patch.

Changes:

  • updateMaxPeerHeight now excludes peers whose base > pool.height from the maxPeerHeight computation.

Tests:

  • TestBlockPoolIgnoresPeersWithInflatedBase: verifies a peer with base > pool.height does not raise maxPeerHeight.
  • TestBlockPoolTimeout: forced uniform base=start so all peers contribute to maxPeerHeight. The staggered bases from makePeers combined with the new gating would otherwise starve the request pipeline since this test never advances pool.height.

@fridrik01 fridrik01 self-assigned this Apr 21, 2026
@fridrik01 fridrik01 requested a review from calbera April 21, 2026 15:09
@fridrik01 fridrik01 force-pushed the fix-blocksync-maxpeerheight-poisoning branch from 09a1be3 to 08ce249 Compare April 21, 2026 15:49
@fridrik01 fridrik01 marked this pull request as ready for review April 21, 2026 15:56
@fridrik01 fridrik01 merged commit c234299 into bera-v1.x Apr 21, 2026
16 of 17 checks passed
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.

3 participants