AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 54 Bitcoin

validation: avoid duplicates in m_blocks_unlinked

Public commit record

What the developer wrote

Authored by stratospher

68/100 · Adequate
validation: avoid duplicates in m_blocks_unlinked

In a pruned node undergoing a deep reorg, FindMostWorkChain can
insert duplicate entries into m_blocks_unlinked.

This can happen when:
- Traversing from one candidate tip to the fork point adds blocks
whose parents have been pruned.
- Traversing from another candidate tip over the same fork inserts
the same pairs again, since the blocks are shared across
both branches.

When we finally download the missing parent from our peer and call
ReceivedBlockTransactions to process m_blocks_unlinked, the same
entry may be processed multiple times.

This can lead to re-insertion into setBlockIndexCandidates with
a modified nSequenceId, violating its ordering invariants and
causing undefined behavior. So avoid duplicate insertions into
m_blocks_unlinked here.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This Bitcoin Core update fixes a bug where, during a deep chain reorganization on a pruned node, the same block entries could accidentally be added twice to an internal waiting list. If processed twice later, this could corrupt an ordered set used to choose the best chain, potentially causing crashes or undefined behavior. The fix prevents duplicates and adds a safety check.

Recommended action

Apply the patch. It is a targeted correctness fix for pruned nodes. Monitor for related crash reports or consensus anomalies on pruned nodes during large reorgs.

Security signals we found

01

Data structure invariant violation (setBlockIndexCandidates ordering)

02

Undefined behavior from duplicate processing

03

Pruned-node deep reorg trigger condition

04

Internal consistency assertion added in CheckBlockIndex()

Risk score

Why this scored 54/100

Our methodology →
Potential impact 18/30
Exploitability 8/25
Stealth signal 10/15
Affected reach 7/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.